]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/image: fix unsigned value compared with zero 33937/head
authorChangcheng Liu <changcheng.liu@aliyun.com>
Fri, 13 Mar 2020 01:37:43 +0000 (09:37 +0800)
committerChangcheng Liu <changcheng.liu@aliyun.com>
Fri, 13 Mar 2020 01:41:32 +0000 (09:41 +0800)
buffer::list::length() return value type is unsigned,
it makes none sense to check whether it's less than zero.

Signed-off-by: Changcheng Liu <changcheng.liu@aliyun.com>
src/librbd/librbd.cc

index ca1009e0ee54db351be19b174041bb9f4b09f576..18e18cb625c204b88234b3557ca5200ff940920d 100644 (file)
@@ -2531,9 +2531,9 @@ namespace librbd {
   {
     ImageCtx *ictx = (ImageCtx *)ctx;
     tracepoint(librbd, writesame_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(),
-               ictx->read_only, ofs, len, bl.length() <= 0 ? NULL : bl.c_str(), bl.length(),
+               ictx->read_only, ofs, len, bl.length() == 0 ? NULL : bl.c_str(), bl.length(),
                op_flags);
-    if (bl.length() <= 0 || len % bl.length() ||
+    if (bl.length() == 0 || len % bl.length() ||
         len > static_cast<size_t>(std::numeric_limits<int>::max())) {
       tracepoint(librbd, writesame_exit, -EINVAL);
       return -EINVAL;
@@ -2672,7 +2672,7 @@ namespace librbd {
     tracepoint(librbd, aio_writesame_enter, ictx, ictx->name.c_str(), ictx->snap_name.c_str(),
                ictx->read_only, off, len, bl.length() <= len ? NULL : bl.c_str(), bl.length(),
                c->pc, op_flags);
-    if (bl.length() <= 0 || len % bl.length()) {
+    if (bl.length() == 0 || len % bl.length()) {
       tracepoint(librbd, aio_writesame_exit, -EINVAL);
       return -EINVAL;
     }