[prev in list] [next in list] [prev in thread] [next in thread]
List: linux-kbuild
Subject: [PATCH 07/10] scripts/basic/fixdep: Fix error log output in do_config_file()
From: SF Markus Elfring <elfring () users ! sourceforge ! net>
Date: 2016-10-28 8:37:50
Message-ID: 38828145-ab16-0eda-0f8c-6a9f27cd17bd () users ! sourceforge ! net
[Download RAW message or body]
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 27 Oct 2016 22:15:14 +0200
The function "perror" was called after a call of the function "fprintf"
in two if branches. So it could happen that an error message was displayed
for a failed print operation instead of the failure according to the call
of the function "fstat" or "open" here.
* Pass the relevant error data in the logging calls directly.
* Express that the corresponding return values are intentionally unused
by casts to void.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
scripts/basic/fixdep.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index be0fdaa..2c4ec91 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -275,13 +275,15 @@ static void do_config_file(const char *filename)
fd = open(filename, O_RDONLY);
if (fd < 0) {
- fprintf(stderr, "fixdep: error opening config file: ");
- perror(filename);
+ (void) fprintf(stderr,
+ "fixdep: error opening config file: %s: %s\n",
+ filename, strerror(errno));
exit(2);
}
if (fstat(fd, &st) < 0) {
- fprintf(stderr, "fixdep: error fstat'ing config file: ");
- perror(filename);
+ (void) fprintf(stderr,
+ "fixdep: error fstat'ing config file: %s: %s\n",
+ filename, strerror(errno));
exit(2);
}
if (st.st_size == 0)
--
2.10.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic