From 8ff6070830f29650203fffed12e9cd2ca43f05d6 Mon Sep 17 00:00:00 2001 From: Markus Uhlin Date: Sat, 16 Dec 2023 15:14:30 +0100 Subject: Fixed compiler warning --- FICS/gamedb.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'FICS') diff --git a/FICS/gamedb.c b/FICS/gamedb.c index 3445eff..ffac465 100644 --- a/FICS/gamedb.c +++ b/FICS/gamedb.c @@ -938,13 +938,24 @@ ReadOneV1Move(FILE *fp, move_t *m) } } - if (m->algString[0] != 'O') - sprintf(m->moveString, "%c/%c%d-%c%d", + if (m->algString[0] != 'O') { + int ret, too_long; + + ret = snprintf(m->moveString, sizeof m->moveString, + "%c/%c%d-%c%d", PieceChar, ('a' + m->fromFile), (m->fromRank + 1), ('a' + m->toFile), (m->toRank + 1)); + + too_long = (ret < 0 || (size_t)ret >= sizeof m->moveString); + + if (too_long) { + fprintf(stderr, "FICS: %s: warning: " + "snprintf truncated\n", __func__); + } + } if (check) strcat(m->algString, "+"); } -- cgit v1.2.3