From 41a92d80a86dc2f2639d2374b50a0326a9b086ad Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Sun, 7 Jul 2024 14:43:19 +0200 Subject: Check return values --- FICS/ratings.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'FICS') diff --git a/FICS/ratings.c b/FICS/ratings.c index 92484a1..11896aa 100644 --- a/FICS/ratings.c +++ b/FICS/ratings.c @@ -326,13 +326,19 @@ load_ratings(void) if ((fp = fopen(fname, "r")) == NULL) { warn("%s: can't read ratings data", __func__); return; + } else if (fscanf(fp, "%lf %lf %lf %d", &Rb_M, &Rb_S, &Rb_total, + &Rb_count) != 4 || + fscanf(fp, "%lf %lf %lf %d", &Rs_M, &Rs_S, &Rs_total, + &Rs_count) != 4 || + fscanf(fp, "%lf %lf %lf %d", &Rw_M, &Rw_S, &Rw_total, + &Rw_count) != 4 || + fscanf(fp, "%lf %lf %lf %d", &Rl_M, &Rl_S, &Rl_total, + &Rl_count) != 4) { + warn("%s: fscanf", __func__); + fclose(fp); + return; } - fscanf(fp, "%lf %lf %lf %d", &Rb_M, &Rb_S, &Rb_total, &Rb_count); - fscanf(fp, "%lf %lf %lf %d", &Rs_M, &Rs_S, &Rs_total, &Rs_count); - fscanf(fp, "%lf %lf %lf %d", &Rw_M, &Rw_S, &Rw_total, &Rw_count); - fscanf(fp, "%lf %lf %lf %d", &Rl_M, &Rl_S, &Rl_total, &Rl_count); - for (int i = 0; i < MAXHIST; i++) { fscanf(fp, "%d %d %d %d", &sHist[i], &bHist[i], &wHist[i], &lHist[i]); -- cgit v1.2.3