Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/dmesg PR toolchain/54269



details:   https://anonhg.NetBSD.org/src/rev/e90c80a83664
branches:  trunk
changeset: 456977:e90c80a83664
user:      kre <kre%NetBSD.org@localhost>
date:      Tue Jun 04 11:37:39 2019 +0000

description:
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:

 sbin/dmesg/dmesg.c |  18 ++++++++----------
 1 files changed, 8 insertions(+), 10 deletions(-)

diffs (74 lines):

diff -r 0aebcf759859 -r e90c80a83664 sbin/dmesg/dmesg.c
--- a/sbin/dmesg/dmesg.c        Tue Jun 04 10:15:22 2019 +0000
+++ b/sbin/dmesg/dmesg.c        Tue Jun 04 11:37:39 2019 +0000
@@ -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 @@
 #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 @@
 #endif
 
                        switch (ch) {
+#ifndef SMALL
                        case '[':
-#ifndef SMALL
                                frac = false;
                                scale = 0;
-#endif
                                ADDC(ch);
                                continue;
+#endif
                        case '<':
                                log = 1;
                                continue;
                        case '>':
                                log = 0;
                                continue;
+#ifndef SMALL
                        case ']':
-#ifndef SMALL
                                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 @@
                                }
                                if (!quiet || deltas)
                                        printf("] ");
+                               continue;
 #endif
-                               continue;
                        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;



Home | Main Index | Thread Index | Old Index