Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/stat avoid a GCC stringop truncate warning.



details:   https://anonhg.NetBSD.org/src/rev/f7ad7fd06f4d
branches:  trunk
changeset: 943609:f7ad7fd06f4d
user:      mrg <mrg%NetBSD.org@localhost>
date:      Mon Sep 07 00:46:38 2020 +0000

description:
avoid a GCC stringop truncate warning.

diffstat:

 usr.bin/stat/stat.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (27 lines):

diff -r 1094ff445c3b -r f7ad7fd06f4d usr.bin/stat/stat.c
--- a/usr.bin/stat/stat.c       Mon Sep 07 00:38:14 2020 +0000
+++ b/usr.bin/stat/stat.c       Mon Sep 07 00:46:38 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: stat.c,v 1.45 2019/10/04 11:12:16 mrg Exp $ */
+/*     $NetBSD: stat.c,v 1.46 2020/09/07 00:46:38 mrg Exp $ */
 
 /*
  * Copyright (c) 2002-2011 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 #include <sys/cdefs.h>
 #if !defined(lint)
-__RCSID("$NetBSD: stat.c,v 1.45 2019/10/04 11:12:16 mrg Exp $");
+__RCSID("$NetBSD: stat.c,v 1.46 2020/09/07 00:46:38 mrg Exp $");
 #endif
 
 #if ! HAVE_NBTOOL_CONFIG_H
@@ -1072,6 +1072,8 @@
        if ((flags & FLAG_POUND) != 0 && ofmt == FMTF_STRING) {
                flags &= !FLAG_POUND;
                strncpy(visbuf, sdata, prefixlen);
+               /* Avoid GCC warnings. */
+               visbuf[prefixlen] = 0;
                strnvis(visbuf + prefixlen, sizeof(visbuf) - prefixlen,
                    sdata + prefixlen, VIS_WHITE | VIS_OCTAL | VIS_CSTYLE);
                sdata = visbuf;



Home | Main Index | Thread Index | Old Index