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
This commit is contained in:
+2
-2
@@ -246,7 +246,7 @@ cnt(const char *file)
|
|||||||
*/
|
*/
|
||||||
if (doline == 0 && dolongline == 0) {
|
if (doline == 0 && dolongline == 0) {
|
||||||
if (fstat(fd, &sb)) {
|
if (fstat(fd, &sb)) {
|
||||||
xo_warn("%s: fstat", file);
|
xo_warn("%s: fstat", file != NULL ? file : "stdin");
|
||||||
(void)close(fd);
|
(void)close(fd);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
@@ -267,7 +267,7 @@ cnt(const char *file)
|
|||||||
*/
|
*/
|
||||||
while ((len = read(fd, buf, MAXBSIZE))) {
|
while ((len = read(fd, buf, MAXBSIZE))) {
|
||||||
if (len == -1) {
|
if (len == -1) {
|
||||||
xo_warn("%s: read", file);
|
xo_warn("%s: read", file != NULL ? file : "stdin");
|
||||||
(void)close(fd);
|
(void)close(fd);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user