CWARN.CONSTCOND.DOCondition of do statement is constantThe CWARN.CONSTCOND.DO checker finds instances in which the condition of a do statement is constant. Vulnerability and riskA constant condition for a statement typically results in the program's intention not being accomplished, with probable unexpected consequences. Vulnerable code example1 void foo() { 2 int x = 3; 3 do { 4 x++; 5 } while (x = 10); 6 } In this example, Klocwork flags line 5, in which the condition (x=10) is constant. Fixed code example1 void foo() { 2 int x = 3; 3 do { 4 x++; 5 } while (<10); 6 } In the fixed example, the condition is no longer a constant. |