diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2012-03-05 08:56:10 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2012-04-19 16:36:43 +0200 |
commit | 185b43386ad999c80bdc58e41b87f05e5b3e8463 (patch) | |
tree | 326967bbfb0f72801848e9aebbad859f33873828 /qemu-nbd.c | |
parent | fc19f8a02e45c4d8ad24dd7eb374330b03dfc28e (diff) | |
download | hqemu-185b43386ad999c80bdc58e41b87f05e5b3e8463.zip hqemu-185b43386ad999c80bdc58e41b87f05e5b3e8463.tar.gz |
nbd: consistently return negative errno values
In the next patch we need to look at the return code of nbd_wr_sync.
To avoid percolating the socket_error() ugliness all around, let's
handle errors by returning negative errno values.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'qemu-nbd.c')
-rw-r--r-- | qemu-nbd.c | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -126,8 +126,7 @@ static int find_partition(BlockDriverState *bs, int partition, } if (data[510] != 0x55 || data[511] != 0xaa) { - errno = -EINVAL; - return -1; + return -EINVAL; } for (i = 0; i < 4; i++) { @@ -165,8 +164,7 @@ static int find_partition(BlockDriverState *bs, int partition, } } - errno = -ENOENT; - return -1; + return -ENOENT; } static void termsig_handler(int signum) @@ -491,9 +489,12 @@ int main(int argc, char **argv) fd_size = bs->total_sectors * 512; - if (partition != -1 && - find_partition(bs, partition, &dev_offset, &fd_size)) { - err(EXIT_FAILURE, "Could not find partition %d", partition); + if (partition != -1) { + ret = find_partition(bs, partition, &dev_offset, &fd_size); + if (ret < 0) { + errno = -ret; + err(EXIT_FAILURE, "Could not find partition %d", partition); + } } exp = nbd_export_new(bs, dev_offset, fd_size, nbdflags); |