OSDN Git Service

block/bochs: Fix error handling for seek_to_sector()
authorMax Reitz <mreitz@redhat.com>
Tue, 29 Apr 2014 17:03:15 +0000 (19:03 +0200)
committerKevin Wolf <kwolf@redhat.com>
Wed, 30 Apr 2014 12:46:17 +0000 (14:46 +0200)
commite1b42f456fad6e797eaf795ed2e400c4e47d5eb4
treef0a4f982ce7c8c1a10165b42e4eb25715ddf1252
parentb93f995081cc32e56071fef179161d2907d0491e
block/bochs: Fix error handling for seek_to_sector()

Currently, seek_to_sector() returns -1 both for errors and unallocated
sectors, resulting in silent errors. As 0 is an invalid offset of data
clusters (bitmap_offset is greater than 0 because s->data_offset is
greater than 0), just return 0 for unallocated sectors and -errno in
case of error. This should then be propagated by bochs_read(), the sole
user of seek_to_sector().

That function also has a case of "return -1 in case of error", which is
fixed by this patch as well.

bochs_read() is called by bochs_co_read() which passes the return value
through, therefore it is indeed correct for bochs_read() to return
-errno.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/bochs.c