Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/sysinst Backout previous snprintf nonsense, instead...



details:   https://anonhg.NetBSD.org/src/rev/258d0e22e7b4
branches:  trunk
changeset: 839282:258d0e22e7b4
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Feb 12 18:32:15 2019 +0000

description:
Backout previous snprintf nonsense, instead STFU gcc 7's most
useless warning ever.

diffstat:

 usr.sbin/sysinst/Makefile.inc   |   6 +++++-
 usr.sbin/sysinst/bsddisklabel.c |   4 ++--
 usr.sbin/sysinst/defs.h         |   5 +----
 usr.sbin/sysinst/partman.c      |  16 ++++++++--------
 usr.sbin/sysinst/util.c         |  19 +------------------
 5 files changed, 17 insertions(+), 33 deletions(-)

diffs (158 lines):

diff -r ed18666e09fc -r 258d0e22e7b4 usr.sbin/sysinst/Makefile.inc
--- a/usr.sbin/sysinst/Makefile.inc     Tue Feb 12 16:13:23 2019 +0000
+++ b/usr.sbin/sysinst/Makefile.inc     Tue Feb 12 18:32:15 2019 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.inc,v 1.18 2019/02/11 19:15:38 martin Exp $
+#      $NetBSD: Makefile.inc,v 1.19 2019/02/12 18:32:15 martin Exp $
 #
 # Makefile for sysinst
 
@@ -104,6 +104,10 @@
 CPPFLAGS+=-DINET6
 .endif
 
+.if defined(HAVE_GCC) && ${HAVE_GCC} == 7 && ${ACTIVE_CC} == "gcc"
+COPTS+=-Wno-format-truncation  # most useless gcc warning ever
+.endif
+
 .if defined(HAVE_GCC) || defined(HAVE_PCC)
 COPTS.label.c+=        -Wno-pointer-sign
 .endif
diff -r ed18666e09fc -r 258d0e22e7b4 usr.sbin/sysinst/bsddisklabel.c
--- a/usr.sbin/sysinst/bsddisklabel.c   Tue Feb 12 16:13:23 2019 +0000
+++ b/usr.sbin/sysinst/bsddisklabel.c   Tue Feb 12 18:32:15 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bsddisklabel.c,v 1.7 2019/02/11 20:40:18 martin Exp $  */
+/*     $NetBSD: bsddisklabel.c,v 1.8 2019/02/12 18:32:15 martin Exp $  */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -224,7 +224,7 @@
        if (size == 0)
                size = p->dflt_size;
        size /= sizemult;
