aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Kraai <kraai@debian.org>2001-08-06 16:09:09 +0000
committerMatt Kraai <kraai@debian.org>2001-08-06 16:09:09 +0000
commit2338d3176bdb6fb607a8ce81534e88522d8c516c (patch)
treebc17e5768f410ffb2b67c9d6af57c98ccc59d9b5
parent063c1f54eae3e1dcb8dd5c00ba9bf802357d3cb9 (diff)
downloadbusybox-w32-2338d3176bdb6fb607a8ce81534e88522d8c516c.tar.gz
busybox-w32-2338d3176bdb6fb607a8ce81534e88522d8c516c.tar.bz2
busybox-w32-2338d3176bdb6fb607a8ce81534e88522d8c516c.zip
Use ferror(3) to check for errors, rather than inspecting errno. Thanks to
David Douthitt for reporting, and shame on me for writing such crappy code.
-rw-r--r--coreutils/head.c4
-rw-r--r--head.c4
2 files changed, 2 insertions, 6 deletions
diff --git a/coreutils/head.c b/coreutils/head.c
index 0c8ef3d59..688c250b1 100644
--- a/coreutils/head.c
+++ b/coreutils/head.c
@@ -22,7 +22,6 @@
22 * 22 *
23 */ 23 */
24 24
25#include <errno.h>
26#include <stdio.h> 25#include <stdio.h>
27#include <getopt.h> 26#include <getopt.h>
28#include <stdlib.h> 27#include <stdlib.h>
@@ -82,10 +81,9 @@ int head_main(int argc, char **argv)
82 printf("==> %s <==\n", argv[optind]); 81 printf("==> %s <==\n", argv[optind]);
83 } 82 }
84 head(len, fp); 83 head(len, fp);
85 if (errno) { 84 if (ferror(fp)) {
86 perror_msg("%s", argv[optind]); 85 perror_msg("%s", argv[optind]);
87 status = EXIT_FAILURE; 86 status = EXIT_FAILURE;
88 errno = 0;
89 } 87 }
90 if (optind < argc - 1) 88 if (optind < argc - 1)
91 putchar('\n'); 89 putchar('\n');
diff --git a/head.c b/head.c
index 0c8ef3d59..688c250b1 100644
--- a/head.c
+++ b/head.c
@@ -22,7 +22,6 @@
22 * 22 *
23 */ 23 */
24 24
25#include <errno.h>
26#include <stdio.h> 25#include <stdio.h>
27#include <getopt.h> 26#include <getopt.h>
28#include <stdlib.h> 27#include <stdlib.h>
@@ -82,10 +81,9 @@ int head_main(int argc, char **argv)
82 printf("==> %s <==\n", argv[optind]); 81 printf("==> %s <==\n", argv[optind]);
83 } 82 }
84 head(len, fp); 83 head(len, fp);
85 if (errno) { 84 if (ferror(fp)) {
86 perror_msg("%s", argv[optind]); 85 perror_msg("%s", argv[optind]);
87 status = EXIT_FAILURE; 86 status = EXIT_FAILURE;
88 errno = 0;
89 } 87 }
90 if (optind < argc - 1) 88 if (optind < argc - 1)
91 putchar('\n'); 89 putchar('\n');