summaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorkre <kre@NetBSD.org>2019-06-04 11:37:39 +0000
committerkre <kre@NetBSD.org>2019-06-04 11:37:39 +0000
commitc8b7ccf0a2236273f89c806fad5c94dc8517f014 (patch)
tree170f3f981439b7696eb457d56c4dc6d6cad710b9 /sbin
parent09ae050149df7306b06248df59157147c2022eb9 (diff)
PR toolchain/54269
Make a SMALL dmesg even smaller. When compiled -DSMALL, dmesg does nothing at all with the kernel timestamps (it processes no options to be told what would be the user's desire) so make it truly do (almost) nothing, rather than some botched partial processing of them. The "almost" is that a SMALL dmesg will now ignore spaces at the beginning of each new message line ... those are (vanishingly) unlikely to occur, as the kernel puts the timestamp (which starts with '[' there) - fixing this would have meant even more #ifdef's as the code that ignores that leading space is the only remaining thing that (in a SMALL) dmesg looks at the value of the "tstamp" variable, and if we don't keep some use of it, gcc complains... These changes affect only SMALL dmesg (as installed on boot floppies, etc) and have no intended effect on the version that's installed on a normal (full size) running system.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/dmesg/dmesg.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/sbin/dmesg/dmesg.c b/sbin/dmesg/dmesg.c
index bd0cb0e110c..c3331f026d9 100644
--- a/sbin/dmesg/dmesg.c
+++ b/sbin/dmesg/dmesg.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dmesg.c,v 1.41 2018/10/30 19:40:36 kre Exp $ */
+/* $NetBSD: dmesg.c,v 1.42 2019/06/04 11:37:39 kre Exp $ */
/*-
* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
@@ -38,7 +38,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 1993\
#if 0
static char sccsid[] = "@(#)dmesg.c 8.1 (Berkeley) 6/5/93";
#else
-__RCSID("$NetBSD: dmesg.c,v 1.41 2018/10/30 19:40:36 kre Exp $");
+__RCSID("$NetBSD: dmesg.c,v 1.42 2019/06/04 11:37:39 kre Exp $");
#endif
#endif /* not lint */
@@ -291,27 +291,25 @@ main(int argc, char *argv[])
#endif
switch (ch) {
- case '[':
#ifndef SMALL
+ case '[':
frac = false;
scale = 0;
-#endif
ADDC(ch);
continue;
+#endif
case '<':
log = 1;
continue;
case '>':
log = 0;
continue;
- case ']':
#ifndef SMALL
+ case ']':
frac = false;
-#endif
ADDC(ch);
ADDC('\0');
tstamp = 0;
-#ifndef SMALL
sec = fsec = 0;
switch (sscanf(tbuf, "[%jd.%ld]", &sec, &fsec)){
case EOF:
@@ -374,21 +372,21 @@ main(int argc, char *argv[])
}
if (!quiet || deltas)
printf("] ");
-#endif
continue;
+#endif
case ' ':
if (!tstamp)
continue;
/*FALLTHROUGH*/
default:
+#ifndef SMALL
if (tstamp) {
ADDC(ch);
-#ifndef SMALL
if (ch == '.')
frac = true;
-#endif
continue;
}
+#endif
if (log)
continue;
break;