dmesg: fix usage and code-style

This commit is contained in:
Hiltjo Posthuma 2015-02-06 15:10:34 +01:00 committed by sin
parent 4855f188c1
commit 1c7b96de55

32
dmesg.c
View File

@ -8,8 +8,6 @@
#include "util.h"
static void dmesg_show(const void *buf, size_t n);
enum {
SYSLOG_ACTION_READ_ALL = 3,
SYSLOG_ACTION_CLEAR = 5,
@ -17,10 +15,23 @@ enum {
SYSLOG_ACTION_SIZE_BUFFER = 10
};
static void
dmesg_show(const void *buf, size_t n)
{
const char *p = buf;
ssize_t r;
r = write(1, p, n);
if (r < 0)
eprintf("write:");
if (r > 0 && p[r - 1] != '\n')
putchar('\n');
}
static void
usage(void)
{
eprintf("usage: [-Ccr] [-n level] %s\n", argv0);
eprintf("usage: %s [-Ccr] [-n level]\n", argv0);
}
int
@ -67,17 +78,4 @@ main(int argc, char *argv[])
free(buf);
return 0;
}
static void
dmesg_show(const void *buf, size_t n)
{
const char *p = buf;
ssize_t r;
r = write(1, p, n);
if (r < 0)
eprintf("write:");
if (r > 0 && p[r - 1] != '\n')
putchar('\n');
}
}