Coverity has recently added a check that will find when we don't check the return code from fstat(2). Copy/paste the checking logic that print_deps() has with an appropriate re-wording of the perror() message.
Showing the changes to scripts/basic (1 of 1 file). Show all
Unified · Split
| @@ -274,7 +274,11 @@ static void do_config_file(const char *filename) · 273 unmodified lines | ||
| 274 | 274 | perror(filename); |
| 275 | 275 | exit(2); |
| 276 | 276 | } |
| 277 | − fstat(fd, &st); | |
| 277 | + if (fstat(fd, &st) < 0) { | |
| 278 | + fprintf(stderr, "fixdep: error fstat'ing config file: "); | |
| 279 | + perror(filename); | |
| 280 | + exit(2); | |
| 281 | + } | |
| 278 | 282 | if (st.st_size == 0) { |
| 279 | 283 | close(fd); |
| 280 | 284 | return; |