-       trunc_snprintf(dflt, sizeof dflt, "%" PRIi64 "%s",
+       snprintf(dflt, sizeof dflt, "%" PRIi64 "%s",
            size, p == pi->pool_part ? "+" : "");
 
        for (;;) {
diff -r ed18666e09fc -r 258d0e22e7b4 usr.sbin/sysinst/defs.h
--- a/usr.sbin/sysinst/defs.h   Tue Feb 12 16:13:23 2019 +0000
+++ b/usr.sbin/sysinst/defs.h   Tue Feb 12 18:32:15 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: defs.h,v 1.32 2019/02/11 20:40:18 martin Exp $ */
+/*     $NetBSD: defs.h,v 1.33 2019/02/12 18:32:15 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -561,9 +561,6 @@
 void   restore_etc(void);
 
 /* from util.c */
-/* like snprintf, but always terminates the output */
-void trunc_snprintf(char * restrict str, size_t size,
-    const char * restrict format, ...) __printflike(3, 4);
 char*  str_arg_subst(const char *, size_t, const char **);
 void   msg_display_subst(const char *, size_t, ...);
 int    ask_yesno(const char *);
diff -r ed18666e09fc -r 258d0e22e7b4 usr.sbin/sysinst/partman.c
--- a/usr.sbin/sysinst/partman.c        Tue Feb 12 16:13:23 2019 +0000
+++ b/usr.sbin/sysinst/partman.c        Tue Feb 12 18:32:15 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: partman.c,v 1.29 2019/02/11 20:40:18 martin Exp $ */
+/*     $NetBSD: partman.c,v 1.30 2019/02/12 18:32:15 martin Exp $ */
 
 /*
  * Copyright 2012 Eugene Lozovoy
@@ -260,14 +260,14 @@
        if (pm_cur->isspecial)
                snprintf(buf, len, "%s", pm_cur->diskdev);
        else if (num + 'a' < 'a' || num + 'a' > 'a' + MAXPARTITIONS) {
-               trunc_snprintf(buf, len, "%sd", pm_cur->diskdev);
+               snprintf(buf, len, "%sd", pm_cur->diskdev);
        } else if (pm_cur->gpt) {
                for (i = 0; i < MAX_WEDGES; i++)
                        if (wedges[i].pm == pm_cur &&
                                wedges[i].ptn == num)
                                snprintf(buf, len, "dk%d", i); // XXX: xxx
        } else {
-               trunc_snprintf(buf, len, "%s%c", pm_cur->diskdev, num + 'a');
+               snprintf(buf, len, "%s%c", pm_cur->diskdev, num + 'a');
        }
 
        return;
@@ -1903,7 +1903,7 @@
                for (i = 0; i < MAX_CGD; i++)
                        if (cgds[i].blocked && cgds[i].node == dev_num) {
                                pm_cur->refdev = &cgds[i];
-                               trunc_snprintf(pm_cur->diskdev_descr,
+                               snprintf(pm_cur->diskdev_descr,
                                    sizeof(pm_cur->diskdev_descr),
                                    "%s (%s, %s-%d)",
                                    pm_cur->diskdev_descr, cgds[i].pm_name,
@@ -1917,7 +1917,7 @@
                                pm_cur->refdev = &vnds[i];
                                pm_getdevstring(dev, SSTRSIZE, vnds[i].pm,
                                    vnds[i].pm_part);
-                               trunc_snprintf(pm_cur->diskdev_descr,
+                               snprintf(pm_cur->diskdev_descr,
                                    sizeof(pm_cur->diskdev_descr),
                                    "%s (%s, %s)",
                                    pm_cur->diskdev_descr, dev,
@@ -1937,7 +1937,7 @@
                                                else
                                                        num_devs++;
                                        }
-                               trunc_snprintf(pm_cur->diskdev_descr,
+                               snprintf(pm_cur->diskdev_descr,
                                        sizeof(pm_cur->diskdev_descr),
                                        "%s (lvl %d, %d disks, %d spare)", pm_cur->diskdev_descr,
                                        raids[i].raid_level, num_devs, num_devs_s);
@@ -2191,7 +2191,7 @@
        if (strlen(pm_cur->bsdlabel[part_num].mounted) > 0)
                return 0;
 
-       trunc_snprintf(buf, sizeof(buf), "/tmp/%s%c", pm_cur->diskdev,
+       snprintf(buf, sizeof(buf), "/tmp/%s%c", pm_cur->diskdev,
            part_num + 'a');
        if (! dir_exists_p(buf))
                run_program(RUN_DISPLAY | RUN_PROGRESS, "/bin/mkdir -p %s", buf);
@@ -2539,7 +2539,7 @@
                                pm_cur->bsdlabel[part_num].pi_size / (MEG / pm_cur->sectorsize));
                        break;
                case PM_SPEC_T:
-                       trunc_snprintf(buf, sizeof(buf), "%s: %s",
+                       snprintf(buf, sizeof(buf), "%s: %s",
                            pm_cur->diskdev_descr,
                            pm_cur->bsdlabel[0].pi_mount);
                        wprintw(m->mw, "%-33.32s %-22.21s %11luM", buf,
diff -r ed18666e09fc -r 258d0e22e7b4 usr.sbin/sysinst/util.c
--- a/usr.sbin/sysinst/util.c   Tue Feb 12 16:13:23 2019 +0000
+++ b/usr.sbin/sysinst/util.c   Tue Feb 12 18:32:15 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: util.c,v 1.20 2019/02/11 20:40:18 martin Exp $ */
+/*     $NetBSD: util.c,v 1.21 2019/02/12 18:32:15 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1882,20 +1882,3 @@
        free(args);
 }
 
-/*
- * like snprintf, but always terminates the output
- */
-void
-trunc_snprintf(char * restrict str, size_t size,
-     const char * restrict format, ...)
-{
-       int r;
-       va_list ap;
-
-       va_start(ap, format);
-       r = vsnprintf(str, size, format, ap);
-       va_end(ap);
-
-       if (r >= (int)size)
-               str[size-1] = 0;
-}



Home | Main Index | Thread Index | Old Index