diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2025-04-06 15:41:12 +0200 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2025-04-06 15:41:12 +0200 |
commit | 8e428ea30fd9f33f919c82c9b6f4b7380ebd2480 (patch) | |
tree | bc7dacf91306e8a2a1ff0a8e1bee08eeec5f6077 /FICS | |
parent | 15533753e048b661f1ce4dcf124d427a447204bd (diff) |
Fixed Clang Tidy warnings
Diffstat (limited to 'FICS')
-rw-r--r-- | FICS/ratings.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/FICS/ratings.c b/FICS/ratings.c index 70dc529..4bdcce8 100644 --- a/FICS/ratings.c +++ b/FICS/ratings.c @@ -1595,16 +1595,20 @@ PositionFilePtr(FILE *fp, int count, int *last, int *nTied, int showComp) return; rating = nGames = is_computer = 0; + errno = 0; rewind(fp); + if (errno) { + warn("%s: rewind", __func__); + return; + } for (int i = 1; i < count; i++) { do { _Static_assert(ARRAY_SIZE(login) > 19, "'login' too small"); - if (fgets(line, sizeof line, fp) == NULL || - feof(fp) || - ferror(fp)) + if (feof(fp) || ferror(fp) || + fgets(line, sizeof line, fp) == NULL) break; else if (sscanf(line, "%19s %d %d %d", login, &rating, &nGames, &is_computer) != 4) { @@ -1613,6 +1617,11 @@ PositionFilePtr(FILE *fp, int count, int *last, int *nTied, int showComp) } } while (!CountRankLine(showComp, login, nGames, is_computer)); + if (ferror(fp)) { + warnx("%s: the error indicator is set", __func__); + return; + } + if (rating != *last) { *nTied = 1; *last = rating; @@ -1631,7 +1640,7 @@ ShowRankEntry(int p, FILE *fp, int count, int comp, char *target, // XXX rating = 0; - findable = (count > 0 && !feof(fp)); + findable = (count > 0 && !feof(fp) && !ferror(fp)); nGames = 0; is_comp = 0; |