Menu

False condition check report

2022-01-29
2022-01-29
  • Mohammadhossein Heydarchi

    Hiii there,

    For the code below Cppcheck 2.6 reports something wrong:

    int ReturnUnicodeType(uint16 temp)
    {
        if (temp< 152)
            return 1;
    
            if (temp>= 152 && temp<232)
            return 2;
    
        return 3;
    }
    

    Report : (style) Condition 'temp>=152' is always true

     
  • Dusan Peterc

    Dusan Peterc - 2022-01-29

    According to my understanding, the style warning is correct.
    You can safely omit the "temp>=152" condition and get the same behavior on all input values.

     
    • Mohammadhossein Heydarchi

      Oh yes👍
      That was my bad.

       

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.