diff options
| author | Markus Uhlin <markus@nifty-networks.net> | 2026-03-15 14:43:11 +0100 |
|---|---|---|
| committer | Markus Uhlin <markus@nifty-networks.net> | 2026-03-15 14:43:11 +0100 |
| commit | ef31ad9f87c412f6f14737f2e02d25d5e9a1fba2 (patch) | |
| tree | b69ac898e54ae76700c85e7fa4ff3986e1e0a8ec | |
| parent | 7cb44b1ff4a1620cf961eae9e80ec9f1cfde7dee (diff) | |
Handle fclose() errors
| -rw-r--r-- | FICS/obsproc.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/FICS/obsproc.c b/FICS/obsproc.c index 89fc7c1..0e880a6 100644 --- a/FICS/obsproc.c +++ b/FICS/obsproc.c @@ -960,7 +960,9 @@ ExamineAdjourned(int p, int p1, int p2) } g = ExamineStored(fp, p, filename); - fclose(fp); + + if (fclose(fp) != 0) + warn("%s: error closing file pointer", __func__); if (g >= 0) { if (garray[g].white_name[0] == '\0') { @@ -997,7 +999,7 @@ FindHistory(int p, int p1, int p_game) "%*d %*s %*s %ld", &index, &when); if (ret != 2) { warnx("%s: %s: corrupt", __func__, fileName); - fclose(fpHist); + (void) fclose(fpHist); return NULL; } } while (!feof(fpHist) && @@ -1007,11 +1009,12 @@ FindHistory(int p, int p1, int p_game) if (feof(fpHist) || ferror(fpHist)) { pprintf(p, "There is no history game %d for %s.\n", p_game, parray[p1].name); - fclose(fpHist); + (void) fclose(fpHist); return NULL; } - fclose(fpHist); + if (fclose(fpHist) != 0) + warn("%s: error closing file pointer", __func__); if (when < 0 || when >= LONG_MAX) { pprintf(p, "Corrupt history data for %s (invalid timestamp).\n", @@ -1048,7 +1051,7 @@ FindHistory2(int p, int p1, int p_game, char *End, const size_t End_size) do { if (fscanf(fpHist, fmt, &index, End, &when) != 3) { warnx("%s: %s: corrupt", __func__, fileName); - fclose(fpHist); + (void) fclose(fpHist); return NULL; } } while (!feof(fpHist) && @@ -1058,11 +1061,12 @@ FindHistory2(int p, int p1, int p_game, char *End, const size_t End_size) if (feof(fpHist) || ferror(fpHist)) { pprintf(p, "There is no history game %d for %s.\n", p_game, parray[p1].name); - fclose(fpHist); + (void) fclose(fpHist); return NULL; } - fclose(fpHist); + if (fclose(fpHist) != 0) + warn("%s: error closing file pointer", __func__); if (when < 0 || when >= LONG_MAX) { pprintf(p, "Invalid history timestamp for %s.\n", @@ -1104,7 +1108,11 @@ ExamineHistory(int p, int p1, int p_game) p_game, parray[p1].name); } else { ExamineStored(fpGame, p, fileName); - fclose(fpGame); + + if (fclose(fpGame) != 0) { + warn("%s: error closing file pointer", + __func__); + } } } } |
