Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chrstphrchvz
Copy link

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
Copy link

CLAassistant commented Aug 21, 2020

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants