lkml.org 
[lkml]   [2016]   [Oct]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 05/10] scripts/basic/fixdep: Complete error handling in parse_dep_file()
From
Date
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 27 Oct 2016 19:43:43 +0200

Return values were not checked from five calls of the function "printf".

This issue was detected also by using the Coccinelle software.


* Add a bit of exception handling there.

* Combine these calls into three.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
scripts/basic/fixdep.c | 32 ++++++++++++++++++++++++--------
1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index 9a2ff68..5f6a4f4 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -366,14 +366,25 @@ static void parse_dep_file(void *map, size_t len)
*/
if (!saw_any_target) {
saw_any_target = 1;
- printf("source_%s := %s\n\n",
- target, s);
- printf("deps_%s := \\\n",
- target);
+ if (printf("source_%s := %s\n\n"
+ "deps_%s := \\\n",
+ target, s, target)
+ < 24) {
+ int code = errno;
+
+ perror("fixdep: printf");
+ exit(code);
+ }
}
is_first_dep = 0;
- } else
- printf(" %s \\\n", s);
+ } else {
+ if (printf(" %s \\\n", s) < 5) {
+ int code = errno;
+
+ perror("fixdep: printf");
+ exit(code);
+ }
+ }
do_config_file(s);
}
}
@@ -391,8 +402,13 @@ static void parse_dep_file(void *map, size_t len)

do_extra_deps();

- printf("\n%s: $(deps_%s)\n\n", target, target);
- printf("$(deps_%s):\n", target);
+ if (printf("\n%s: $(deps_%s)\n\n"
+ "$(deps_%s):\n", target, target, target) < 27) {
+ int code = errno;
+
+ perror("fixdep: printf");
+ exit(code);
+ }
}

static void print_deps(void)
--
2.10.1
\
 
 \ /
  Last update: 2016-10-28 10:36    [W:0.125 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site