Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 Feb 2020 14:00:27 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r357572 - head/usr.bin/wc
Message-ID:  <202002051400.015E0Roo043746@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Wed Feb  5 14:00:27 2020
New Revision: 357572
URL: https://svnweb.freebsd.org/changeset/base/357572

Log:
  wc(1): account for possibility of file == NULL
  
  file could reasonably be NULL here if we we're using stdin. Albeit less
  likely in normal usage, one could actually hit either of these warnings on
  stdin.
  
  ubmitted by:	sigsys@gmail.com
  MFC after:	3 days

Modified:
  head/usr.bin/wc/wc.c

Modified: head/usr.bin/wc/wc.c
==============================================================================
--- head/usr.bin/wc/wc.c	Wed Feb  5 13:08:24 2020	(r357571)
+++ head/usr.bin/wc/wc.c	Wed Feb  5 14:00:27 2020	(r357572)
@@ -246,7 +246,7 @@ cnt(const char *file)
 	 */
 	if (doline == 0 && dolongline == 0) {
 		if (fstat(fd, &sb)) {
-			xo_warn("%s: fstat", file);
+			xo_warn("%s: fstat", file != NULL ? file : "stdin");
 			(void)close(fd);
 			return (1);
 		}
@@ -267,7 +267,7 @@ cnt(const char *file)
 	 */
 	while ((len = read(fd, buf, MAXBSIZE))) {
 		if (len == -1) {
-			xo_warn("%s: read", file);
+			xo_warn("%s: read", file != NULL ? file : "stdin");
 			(void)close(fd);
 			return (1);
 		}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202002051400.015E0Roo043746>