]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: count length of SPDK_PREFIX in a more human-readable way 10277/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Wed, 13 Jul 2016 07:19:25 +0000 (15:19 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Wed, 13 Jul 2016 07:19:25 +0000 (15:19 +0800)
The strlen() will automatically exclude the NUL terminator of a literal
constant. Also by calling strlen(), we know that we are definitely
operate on a string instead of something odd.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/os/bluestore/BlueStore.cc

index f3b97bd8a128cf8f0ed7267c561f02810c5e6341..0352fceef1a483563a4f1723e4fe4edaef21b223 100644 (file)
@@ -2432,7 +2432,7 @@ int BlueStore::_setup_block_symlink_or_file(
   if (create)
     flags |= O_CREAT;
   if (epath.length()) {
-    if (!epath.compare(0, sizeof(SPDK_PREFIX)-1, SPDK_PREFIX)) {
+    if (!epath.compare(0, strlen(SPDK_PREFIX), SPDK_PREFIX)) {
       r = ::symlinkat(epath.c_str(), path_fd, name.c_str());
       if (r < 0) {
         r = -errno;
@@ -2447,7 +2447,7 @@ int BlueStore::_setup_block_symlink_or_file(
             << cpp_strerror(r) << dendl;
        return r;
       }
-      string serial_number = epath.substr(sizeof(SPDK_PREFIX)-1);
+      string serial_number = epath.substr(strlen(SPDK_PREFIX));
       r = ::write(fd, serial_number.c_str(), serial_number.size());
       assert(r == (int)serial_number.size());
       dout(1) << __func__ << " created " << name << " file with " << dendl;