The _read() call may fail and return a negative result,
and thus when it is passed to "resid", which is of type of
"unsigned", overflow happens due to a forced cast that is
implicitly performed.
Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
bufferlist bl;
int r = _read(fh, offset, totallen, &bl);
ldout(cct, 3) << "preadv(" << fd << ", " << offset << ") = " << r << dendl;
+ if (r <= 0)
+ return r;
+
int bufoff = 0;
for (unsigned j = 0, resid = r; j < iovcnt && resid > 0; j++) {
/*