i3-dump-log/main.c: error handling for write(...)
Sascha Kruse authored 11 years ago
Michael Stapelberg committed 11 years ago
41 | 41 | /* The log wrapped. Print the remaining content and reset walk to the top |
42 | 42 | * of the log. */ |
43 | 43 | wrap_count = header->wrap_count; |
44 | write(STDOUT_FILENO, walk, ((logbuffer + header->offset_last_wrap) - walk)); | |
44 | const int len = (logbuffer + header->offset_last_wrap) - walk; | |
45 | if (write(STDOUT_FILENO, walk, len) != len) | |
46 | err(EXIT_FAILURE, "write()"); | |
45 | 47 | walk = logbuffer + sizeof(i3_shmlog_header); |
46 | 48 | return 1; |
47 | 49 | } |
48 | 50 | |
49 | 51 | static void print_till_end(void) { |
50 | 52 | check_for_wrap(); |
51 | int n = write(STDOUT_FILENO, walk, ((logbuffer + header->offset_next_write) - walk)); | |
53 | const int len = (logbuffer + header->offset_next_write) - walk; | |
54 | const int n = write(STDOUT_FILENO, walk, len); | |
55 | if (len != n) | |
56 | err(EXIT_FAILURE, "write()"); | |
52 | 57 | if (n > 0) { |
53 | 58 | walk += n; |
54 | 59 | } |