aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2023-12-16 15:14:30 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2023-12-16 15:14:30 +0100
commit8ff6070830f29650203fffed12e9cd2ca43f05d6 (patch)
treef06f33b5bd25cb6f9ae25cd0538a4518b83f3829
parentf5c4e6ea6df740481a85d670024a9455a388505e (diff)
Fixed compiler warning
-rw-r--r--FICS/gamedb.c15
1 files changed, 13 insertions, 2 deletions
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, "+");
}