10002 librcm: bitwise comparison always evaluates to false
Review Request #1294 — Created Nov. 22, 2018 and submitted
Information | |
---|---|
tsoome | |
illumos-gate | |
10002 | |
cc3f319... | |
Reviewers | |
general | |
../librcm.c:139:46: error: bitwise comparison always evaluates to false [-Werror=tautological-compare] ((flag & RCM_DR_OPERATION|RCM_MOD_INFO) == 0)) { ^~ cc1: all warnings being treated as errors
-
-
usr/src/lib/librcm/librcm.c (Diff revision 1) Maybe excess parentheses resulted in unclarity and the bug to begin with? I wonder if instead of adding a couple more parentheses, trimming down to one outer pair for the if and one pair for the OR-ed bits would be clearer.
-
-
usr/src/lib/librcm/librcm.c (Diff revision 1) Missing blanks around
|
, should be:((flag & (RCM_DR_OPERATION | RCM_MOD_INFO)) == 0)) {
From C Style and Coding Standards for SunOS, page 17:
All binary operators except . and –> should be separated from their operands by blanks. In other words, blanks should appear around assignment, arithmetic, relational, and logical operators. Blanks should never separate unary operators such as unary minus, address (‘&’), indirection (‘*’), increment (‘++’), and decrement (‘--’) from their operands. Note that this includes the unary * that is a part of pointer declarations.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 2 (+4 -4) |
-
-
usr/src/lib/librcm/librcm.c (Diff revision 2) Wrong evaluation order:
1.rsrcname == NULL
2.(RCM_DR_OPERATION | RCM_MOD_INFO) == 0
evalutes to 0
3.flag & 0
4.(rsrcname == NULL) && (flag & 0)
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 3 (+4 -4) |