Menu

MISRA False Positive 10.4

Amir
2020-08-27
2020-08-28
  • Amir

    Amir - 2020-08-27

    Hello,

    I've searched for false positives on 10.4 and couldn't find any that exist, so hopefully this isn't a double post. I'm seeing a false positive on the following code:

    uint16_t prechargeV = 0;
    uint16_t auxV = UINT16_MAX;
    prechargeV = Eal_GetPrechargeV();
    auxV = Eal_GetContactorAuxV();
    
    if ((max(auxV, prechargeV) - min(auxV, prechargeV)) <= AUX_V_THRESHOLD_IN_MV) //error here
    

    min/max macros:

    #ifndef max
    #define max(a,b)            (((a) > (b)) ? (a) : (b))
    #endif
    
    #ifndef min
    #define min(a,b)            (((a) < (b)) ? (a) : (b))
    #endif
    

    Error:
    asw\aswContCtrl.c:155:56: style: Required. Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category. [misra-c2012-10.4]

     
  • Georgiy Komarov

    Georgiy Komarov - 2020-08-28

    Hello,

    How does AUX_V_THRESHOLD_IN_MV is defined? What type does it have?

     

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.