On 8/26/22 09:21, Jan Beulich wrote:
On 25.08.2022 20:09, Stefano Stabellini wrote:
But first, let's confirm whether this change:
#define dt_for_each_property_node(dn, pp) \
- for ( pp = dn->properties; pp != NULL; pp = pp->next )
+ for ( pp = (dn)->properties; pp != NULL; pp = (pp)->next )
is sufficient to make the violation go away in Eclair or cppcheck. I am
assuming it is not sufficient, but let's confirm.
Well, even if for the lhs of assignments there was an exception, this
still wouldn't be sufficient. The minimum needed is
#define dt_for_each_property_node(dn, pp) \
for ( pp = (dn)->properties; (pp) != NULL; pp = (pp)->next )
If pp is assumed to be a valid lvalue, then why it is needed to add
parentheses here (pp) != NULL ?
For the violations to go away, parentheses should be placed around all
macro parameters that represent expressions, that is
#define dt_for_each_property_node(dn, pp) \
for ( (pp) = (dn)->properties; (pp) != NULL; (pp) = (pp)->next )
--
Xenia