]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
dmesg: refactoring - cleanup get bufsize code
authorKarel Zak <kzak@redhat.com>
Fri, 1 Jul 2011 11:49:25 +0000 (13:49 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 1 Jul 2011 11:49:25 +0000 (13:49 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/dmesg.c

index 7734cd0857f1b1b7e414d247d3d011cbf35c885f..3b72cfaf8541381544c5c4a19ffe79516d460144 100644 (file)
@@ -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;