Rule 13.4 For statement operand assignment - Printable Version +- MISRA Discussion Forums (https://forum.misra.org.uk) +-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4) +--- Forum: MISRA C:2012 and MISRA C:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=21) +---- Forum: 8.13 Side effects (https://forum.misra.org.uk/forumdisplay.php?fid=168) +---- Thread: Rule 13.4 For statement operand assignment (/showthread.php?tid=1595) |
Rule 13.4 For statement operand assignment - shaw - 07-01-2022 The third operand of the for statement has an assignment. Does the calculation violate the result that the assignment operator should not be used? for ( pos = (&dev->list)->next, q = pos->next; pos != (&dev->list); pos = q, q = pos->next ) {/* */} RE: Rule 13.4 For statement operand assignment - misra-c - 13-01-2022 The code does not violate rule 13.4 "The result of an assignment operator should not be used". Examples of 13.4 violations would be Code: x = pos = q; However, the code does violate: Rule 12.3 "The comma operator should not be used" which includes the 1st and 3rd clauses of a for loop Rule 14.2 "A for loop shall be well-formed". This requires the use of a single loop counter with a scalar type. |