aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2007-08-30 21:18:25 +0000
committerRafael J. Wysocki <rjw@sisk.pl>2007-08-30 21:18:25 +0000
commite832c8c05d3e897e809d1aabdf64908c9e7c03c3 (patch)
tree9a8d5549f09c2191d5229777e3ad1ea249de0377
parent94d41e6d8ec3246962f3b48a4c8d75d6e8885a86 (diff)
downloadsuspend-utils-e832c8c05d3e897e809d1aabdf64908c9e7c03c3.tar.gz
Clean up the code in suspend.c (part 5).
-rw-r--r--suspend.c54
1 files changed, 28 insertions, 26 deletions
diff --git a/suspend.c b/suspend.c
index 1c805e3..f0eb3fb 100644
--- a/suspend.c
+++ b/suspend.c
@@ -495,38 +495,40 @@ static int save_image(struct swap_map_handle *handle,
else
writeout_rate = nr_pages;
- nr_pages = 0;
- do {
+ for (nr_pages = 0; ; nr_pages++) {
ret = read(handle->dev, handle->page_buffer, page_size);
- if (ret > 0) {
- error = swap_write_page(handle);
- if (error)
- break;
+ if (ret <= 0)
+ break;
+
+ error = swap_write_page(handle);
+ if (error)
+ break;
- if (!(nr_pages % m)) {
- printf("\b\b\b\b%3d%%", nr_pages / m);
- splash.progress(20 + (nr_pages / m) * 0.75);
-
- switch (splash.key_pressed()) {
- case ABORT_KEY_CODE:
- if (abort_possible) {
- printf(" aborted!\n");
- error = -EINTR;
- goto Exit;
- }
+ if (!(nr_pages % m)) {
+ printf("\b\b\b\b%3d%%", nr_pages / m);
+ splash.progress(20 + (nr_pages / m) * 0.75);
+
+ switch (splash.key_pressed()) {
+ case ABORT_KEY_CODE:
+ if (abort_possible) {
+ printf(" aborted!\n");
+ error = -EINTR;
+ goto Exit;
+ }
break;
- case REBOOT_KEY_CODE:
- printf (" reboot enabled\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b");
- shutdown_method = SHUTDOWN_METHOD_REBOOT;
+ case REBOOT_KEY_CODE:
+ printf (" reboot enabled\b\b\b\b\b\b\b"
+ "\b\b\b\b\b\b\b\b");
+ shutdown_method =
+ SHUTDOWN_METHOD_REBOOT;
break;
- }
}
- if (!(nr_pages % writeout_rate))
- start_writeout(handle->fd);
-
- nr_pages++;
}
- } while (ret > 0);
+
+ if (!(nr_pages % writeout_rate))
+ start_writeout(handle->fd);
+ }
+
if (ret < 0)
error = -errno;