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:  sig...@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);
                }
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to