From: Karel Zak Date: Fri, 1 Jul 2011 11:49:25 +0000 (+0200) Subject: dmesg: refactoring - cleanup get bufsize code X-Git-Tag: v2.20-rc1~125 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eed99b2a7ce195835b252833a4f07823f57b0a03;p=thirdparty%2Futil-linux.git dmesg: refactoring - cleanup get bufsize code Signed-off-by: Karel Zak --- diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c index 7734cd0857..3b72cfaf85 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;