Skip to contentSkip to conversation

Make fixdep error handling more explicit

PATCH In review Ben Gamari 2 participants 2 messages Dec 22, 2010 Kbuild

lore
Share & tools
lore

Ben Gamari

author
#0 lore raw

PATCH 1/1 Make fixdep error handling more explicit

Also add missing error handling to fstat call

---
 scripts/basic/fixdep.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
scripts/basic/fixdep.c +7 -3
index ea26b23..184fb89 100644
@@ -273,7 +273,7 @@ static void do_config_file(char *filename)
 
 	fd = open(filename, O_RDONLY);
 	if (fd < 0) {
-		fprintf(stderr, "fixdep: ");
+		fprintf(stderr, "fixdep: error opening config file: ");
 		perror(filename);
 		exit(2);
 	}
@@ -344,11 +344,15 @@ static void print_deps(void)
 
 	fd = open(depfile, O_RDONLY);
 	if (fd < 0) {
-		fprintf(stderr, "fixdep: ");
+		fprintf(stderr, "fixdep: error opening depfile: ");
 		perror(depfile);
 		exit(2);
 	}
-	fstat(fd, &st);
+	if (fstat(fd, &st) < 0) {
+                fprintf(stderr, "fixdep: error fstat'ing depfile: ");
+                perror(depfile);
+                exit(2);
+        }
 	if (st.st_size == 0) {
 		fprintf(stderr,"fixdep: %s is empty\n",depfile);
 		close(fd);
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 6 lines · Ben Gamari

Also add missing error handling to fstat call

---
 scripts/basic/fixdep.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

Applied to kbuild-2.6.git#kbuild, thanks.

Michal