Use null check instead of pointer comparison #701
Merged
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.
The original code worked for xc8 v1.44, but does not compile with v2.45. I think the compiler failure is correct. In general, from what I understand of the C standard, it's not allowed to compare pointers unless they are to the same array or structure. I don't know how the compiler would know that and don't fully understand the reasoning for the rule, but maybe it's due to segmented memory addressing.
Anyway, the change I made should be logically equivalent; comparing both expected and actual against null rather than comparing them with each other.
Also, the comment above the change line was confusing so I re-wrote it.
This change fixes the issue I added last week, #700