Also add missing error handling to fstat call
Showing the changes to scripts/basic (1 of 1 file). Show all
Unified · Split
| @@ -286,7 +286,7 @@ static void do_config_file(const char *filename) · 285 unmodified lines | ||
| 286 | 286 | |
| 287 | 287 | fd = open(filename, O_RDONLY); |
| 288 | 288 | if (fd < 0) { |
| 289 | − fprintf(stderr, "fixdep: "); | |
| 289 | + fprintf(stderr, "fixdep: error opening config file: "); | |
| 290 | 290 | perror(filename); |
| 291 | 291 | exit(2); |
| 292 | 292 | } |
| @@ -357,11 +357,15 @@ static void print_deps(void) · 64 unmodified lines | ||
| 357 | 357 | |
| 358 | 358 | fd = open(depfile, O_RDONLY); |
| 359 | 359 | if (fd < 0) { |
| 360 | − fprintf(stderr, "fixdep: "); | |
| 360 | + fprintf(stderr, "fixdep: error opening depfile: "); | |
| 361 | 361 | perror(depfile); |
| 362 | 362 | exit(2); |
| 363 | 363 | } |
| 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 | + } | |
| 365 | 369 | if (st.st_size == 0) { |
| 366 | 370 | fprintf(stderr,"fixdep: %s is empty\n",depfile); |
| 367 | 371 | close(fd); |