Skip to content

Commit

Permalink
Make fixdep error handling more explicit
Browse files Browse the repository at this point in the history
Also add missing error handling to fstat call

Signed-off-by: Ben Gamari <[email protected]>
Signed-off-by: Michal Marek <[email protected]>
  • Loading branch information
bgamari authored and michal42 committed Dec 22, 2010
1 parent 6e5f685 commit a3ba811
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions scripts/basic/fixdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ static void do_config_file(const char *filename)

fd = open(filename, O_RDONLY);
if (fd < 0) {
fprintf(stderr, "fixdep: ");
fprintf(stderr, "fixdep: error opening config file: ");
perror(filename);
exit(2);
}
Expand Down Expand Up @@ -357,11 +357,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);
Expand Down

0 comments on commit a3ba811

Please sign in to comment.