Add parentheses around use of zerouuid macro#371
Merged
jacobperron merged 1 commit intomasterfrom Jan 9, 2019
Merged
Conversation
Otherwise the preprocessor may gobble up the commas in mistake of extra parameters when it is passed to uuidcmpzero. cppcheck v1.86 was complaining about this line.
Member
Author
clalancette
reviewed
Jan 9, 2019
| #define uuidcmp(uuid0, uuid1) (0 == memcmp(uuid0, uuid1, UUID_SIZE)) | ||
| #define zerouuid (uint8_t[UUID_SIZE]) {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} | ||
| #define uuidcmpzero(uuid) uuidcmp(uuid, zerouuid) | ||
| #define uuidcmpzero(uuid) uuidcmp(uuid, (zerouuid)) |
Contributor
There was a problem hiding this comment.
Is there any particular reason to make this (and uuidcmp above) macros? It seems like they can just as easily be done as functions, and then you'd get type-checking and no weird pre-processor things either.
Member
Author
There was a problem hiding this comment.
I don't recall a particular reason. I guess because it was more terse this way.
dirk-thomas
approved these changes
Jan 9, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Otherwise the preprocessor may gobble up the commas in mistake of extra parameters when it is passed to uuidcmpzero.
cppcheck v1.86 was complaining about this line.