From: xie xingguo Date: Wed, 13 Jul 2016 07:19:25 +0000 (+0800) Subject: os/bluestore: count length of SPDK_PREFIX in a more human-readable way X-Git-Tag: ses5-milestone5~363^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=de59926d9596010cd9e9331cc9d6c2e602b814c9;p=ceph.git os/bluestore: count length of SPDK_PREFIX in a more human-readable way 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 --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index f3b97bd8a128..0352fceef1a4 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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;