Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 9 Feb 2020 19:20:21 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org
Subject:   svn commit: r357704 - stable/12/usr.bin/wc
Message-ID:  <202002091920.019JKL73066793@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Sun Feb  9 19:20:20 2020
New Revision: 357704
URL: https://svnweb.freebsd.org/changeset/base/357704

Log:
  MFC r357572: 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.

Modified:
  stable/12/usr.bin/wc/wc.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/usr.bin/wc/wc.c
==============================================================================
--- stable/12/usr.bin/wc/wc.c	Sun Feb  9 18:53:53 2020	(r357703)
+++ stable/12/usr.bin/wc/wc.c	Sun Feb  9 19:20:20 2020	(r357704)
@@ -218,7 +218,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);
 		}
@@ -239,7 +239,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?202002091920.019JKL73066793>