-
Notifications
You must be signed in to change notification settings - Fork 3k
Clarify intention between comparison to zero and the shift operation #6263
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
Conversation
Building with (GNU Tools for Arm Embedded Processors 7-2017-q4-major) 7.2.1 20170904 gives this warning ../events/equeue/equeue.c: In function 'equeue_incid': ../events/equeue/equeue.c:40:17: warning: '<<' in boolean context, did you mean '<' ? [-Wint-in-bool-context] if (!(e->id << q->npw2)) {
@pauluap Thanks for the fix. Can you please sign https://os.mbed.com/contributor_agreement/ ? Please use the github template to specify what type of PR is it (I updated it for now) |
I clicked "accept" on the contributor agreement link, not sure if you get notified of that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking care of that warning 👍
events/equeue/equeue.c
Outdated
@@ -37,7 +37,7 @@ static inline int equeue_clampdiff(unsigned a, unsigned b) { | |||
// Increment the unique id in an event, hiding the event from cancel | |||
static inline void equeue_incid(equeue_t *q, struct equeue_event *e) { | |||
e->id += 1; | |||
if (!(e->id << q->npw2)) { | |||
if (0 == (e->id << q->npw2)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Could you flip the order of this comparison? It's easier to read with constants on the right, and all of our compilers have warnings against asignments in if statements anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Look good to me
/morph build |
Build : SUCCESSBuild number : 1356 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 1009 |
/morph mbed2-build |
Description
Building with (GNU Tools for Arm Embedded Processors 7-2017-q4-major) 7.2.1 20170904 gives this warning
../events/equeue/equeue.c: In function 'equeue_incid':
../events/equeue/equeue.c:40:17: warning: '<<' in boolean context, did you mean '<' ? [-Wint-in-bool-context]
if (!(e->id << q->npw2)) {
Pull request type