Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-29003

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

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

      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:
            kimberly.tao@mongodb.com Kim Tao
            Reporter:
            kelsey.schubert@mongodb.com Kelsey Schubert
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: