Codebase list i3-gaps / 5a56705
i3-dump-log/main.c: error handling for write(...) Sascha Kruse authored 11 years ago Michael Stapelberg committed 11 years ago
1 changed file(s) with 7 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
4141 /* The log wrapped. Print the remaining content and reset walk to the top
4242 * of the log. */
4343 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()");
4547 walk = logbuffer + sizeof(i3_shmlog_header);
4648 return 1;
4749 }
4850
4951 static void print_till_end(void) {
5052 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()");
5257 if (n > 0) {
5358 walk += n;
5459 }