]> git.sur5r.net Git - i3/i3/blobdiff - i3-dump-log/main.c
Merge branch 'next' into master
[i3/i3] / i3-dump-log / main.c
index acb7fcb1f36308b64a2f075b038668c20f55f00c..137554a4f1fefc36539c5ca8c40b5357b32a7e2a 100644 (file)
@@ -2,7 +2,7 @@
  * vim:ts=4:sw=4:expandtab
  *
  * i3 - an improved dynamic tiling window manager
- * © 2009-2012 Michael Stapelberg and contributors (see also: LICENSE)
+ * © 2009 Michael Stapelberg and contributors (see also: LICENSE)
  *
  * i3-dump-log/main.c: Dumps the i3 SHM log to stdout.
  *
 #include <i3/ipc.h>
 
 static uint32_t offset_next_write,
-                wrap_count;
+    wrap_count;
 
 static i3_shmlog_header *header;
 static char *logbuffer,
-            *walk;
+    *walk;
 
 static int check_for_wrap(void) {
     if (wrap_count == header->wrap_count)
@@ -43,8 +43,7 @@ static int check_for_wrap(void) {
      * of the log. */
     wrap_count = header->wrap_count;
     const int len = (logbuffer + header->offset_last_wrap) - walk;
-    if (write(STDOUT_FILENO, walk, len) != len)
-        err(EXIT_FAILURE, "write()");
+    swrite(STDOUT_FILENO, walk, len);
     walk = logbuffer + sizeof(i3_shmlog_header);
     return 1;
 }
@@ -52,12 +51,8 @@ static int check_for_wrap(void) {
 static void print_till_end(void) {
     check_for_wrap();
     const int len = (logbuffer + header->offset_next_write) - walk;
-    const int n = write(STDOUT_FILENO, walk, len);
-    if (len != n)
-        err(EXIT_FAILURE, "write()");
-    if (n > 0) {
-        walk += n;
-    }
+    swrite(STDOUT_FILENO, walk, len);
+    walk += len;
 }
 
 int main(int argc, char *argv[]) {
@@ -70,8 +65,7 @@ int main(int argc, char *argv[]) {
         {"verbose", no_argument, 0, 'V'},
         {"follow", no_argument, 0, 'f'},
         {"help", no_argument, 0, 'h'},
-        {0, 0, 0, 0}
-    };
+        {0, 0, 0, 0}};
 
     char *options_string = "s:vfVh";
 
@@ -139,7 +133,7 @@ int main(int argc, char *argv[]) {
     if (logbuffer == MAP_FAILED)
         err(EXIT_FAILURE, "Could not mmap SHM segment for the i3 log");
 
-    header = (i3_shmlog_header*)logbuffer;
+    header = (i3_shmlog_header *)logbuffer;
 
     if (verbose)
         printf("next_write = %d, last_wrap = %d, logbuffer_size = %d, shmname = %s\n",