diff options
author | Sami Kerola | 2016-07-04 23:14:41 +0200 |
---|---|---|
committer | Sami Kerola | 2016-07-21 22:14:33 +0200 |
commit | da0788fb9782f5c13c345f462c91c1f8640c90c3 (patch) | |
tree | aac9ad3241c8db9cd2472f3dd9db04fb1dd49a6f /misc-utils/logger.c | |
parent | libblkid: simplify if clause [oclint] (diff) | |
download | kernel-qcow2-util-linux-da0788fb9782f5c13c345f462c91c1f8640c90c3.tar.gz kernel-qcow2-util-linux-da0788fb9782f5c13c345f462c91c1f8640c90c3.tar.xz kernel-qcow2-util-linux-da0788fb9782f5c13c345f462c91c1f8640c90c3.zip |
logger: simplify if clause [oclint]
This has effect of collapsing rather long indentation block, so commit
separately.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'misc-utils/logger.c')
-rw-r--r-- | misc-utils/logger.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/misc-utils/logger.c b/misc-utils/logger.c index 70fac68bb..dbb9cdc24 100644 --- a/misc-utils/logger.c +++ b/misc-utils/logger.c @@ -924,32 +924,32 @@ static void logger_stdin(struct logger_ctl *ctl) c = getchar(); while (c != EOF) { i = 0; - if (ctl->prio_prefix) { - if (c == '<') { - pri = 0; + if (ctl->prio_prefix && c == '<') { + pri = 0; + buf[i++] = c; + while (isdigit(c = getchar()) && pri <= 191) { + buf[i++] = c; + pri = pri * 10 + c - '0'; + } + if (c != EOF && c != '\n') buf[i++] = c; - while (isdigit(c = getchar()) && pri <= 191) { - buf[i++] = c; - pri = pri * 10 + c - '0'; - } - if (c != EOF && c != '\n') - buf[i++] = c; - if (c == '>' && 0 <= pri && pri <= 191) { /* valid RFC PRI values */ - i = 0; - if (pri < 8) - pri |= 8; /* kern facility is forbidden */ - ctl->pri = pri; - } else - ctl->pri = default_priority; - - if (ctl->pri != last_pri) { - has_header = 0; - max_usrmsg_size = ctl->max_message_size - strlen(ctl->hdr); - last_pri = ctl->pri; - } - if (c != EOF && c != '\n') - c = getchar(); + if (c == '>' && 0 <= pri && pri <= 191) { + /* valid RFC PRI values */ + i = 0; + if (pri < 8) /* kern facility is forbidden */ + pri |= 8; + ctl->pri = pri; + } else + ctl->pri = default_priority; + + if (ctl->pri != last_pri) { + has_header = 0; + max_usrmsg_size = + ctl->max_message_size - strlen(ctl->hdr); + last_pri = ctl->pri; } + if (c != EOF && c != '\n') + c = getchar(); } while (c != EOF && c != '\n' && i < max_usrmsg_size) { |