[hackers] [ubase] Incomplete output is not an error || sin

From: <git_AT_suckless.org>
Date: Mon, 30 Jun 2014 23:44:31 +0200

commit 135f6012cba72e9b1a44d91f2cf48c0d6c46a2ff
Author: sin <sin_AT_2f30.org>
Date: Mon Jun 30 22:37:56 2014 +0100

    Incomplete output is not an error

diff --git a/dmesg.c b/dmesg.c
index 6f2ed8b..76179a9 100644
--- a/dmesg.c
+++ b/dmesg.c
_AT_@ -8,7 +8,7 @@
 
 #include "util.h"
 
-static int dmesg_show(int fd, const void *buf, size_t n);
+static void dmesg_show(int fd, const void *buf, size_t n);
 
 enum {
         SYSLOG_ACTION_READ_ALL = 3,
_AT_@ -60,9 +60,7 @@ main(int argc, char *argv[])
         if (n < 0)
                 eprintf("klogctl:");
 
- n = dmesg_show(STDOUT_FILENO, buf, n);
- if (n < 0)
- eprintf("dmesg_show:");
+ dmesg_show(STDOUT_FILENO, buf, n);
 
         if (cflag && klogctl(SYSLOG_ACTION_CLEAR, NULL, 0) < 0)
                 eprintf("klogctl:");
_AT_@ -71,16 +69,15 @@ main(int argc, char *argv[])
         return EXIT_SUCCESS;
 }
 
-static int
+static void
 dmesg_show(int fd, const void *buf, size_t n)
 {
         const char *p = buf;
         ssize_t r;
 
         r = write(fd, p, n);
- if (r < 0 || (size_t)r != n)
- return -1;
- if (p[n - 1] != '
')
+ if (r < 0)
+ eprintf("write:");
+ if (r > 0 && p[r - 1] != '
')
                 putchar('
');
- return 0;
 }
Received on Mon Jun 30 2014 - 23:44:31 CEST

This archive was generated by hypermail 2.3.0 : Mon Jun 30 2014 - 23:48:10 CEST