[previous] 1311 [next] 'void *' and 'const T *' pointers used as operands to an equality or conditional operator.
Miscellaneous

A "void *" pointer and a "const T *" pointer are the operands of an equality operator or the 2nd and 3rd operands of a conditional operator.

For example:


/*PRQA S 2213,3112,3198,3227,3408,3447,3602 ++*/

extern       int  * pi;
extern       void * pv;

extern const int  * pci;
extern const void * pcv;

extern void foo(int n)
{

    pv = pi;
    pcv = pci;

    pi = pv;
    pci = pcv;

    (n > 0) ? pv  : pi;                         /*              */
    (n > 0) ? pcv : pci;                        /*              */
    (n > 0) ? pv  : pci;                        /* Message 1311 */
    (n > 0) ? pcv : pi;                         /*              */


    pv  = (n > 0) ? pv  : pi;                   /*              */
    pcv = (n > 0) ? pcv : pci;                  /*              */
    pv  = (n > 0) ? pv  : pci;                  /* Message 1311 */
    pcv = (n > 0) ? pcv : pi;                   /*              */


    pi  = (n > 0) ? pv  : pi;                   /*              */
    pci = (n > 0) ? pcv : pci;                  /*              */
    pi  = (n > 0) ? pv  : pci;                  /* Message 1311 */
    pci = (n > 0) ? pcv : pi;                   /*              */


    if (pv  == pi ) { }                         /*              */
    if (pcv == pci) { }                         /*              */
    if (pv  == pci) { }                         /* Message 1311 */
    if (pcv == pi ) { }                         /*              */

    if (pv  != pi ) { }                         /*              */
    if (pcv != pci) { }                         /*              */
    if (pv  != pci) { }                         /* Message 1311 */
    if (pcv != pi ) { }                         /*              */

}

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