summaryrefslogtreecommitdiff
path: root/disk-io.c
diff options
context:
space:
mode:
authorQu Wenruo <quwenruo@cn.fujitsu.com>2014-12-19 14:13:09 +0800
committerDavid Sterba <dsterba@suse.cz>2014-12-19 15:04:50 +0100
commite363f6ba095a646dd6634939a43b0db17f34577f (patch)
treec4b3b619a6875b5db0e696ab4ce174d6fdc56df4 /disk-io.c
parent040b3f11ba6b5555d793a9ef79ed4d9032d22370 (diff)
btrfs-progs: Fix a clang dead-judgement warning in disk-io.c.
When compiled with clang, the following warning is outputted. disk-io.c:1017:15: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare] if (dev_size < 0) ~~~~~~~~ ^ ~ 1 warning generated. This is because dev_size is defined as unsigned type, but lseek() will return singed valued. So the judgement will always to false. Use temporary off_t return value to solve it. Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com> Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'disk-io.c')
-rw-r--r--disk-io.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/disk-io.c b/disk-io.c
index 03edf8ef..2bf85869 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -1009,13 +1009,16 @@ int btrfs_scan_fs_devices(int fd, const char *path,
{
u64 total_devs;
u64 dev_size;
+ off_t seek_ret;
int ret;
if (!sb_bytenr)
sb_bytenr = BTRFS_SUPER_INFO_OFFSET;
- dev_size = lseek(fd, 0, SEEK_END);
- if (dev_size < 0)
- return (int)(dev_size);
+ seek_ret = lseek(fd, 0, SEEK_END);
+ if (seek_ret < 0)
+ return -errno;
+
+ dev_size = seek_ret;
lseek(fd, 0, SEEK_SET);
if (sb_bytenr > dev_size) {
fprintf(stderr, "Superblock bytenr is larger than device size\n");