From f0aadfd1993226f63a3086117f812a5bb3077b8d Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Sun, 7 Jul 2024 20:46:56 +0200 Subject: Return value checking --- FICS/obsproc.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'FICS') diff --git a/FICS/obsproc.c b/FICS/obsproc.c index 43d0ace..cd661b0 100644 --- a/FICS/obsproc.c +++ b/FICS/obsproc.c @@ -961,8 +961,12 @@ FindHistory(int p, int p1, int game) } do { - fscanf(fpHist, "%d %*c %*d %*c %*d %*s %*s %*d %*d %*d %*d " - "%*s %*s %ld", &index, &when); + int ret; + + ret = fscanf(fpHist, "%d %*c %*d %*c %*d %*s %*s %*d %*d %*d " + "%*d %*s %*s %ld", &index, &when); + if (ret != 2) + warn("%s: %s: corrupt", __func__, &fileName[0]); } while (!feof(fpHist) && index != game); if (feof(fpHist)) { @@ -996,8 +1000,12 @@ FindHistory2(int p, int p1, int game, char *End) } do { - fscanf(fpHist, "%d %*c %*d %*c %*d %*s %*s %*d %*d %*d %*d " - "%*s %s %ld", &index, End, &when); + int ret; + + ret = fscanf(fpHist, "%d %*c %*d %*c %*d %*s %*s %*d %*d %*d " + "%*d %*s %s %ld", &index, End, &when); + if (ret != 3) + warn("%s: %s: corrupt", __func__, &fileName[0]); } while (!feof(fpHist) && index != game); if (feof(fpHist)) { -- cgit v1.2.3