All of lore.kernel.org
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-kbuild@vger.kernel.org, Michal Marek <mmarek@suse.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 04/10] scripts/basic/fixdep: Fix error log output in print_deps()
Date: Fri, 28 Oct 2016 10:34:28 +0200	[thread overview]
Message-ID: <afce4a5b-0bd1-c887-9fcf-046dac0d3927@users.sourceforge.net> (raw)
In-Reply-To: <72e07814-56e9-505a-d660-91ff20b6efea@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 27 Oct 2016 19:04:01 +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 0dcec29..9a2ff68 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -403,13 +403,15 @@ static void print_deps(void)
 
 	fd = open(depfile, O_RDONLY);
 	if (fd < 0) {
-		fprintf(stderr, "fixdep: error opening depfile: ");
-		perror(depfile);
+		(void) fprintf(stderr,
+			       "fixdep: error opening depfile: %s: %s\n",
+			       depfile, strerror(errno));
 		exit(2);
 	}
 	if (fstat(fd, &st) < 0) {
-		fprintf(stderr, "fixdep: error fstat'ing depfile: ");
-		perror(depfile);
+		(void) fprintf(stderr,
+			       "fixdep: error fstat'ing depfile: %s: %s\n",
+			       depfile, strerror(errno));
 		exit(2);
 	}
 	if (st.st_size == 0) {
-- 
2.10.1

WARNING: multiple messages have this Message-ID (diff)
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: linux-kbuild@vger.kernel.org, Michal Marek <mmarek@suse.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH 04/10] scripts/basic/fixdep: Fix error log output in print_deps()
Date: Fri, 28 Oct 2016 08:34:28 +0000	[thread overview]
Message-ID: <afce4a5b-0bd1-c887-9fcf-046dac0d3927@users.sourceforge.net> (raw)
In-Reply-To: <72e07814-56e9-505a-d660-91ff20b6efea@users.sourceforge.net>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 27 Oct 2016 19:04:01 +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 0dcec29..9a2ff68 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -403,13 +403,15 @@ static void print_deps(void)
 
 	fd = open(depfile, O_RDONLY);
 	if (fd < 0) {
-		fprintf(stderr, "fixdep: error opening depfile: ");
-		perror(depfile);
+		(void) fprintf(stderr,
+			       "fixdep: error opening depfile: %s: %s\n",
+			       depfile, strerror(errno));
 		exit(2);
 	}
 	if (fstat(fd, &st) < 0) {
-		fprintf(stderr, "fixdep: error fstat'ing depfile: ");
-		perror(depfile);
+		(void) fprintf(stderr,
+			       "fixdep: error fstat'ing depfile: %s: %s\n",
+			       depfile, strerror(errno));
 		exit(2);
 	}
 	if (st.st_size = 0) {
-- 
2.10.1


  parent reply	other threads:[~2016-10-28  8:34 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-28  8:30 [PATCH 00/10] scripts/basic: Fine-tuning for seven function implementations SF Markus Elfring
2016-10-28  8:30 ` SF Markus Elfring
2016-10-28  8:31 ` [PATCH 01/10] scripts/basic/bin2c: Complete error handling in main() SF Markus Elfring
2016-10-28  8:31   ` SF Markus Elfring
2016-10-28 22:32   ` Jim Davis
2016-10-28 22:32     ` Jim Davis
2016-11-02 15:41   ` Masahiro Yamada
2016-11-02 15:41     ` Masahiro Yamada
2016-11-02 17:48     ` SF Markus Elfring
2016-11-02 17:48       ` SF Markus Elfring
2016-11-02 18:26       ` Masahiro Yamada
2016-11-02 18:26         ` Masahiro Yamada
2016-11-02 18:46         ` SF Markus Elfring
2016-11-02 18:46           ` SF Markus Elfring
2016-11-03 15:42           ` Michal Marek
2016-11-03 15:42             ` Michal Marek
2016-11-03 19:48             ` SF Markus Elfring
2016-11-03 19:48               ` SF Markus Elfring
2016-11-04 12:19               ` Michal Marek
2016-11-04 12:19                 ` Michal Marek
2016-11-04 12:48                 ` SF Markus Elfring
2016-11-04 12:48                   ` SF Markus Elfring
2016-10-28  8:32 ` [PATCH 02/10] scripts/basic/fixdep: Complete error handling in print_deps() SF Markus Elfring
2016-10-28  8:32   ` SF Markus Elfring
2016-10-28  8:33 ` [PATCH 03/10] scripts/basic/fixdep: Use the symbol "MAP_FAILED" " SF Markus Elfring
2016-10-28  8:33   ` SF Markus Elfring
2016-10-28  8:34 ` SF Markus Elfring [this message]
2016-10-28  8:34   ` [PATCH 04/10] scripts/basic/fixdep: Fix error log output " SF Markus Elfring
2016-10-28  8:35 ` [PATCH 05/10] scripts/basic/fixdep: Complete error handling in parse_dep_file() SF Markus Elfring
2016-10-28  8:35   ` SF Markus Elfring
2016-10-28  8:36 ` [PATCH 06/10] scripts/basic/fixdep: Complete error handling in do_config_file() SF Markus Elfring
2016-10-28  8:36   ` SF Markus Elfring
2016-10-28  8:37 ` [PATCH 07/10] scripts/basic/fixdep: Fix error log output " SF Markus Elfring
2016-10-28  8:37   ` SF Markus Elfring
2016-10-28  8:39 ` [PATCH 08/10] scripts/basic/fixdep: Complete error handling in print_config() SF Markus Elfring
2016-10-28  8:39   ` SF Markus Elfring
2016-10-28  8:40 ` [PATCH 09/10] scripts/basic/fixdep: Complete error handling in print_cmdline() SF Markus Elfring
2016-10-28  8:40   ` SF Markus Elfring
2016-10-28 23:42   ` Jim Davis
2016-10-28 23:42     ` Jim Davis
2016-10-30 15:17     ` SF Markus Elfring
2016-10-30 15:17       ` SF Markus Elfring
2016-11-02 15:35     ` [PATCH 09/10] " Masahiro Yamada
2016-11-02 15:35       ` Masahiro Yamada
2016-11-02 17:38       ` SF Markus Elfring
2016-11-02 17:38         ` SF Markus Elfring
2016-11-02 18:30         ` Masahiro Yamada
2016-11-02 18:30           ` Masahiro Yamada
2016-11-03 15:57           ` Michal Marek
2016-11-03 15:57             ` Michal Marek
2016-10-28  8:41 ` [PATCH 10/10] scripts/basic/fixdep: Combine two fprintf() calls into one fputs() call in usage() SF Markus Elfring
2016-10-28  8:41   ` SF Markus Elfring
2017-11-10 18:32 ` [PATCH 00/10] scripts/basic: Fine-tuning for seven function implementations SF Markus Elfring
2017-11-10 18:32   ` SF Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=afce4a5b-0bd1-c887-9fcf-046dac0d3927@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mmarek@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.