Module Name: src
Committed By: mrg
Date: Mon Sep 7 00:46:38 UTC 2020
Modified Files:
src/usr.bin/stat: stat.c
Log Message:
avoid a GCC stringop truncate warning.
To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/usr.bin/stat/stat.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/stat/stat.c
diff -u src/usr.bin/stat/stat.c:1.45 src/usr.bin/stat/stat.c:1.46
--- src/usr.bin/stat/stat.c:1.45 Fri Oct 4 11:12:16 2019
+++ src/usr.bin/stat/stat.c Mon Sep 7 00:46:38 2020
@@ -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 @@ format1(const struct stat *st,
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;