sahlberg / libnfs

NFS client library
Other
524 stars 201 forks source link

Fix compiler warnings and a subtle precedence error #452

Closed linuxsmiths closed 7 months ago

linuxsmiths commented 7 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.