From: Changcheng Liu Date: Fri, 13 Mar 2020 01:37:43 +0000 (+0800) Subject: librbd/image: fix unsigned value compared with zero X-Git-Tag: v16.1.0~2524^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bfe75dd95d78535f94ebc75ab447b67919e6cccd;p=ceph.git librbd/image: fix unsigned value compared with zero 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 --- diff --git a/src/librbd/librbd.cc b/src/librbd/librbd.cc index ca1009e0ee54..18e18cb625c2 100644 --- a/src/librbd/librbd.cc +++ b/src/librbd/librbd.cc @@ -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(std::numeric_limits::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; }