]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/filestore: silence -Wformat-truncation= warning 21837/head
authorKefu Chai <kchai@redhat.com>
Sun, 6 May 2018 07:25:00 +0000 (15:25 +0800)
committerKefu Chai <kchai@redhat.com>
Sun, 6 May 2018 07:26:14 +0000 (15:26 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/os/filestore/FileStore.cc

index dd77fd722336376933a2ee2a56d4f09ce7811dcb..5754075c5b0a35ab57fcaf62657ff8824186a347 100644 (file)
@@ -4892,7 +4892,11 @@ int FileStore::list_collections(vector<coll_t>& ls, bool include_temp)
       // d_type not supported (non-ext[234], btrfs), must stat
       struct stat sb;
       char filename[PATH_MAX];
-      snprintf(filename, sizeof(filename), "%s/%s", fn, de->d_name);
+      if (int n = snprintf(filename, sizeof(filename), "%s/%s", fn, de->d_name);
+         n >= static_cast<int>(sizeof(filename))) {
+       derr << __func__ << " path length overrun: " << n << dendl;
+       assert(false);
+      }
 
       r = ::stat(filename, &sb);
       if (r < 0) {