From bfe75dd95d78535f94ebc75ab447b67919e6cccd Mon Sep 17 00:00:00 2001 From: Changcheng Liu Date: Fri, 13 Mar 2020 09:37:43 +0800 Subject: [PATCH] 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 --- src/librbd/librbd.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/librbd/librbd.cc b/src/librbd/librbd.cc index ca1009e0ee5..18e18cb625c 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; } -- 2.39.5