Menu

Is it an "unread variable" false positive ?

2016-06-28
2016-07-07
  • Rei Angelus

    Rei Angelus - 2016-06-28

    Hello,

    In the code below, cppcheck detect the variable 'fValeur' has unread. I think it made a mistake.

    switch (pnodeCurrent->left.pnode->usLen)
    {
    case 4:
    fValeur = (float)pevalDataLeft->data.fd;
    pcOctet = (unsigned char*)&fValeur;
    break;
    .....
    default:
    assert(FALSE);
    break;
    }

    Thanks

     

    Last edit: Rei Angelus 2016-06-28
  • Daniel Marjamäki

    Maybe it is a false positive. Is pcOctet data read?

     
  • Rei Angelus

    Rei Angelus - 2016-06-30

    Yes, pcOctet is used just after the switch :

    The whome code is :

    static _evalData _inzevalProc_HEX_OP_DOUBLE(inzeval pEval,
    inznode pnodeCurrent)
    {
    int iIndice;
    char
    pcData;
    unsigned char* pcOctet = NULL;
    float fValeur;

    EVAL_PROC_NULL_BEGIN(pnodeCurrent->usTypeOp)
    
    pevalDataResult->data.vc.isLen = pnodeCurrent->usLen;
    
    switch (pnodeCurrent->left.pnode->usLen)
    {
        case 4:
            fValeur = (float)pevalDataLeft->data.fd;
            pcOctet = (unsigned char*)&fValeur;
            break;
    
        case 8:
            pcOctet = (unsigned char*)&pevalDataLeft->data.fd;
            break;
    
        default:
            assert(FALSE);                 
            break;
    }
    
    pcData = pevalDataResult->data.vc.acData;
    
    for (iIndice = 1; iIndice <= (pnodeCurrent->usLen / 2); iIndice++)
    {
        *pcData = gacHexChar[(*pcOctet >> 4) & 0x0F];
        *(pcData + 1) = gacHexChar[*pcOctet & 0x0F];
    
        pcOctet++;
        pcData = pcData + 2;
    }
    
    EVAL_PROC_NULL_END
    

    }

     

    Last edit: Rei Angelus 2016-06-30

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.