]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
xfsprogs: fix wrong variable types in pwrite/pread code
authorZirong Lang <zlang@redhat.com>
Mon, 20 Nov 2017 19:53:56 +0000 (13:53 -0600)
committerEric Sandeen <sandeen@redhat.com>
Mon, 20 Nov 2017 19:53:56 +0000 (13:53 -0600)
commit421c9220f91360f81717cd09c1d6ae6e8cc584d6
tree4d87f04b83756d85d8e1dcb4318ab1a6ff1d20a8
parent84fe80ce4ed4a74166adfec42f524ac504a2bb01
xfsprogs: fix wrong variable types in pwrite/pread code

The 'Coverity Scan' found a problem in new write_once() function:

272             size_t bytes;
273             bytes = do_pwrite(file->fd, offset, count, count, pwritev2_flags);
>>>     CID 1420710:  Control flow issues  (NO_EFFECT)
>>>     This less-than-zero comparison of an unsigned value is never true. "bytes < 0UL".
274             if (bytes < 0)
275                     return -1;

That's unreasonable. do_pwrite return 'ssize_t' type value, which can
be less than zero, but we use a 'size_t' to get the return value. So
change the size_t to ssize_t for it can store the return value
correctly.

By the chance, correct all 'ssize_t' type problems in pwrite/pread
related functions.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
[sandeen: modify commit summary]
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
io/pread.c
io/pwrite.c