From: Matt Kraai Date: Mon, 6 Aug 2001 16:09:09 +0000 (-0000) Subject: Use ferror(3) to check for errors, rather than inspecting errno. Thanks to X-Git-Tag: 0_60_1~30 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2338d3176bdb6fb607a8ce81534e88522d8c516c;p=oweals%2Fbusybox.git 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. --- 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 @@ * */ -#include #include #include #include @@ -82,10 +81,9 @@ int head_main(int argc, char **argv) printf("==> %s <==\n", argv[optind]); } head(len, fp); - if (errno) { + if (ferror(fp)) { perror_msg("%s", argv[optind]); status = EXIT_FAILURE; - errno = 0; } if (optind < argc - 1) putchar('\n'); diff --git a/head.c b/head.c index 0c8ef3d59..688c250b1 100644 --- a/head.c +++ b/head.c @@ -22,7 +22,6 @@ * */ -#include #include #include #include @@ -82,10 +81,9 @@ int head_main(int argc, char **argv) printf("==> %s <==\n", argv[optind]); } head(len, fp); - if (errno) { + if (ferror(fp)) { perror_msg("%s", argv[optind]); status = EXIT_FAILURE; - errno = 0; } if (optind < argc - 1) putchar('\n');