Bug #3584
libosmovty/command.c: (!elem->attr & CMD_ATTR_DEPRECATED), missing parentheses?
100%
Description
Just noticed while building with clang-4.0:
make[2]: Entering directory `/home/.../osmocom/libosmocore/src/vty' CC buffer.lo CC command.lo CC utils.lo CC vector.lo CC vty.lo command.c:682:8: warning: logical not is only applied to the left hand side of this bitwise operator [-Wlogical-not-parentheses] if (!elem->attr & CMD_ATTR_DEPRECATED) ^ ~ command.c:682:8: note: add parentheses after the '!' to evaluate the bitwise operator first if (!elem->attr & CMD_ATTR_DEPRECATED)
This warning appears a few times. I guess (not sure) the condition should look like this:
if (!elem->attr & CMD_ATTR_DEPRECATED) ...
Associated revisions
vty reference: fix deprecation bit evaluation
In vty_dump_nodes(), make sure the bitwise & is evaluated first.
For the deprecation flag (0x1), the practical effect is most likely identical,
assuming that the boolean ! operator flips the first bit, so I expect no
visible functional difference. It still was confusing and wrong to look at.
Related: OS#3584
Change-Id: I1f18e0e41da4772d092d71261b9e489dc1598923
vty list: fix deprecation/hidden bit logic
If a command is both hidden and deprecated, still don't show it for the 'list'
command.
We currently have no such nodes, as it seems, though.
Related: OS#3584
Change-Id: I07ec15cab057a3e09064e0420a69121ee8eb4253
History
#1 Updated by fixeria over 2 years ago
[...] I guess (not sure) the condition should look like this:
if (!(elem->attr & CMD_ATTR_DEPRECATED)) ...
#2 Updated by neels over 2 years ago
let me add
&& !(cmd->attr == CMD_ATTR_DEPRECATED || cmd->attr == CMD_ATTR_HIDDEN))
So it would be not hidden when it is both "deprecated" and "hidden".
#3 Updated by neels over 2 years ago
- Status changed from New to In Progress
- Assignee set to neels
- Priority changed from Normal to Low
- % Done changed from 0 to 90
remote: https://gerrit.osmocom.org/#/c/libosmocore/+/11070 vty reference: fix deprecation bit evaluation
remote: https://gerrit.osmocom.org/#/c/libosmocore/+/11071 vty list: fix deprecation/hidden bit logic
#4 Updated by fixeria over 2 years ago
- Status changed from In Progress to Resolved
- % Done changed from 90 to 100
Merged. No warnings anymore.
vty/command.h: document and prettify CMD_ATTR_* flags
Since the CMD_ATTR_* flags are intended to be used in bitwise
operations, let's assign them proper values. Adding a new flag
(e.g. CMD_ATTR_FOO_BAR) could actually result in assigning 0x03
instead of expected (0x01 << 2).
Change-Id: I3b1badef830f7e6436a67673b5709ec33c060c68
Related: OS#3584