Unidata / UDUNITS-2

API and utility for arithmetic manipulation of units of physical quantities
http://www.unidata.ucar.edu/software/udunits
Other
62 stars 36 forks source link

prog/udunits2.c: suppress -Wparentheses warning #95

Open chrstphrchvz opened 4 years ago

chrstphrchvz commented 4 years ago

Recent compilers' -Wparentheses will warn if an assignment is used in a condition (in case the programmer meant to use ==):

UDUNITS-2-2.2.27.14/prog/udunits2.c:216:22: warning: using the result of an assignment as a condition without parentheses [-Wparentheses]
        while (*cp++ = tolower(*string++))
               ~~~~~~^~~~~~~~~~~~~~~~~~~~
/opt/local/var/macports/build/_Users_runner_work_1_s_science_udunits2/udunits2/work/UDUNITS-2-2.2.27.14/prog/udunits2.c:216:22: note: place parentheses around the assignment to silence this warning
        while (*cp++ = tolower(*string++))
                     ^
               (                         )
/opt/local/var/macports/build/_Users_runner_work_1_s_science_udunits2/udunits2/work/UDUNITS-2-2.2.27.14/prog/udunits2.c:216:22: note: use '==' to turn this assignment into an equality comparison
        while (*cp++ = tolower(*string++))
                     ^
                     ==
1 warning generated.

Surrounding the assignment with additional parentheses indicates that the assignment is intentional, preventing the warning.

CLAassistant commented 4 years ago

CLA assistant check
All committers have signed the CLA.