mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 03:36:19 +00:00
PM / Hibernate: Fix error handling in save_image()
There are too many retval variables in save_image(). Thus error return value from snapshot_read_next() may be ignored and only part of the snapshot (successfully) written. Remove 'error' variable, invert the condition in the do-while loop and convert the loop to use only 'ret' variable. Switch the rest of the function to consider only 'ret'. Also make sure we end printed line by \n if an error occurs. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
This commit is contained in:
parent
76b57e613f
commit
4ff277f9e4
1 changed files with 16 additions and 16 deletions
|
@ -314,7 +314,6 @@ static int save_image(struct swap_map_handle *handle,
|
|||
{
|
||||
unsigned int m;
|
||||
int ret;
|
||||
int error = 0;
|
||||
int nr_pages;
|
||||
int err2;
|
||||
struct bio *bio;
|
||||
|
@ -329,26 +328,27 @@ static int save_image(struct swap_map_handle *handle,
|
|||
nr_pages = 0;
|
||||
bio = NULL;
|
||||
do_gettimeofday(&start);
|
||||
do {
|
||||
while (1) {
|
||||
ret = snapshot_read_next(snapshot, PAGE_SIZE);
|
||||
if (ret > 0) {
|
||||
error = swap_write_page(handle, data_of(*snapshot),
|
||||
&bio);
|
||||
if (error)
|
||||
if (ret <= 0)
|
||||
break;
|
||||
ret = swap_write_page(handle, data_of(*snapshot), &bio);
|
||||
if (ret)
|
||||
break;
|
||||
if (!(nr_pages % m))
|
||||
printk("\b\b\b\b%3d%%", nr_pages / m);
|
||||
nr_pages++;
|
||||
}
|
||||
} while (ret > 0);
|
||||
err2 = wait_on_bio_chain(&bio);
|
||||
do_gettimeofday(&stop);
|
||||
if (!error)
|
||||
error = err2;
|
||||
if (!error)
|
||||
if (!ret)
|
||||
ret = err2;
|
||||
if (!ret)
|
||||
printk("\b\b\b\bdone\n");
|
||||
else
|
||||
printk("\n");
|
||||
swsusp_show_speed(&start, &stop, nr_to_write, "Wrote");
|
||||
return error;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue