Expression 'i >= 0' is always true. Unsigned type value is always >= 0. mmap_windows.cpp 197

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Fixed
    • Priority: Minor - P4
    • 3.5.9
    • Affects Version/s: None
    • Component/s: Storage
    • Fully Compatible
    • ALL
    • Storage 2017-06-19
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      void* MemoryMappedFile::map(....) {
        ....
        size_t len = strlen(filename);
        for (size_t i = len - 1; i >= 0; i--) {            // <=
          if (filename[i] == '/' || filename[i] == '\\')
            break;
      
          if (filename[i] == ':')
            filename[i] = '_';
        }
        ....
      }
      

      A link to the source code on GitHub

      PVS-Studio warning: V547 Expression 'i >= 0' is always true. Unsigned type value is always >= 0. mmap_windows.cpp 197

      The conditional statement of the loop (i >= 0) should always be true, as the loop counter ( i ) is of unsigned type (size_t).

      This issue was originally reported in SERVER-28570.

            Assignee:
            Kim Tao
            Reporter:
            Kelsey Schubert
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: