svn commit: r357704 - stable/12/usr.bin/wc

Kyle Evans kevans at FreeBSD.org
Sun Feb 9 19:20:21 UTC 2020


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);
 		}


More information about the svn-src-all mailing list