[previous] 3314 [next] This controlling expression is an assignment.
Control flow

This controlling expression is an assignment. Are you sure that an assignment operator (=) was intended; or should it really be an equality operator (==) ?

For example:


/*PRQA S 2017,2213,2464,3120,3195,3198,3210,3408,3447 ++*/

extern int x;
extern int g;

extern void foo(void)
{
    int i;

    if (x == g) { }                     /*                                    */
    while (x == g) { }                  /*                                    */
    do { } while (x == g);              /*                                    */
    for (i = 0; i == g; ++i) { }        /*                                    */

    if ((x == g) != 0) { }              /*                                    */
    while ((x == g) != 0) { }           /*                                    */
    do { } while ((x == g) != 0);       /*                                    */
    for (i = 0; (i == g) != 0; ++i) { } /*                                    */

    if (x = g) { }                      /* Message 3314 + 3326, 3344 and 3416 */
    while (x = g) { }                   /* Message 3314 + 3326, 3344 and 3416 */
    do { } while (x = g);               /* Message 3314 + 3326, 3344 and 3416 */
    for (i = 0; i = g; ++i) { }         /* Message 3314 + 3326, 3344 and 3416 */
    switch (x = g)                      /* Message 3314 + 3226                */
    {
    case 1:
        ++x;
        break;
    case 2:
        ++g;
        break;
    default:
        x = g + 1;
        break;
    }
}

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents