[previous] MISRA C:2012  Rule-13.4:  (Advisory) [next] The result of an assignment operator should not be used

Amplification:

This rule applies even if the expression containing the assignment operator is not evaluated.

Example Code:


#include <stdbool.h>
#include "misra.h"
#include "m3cmex.h"


extern int16_t rule_1304( void )
{
    int16_t buf[10] = {0};

    buf[u16a] = buf[u16b = u16c];               /* 3226           */

    if ( bla = false )                          /* 3326      2992 */
    {
    }

    if ((0u == 0u) || (bla = true))             /* 3326 3415 2991 */
    {
    }

    if ( ( uia = get_u16() ) != 0u)             /* 3326           */
    {
    }

    buf[ u16a += u16b ] = buf [ u16c ];         /* 3226           */

    s16a = s16b = s16c = 0;                     /* 3226 3226      */

    return 1;
}


QAC messages that encompass this guideline:

3226 The result of an assignment is being used in an arithmetic operation or another assigning operation.
3326 The result of an assignment is being used in a logical operation.



(c) The Motor Industry Research Association, 2012
QA C Source Code Analyser 8.1.2
MISRA C:2012 Compliance Module 1.0
© 2013 Programming Research
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index Contents