Closed
Conversation
Some `#ifdef`s in this file are redundant and weirdly placed inside the
respective branches of an `if { } else { }`.
This PR puts the `#ifdef` *around* the `if { } else { }`, reducing the
number of `#ifdef`s in this file, and making it more readable for humans
and tools like `cppcheck` alike ;-).
aabadie
reviewed
Nov 28, 2017
| gpio_init(dev->conf->reset, GPIO_OUT); | ||
| gpio_set(dev->conf->reset); | ||
| dev->mode = mode; | ||
| if (mode == PN532_I2C) { |
Contributor
There was a problem hiding this comment.
Not sure of the fix here. This may increase the generated code size.
Member
Author
There was a problem hiding this comment.
@aabadie If anything, the contrary is the case. The if is now in the #ifdef, so we get a condition check and 2 jump instructions less, even if the optimizer wouldn't already deal with that.
jnohlgard
reviewed
Nov 28, 2017
Member
jnohlgard
left a comment
There was a problem hiding this comment.
Note that the two ifdefs are for different bus types (i2c vs spi)
I don't think this PR will work properly.
| #endif | ||
| } | ||
| else { | ||
| #ifdef PN532_SUPPORT_SPI |
Contributor
There was a problem hiding this comment.
because of this, the 2 blocks are built depending on these 2 bus flags.
Member
Author
Arghs, you are right. Nevermind then! |
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.
Some
#ifdefs in this file are redundant and weirdly placed inside therespective branches of an
if { } else { }.This PR puts the
#ifdefaround theif { } else { }, reducing thenumber of
#ifdefs in this file, and making it more readable for humansand tools like
cppcheckalike ;-).This is a follow-up on #7994 (comment)