Menu

No check for always true/false expressions since version 1.71

barthess
2016-05-02
2016-05-05
  • barthess

    barthess - 2016-05-02

    Command “cppcheck --enable=all test.cpp”
    successfully founds following error:

    [test.c:5]: (warning) Logical conjunction always evaluates to false: diag == 3 && diag == 1.

    when cppcheck's version is 1.70 but no warning produced in case of version 1.71 and later.

    test.cpp code is:

    void pickle(baro_diff_data_t &result) {
    
      uint8_t diag = rxbuf[0] >> 6;
    
      if ((3 == diag) && (1 == diag)) {
        this->state = SENSOR_STATE_DEAD;
      }
      else {
        result.t   = temp;
      }
    }
    
     

Log in to post a comment.