Menu

knownConditionTrueFalse FP?

jacob s
2021-10-28
2021-11-01
  • jacob s

    jacob s - 2021-10-28

    hi,
    i believe this is a false positive:

    static void fun(message_t *message) {
        if (message->length >= 1) {
            switch (data[0]) {
            }
        }
        uint8_t d0 = message->length > 0 ? data[0] : 0xff;
    }
    

    gives:

    test.c:6:34: style: Condition 'message->length>0' is always false [knownConditionTrueFalse]
        uint8_t d0 = message->length > 0 ? data[0] : 0xff;
                                     ^
    test.c:2:25: note: Assuming that condition 'message->length>=1' is not redundant
        if (message->length >= 1) {
                            ^
    test.c:6:34: note: Condition 'message->length>0' is always false
        uint8_t d0 = message->length > 0 ? data[0] : 0xff;
    

    on latest main HEAD (d90ee9bfb9940fe84a826ad0267e5b1db55d23b8)

    thanks, jacob

     
  • Daniel Marjamäki

    Thanks! I agree. the trac server is down so I can't create a ticket right now :-(

     
  • jacob s

    jacob s - 2021-11-01

    the trac server seems to be up now :)

     
    • Daniel Marjamäki

      thanks! I forgot this. I have now created this ticket: https://trac.cppcheck.net/ticket/10582

       

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.