diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2023-12-17 13:57:59 +0100 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2023-12-17 13:57:59 +0100 |
commit | ec8d97e7d9b9c0a37f24050162c64dad202521c0 (patch) | |
tree | 50cf5c361bce8b3a5fafb1c65768e8998393d3b7 /FICS | |
parent | 4110da27224cc1774ef1c2f249cfd08cb79b9ae3 (diff) |
Fixed compiler warning
Diffstat (limited to 'FICS')
-rw-r--r-- | FICS/board.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/FICS/board.c b/FICS/board.c index c1980ce..33d5cd1 100644 --- a/FICS/board.c +++ b/FICS/board.c @@ -660,6 +660,7 @@ style12(game_state_t *b, move_t *ml) { char tmp[80]; int f, r; + int ret, too_long; int ws, bs; board_calc_strength(b, &ws, &bs); @@ -706,7 +707,8 @@ style12(game_state_t *b, move_t *ml) : b->lastIrreversable))); strcat(bstring, tmp); - sprintf(tmp, "%d %s %s %d %d %d %d %d %d %d %d %s (%s) %s %d\n", + ret = snprintf(tmp, sizeof tmp, "%d %s %s %d %d %d %d %d %d %d %d %s " + "(%s) %s %d\n", (b->gameNum + 1), garray[b->gameNum].white_name, garray[b->gameNum].black_name, @@ -732,6 +734,11 @@ style12(game_state_t *b, move_t *ml) : "none"), (orient == WHITE ? 0 : 1)); + too_long = (ret < 0 || (size_t)ret >= sizeof tmp); + if (too_long) { + fprintf(stderr, "FICS: %s: warning: snprintf truncated\n", + __func__); + } strcat(bstring, tmp); return 0; |