CS.CONSTCOND.DO

“do”语句的条件始终为 true 或始终为 false。

示例 1

复制
  class Increaser {
      void Increase() {
          int x = 3;
          do {
              x++;
          } while (3 < 10);  // defect - the condition is constant
          do {
              x--;
          } while(false);    // Ok - typical usage of 'do' constructs when a user to organize a code block
         do {
             return;
         } while(true);     // Ok - typical usage of 'do' constructs when a user to organize an infinite loop
     }
 }

安全培训

应用程序安全培训材料由 Secure Code Warrior 提供。