summaryrefslogtreecommitdiffstats
path: root/sys-utils/dmesg.c
diff options
context:
space:
mode:
authorKarel Zak2011-07-01 13:49:25 +0200
committerKarel Zak2011-07-01 13:49:25 +0200
commiteed99b2a7ce195835b252833a4f07823f57b0a03 (patch)
tree5e8162f9328a1229053328c38cc175c9fca2d07f /sys-utils/dmesg.c
parentdmesg: use SYSLOG_ACTION_* macros rather than magic constatnts (diff)
downloadkernel-qcow2-util-linux-eed99b2a7ce195835b252833a4f07823f57b0a03.tar.gz
kernel-qcow2-util-linux-eed99b2a7ce195835b252833a4f07823f57b0a03.tar.xz
kernel-qcow2-util-linux-eed99b2a7ce195835b252833a4f07823f57b0a03.zip
dmesg: refactoring - cleanup get bufsize code
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/dmesg.c')
-rw-r--r--sys-utils/dmesg.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c
index 7734cd085..3b72cfaf8 100644
--- a/sys-utils/dmesg.c
+++ b/sys-utils/dmesg.c
@@ -64,6 +64,13 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
}
+static int get_buffer_size()
+{
+ int n = klogctl(SYSLOG_ACTION_SIZE_BUFFER, NULL, 0);
+
+ return n > 0 ? n : 0;
+}
+
int main(int argc, char *argv[])
{
char *buf = NULL;
@@ -134,11 +141,8 @@ int main(int argc, char *argv[])
return EXIT_SUCCESS;
}
- if (!bufsize) {
- n = klogctl(SYSLOG_ACTION_SIZE_BUFFER, NULL, 0);
- if (n > 0)
- bufsize = n;
- }
+ if (!bufsize)
+ bufsize = get_buffer_size();
if (bufsize) {
sz = bufsize + 8;