Skip to content

Commit a3ba811

Browse files
bgamarimichal42
authored andcommitted
Make fixdep error handling more explicit
Also add missing error handling to fstat call Signed-off-by: Ben Gamari <bgamari.foss@gmail.com> Signed-off-by: Michal Marek <mmarek@suse.cz>
1 parent 6e5f685 commit a3ba811

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

scripts/basic/fixdep.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ static void do_config_file(const char *filename)
286286

287287
fd = open(filename, O_RDONLY);
288288
if (fd < 0) {
289-
fprintf(stderr, "fixdep: ");
289+
fprintf(stderr, "fixdep: error opening config file: ");
290290
perror(filename);
291291
exit(2);
292292
}
@@ -357,11 +357,15 @@ static void print_deps(void)
357357

358358
fd = open(depfile, O_RDONLY);
359359
if (fd < 0) {
360-
fprintf(stderr, "fixdep: ");
360+
fprintf(stderr, "fixdep: error opening depfile: ");
361361
perror(depfile);
362362
exit(2);
363363
}
364-
fstat(fd, &st);
364+
if (fstat(fd, &st) < 0) {
365+
fprintf(stderr, "fixdep: error fstat'ing depfile: ");
366+
perror(depfile);
367+
exit(2);
368+
}
365369
if (st.st_size == 0) {
366370
fprintf(stderr,"fixdep: %s is empty\n",depfile);
367371
close(fd);

0 commit comments

Comments
 (0)