Skip to content

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

Merged
merged 2 commits into from
Mar 7, 2018

Conversation

pauluap
Copy link

@pauluap pauluap commented Mar 4, 2018

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

  • Fix
  • Refactor
  • New target
  • Feature
  • Breaking change

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)) {
@0xc0170
Copy link
Contributor

0xc0170 commented Mar 5, 2018

@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)

@pauluap
Copy link
Author

pauluap commented Mar 5, 2018

I clicked "accept" on the contributor agreement link, not sure if you get notified of that

geky
geky previously approved these changes Mar 5, 2018
Copy link
Contributor

@geky geky left a 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 👍

@@ -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)) {
Copy link
Contributor

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.

Copy link
Contributor

@geky geky left a 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

@cmonr
Copy link
Contributor

cmonr commented Mar 6, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Mar 6, 2018

Build : SUCCESS

Build number : 1356
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/6263/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Mar 6, 2018

@mbed-ci
Copy link

mbed-ci commented Mar 6, 2018

@studavekar
Copy link
Contributor

/morph mbed2-build

@cmonr cmonr merged commit 4b322d6 into ARMmbed:master Mar 7, 2018
@pauluap pauluap deleted the equeue_gcc7_c++x11_warning branch April 16, 2018 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants