sahlberg / libnfs

NFS client library
Other
510 stars 200 forks source link

Fix compiler warnings and a subtle precedence error #452

Closed linuxsmiths closed 5 months ago

linuxsmiths commented 5 months ago

Most of the warnings are due to -Wunused-but-set-variable, one is due to -Wdiscarded-qualifiers. There are couple due to -Wparentheses. Those are noteworthy as the default precedence w/o the missing paranthesis is not what we want.

e.g., We have : 4 - count & 0x03 We want : 4 - (count & 0x03) We get : (4 - count) & 0x03

This is because '-' operator has higher precedence than '&' and they have left-to-right associativity.

Luckily, for the case (count & 0x03), the incorrect precedence also results in the same result, so it should not affect anything.