aboutsummaryrefslogtreecommitdiffstats
path: root/FICS/board.c
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2023-12-17 14:19:18 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2023-12-17 14:19:18 +0100
commit34c1c87263f0d222021e4851afa0663fc0c9ba3a (patch)
treeba4be759c89f970299efd711b4dd3b79560b5f4c /FICS/board.c
parentb0d4e753eec21fdf444f9c340ab03413e6cf1c8d (diff)
Fixed compiler warning
Diffstat (limited to 'FICS/board.c')
-rw-r--r--FICS/board.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/FICS/board.c b/FICS/board.c
index e289c60..00f6d9d 100644
--- a/FICS/board.c
+++ b/FICS/board.c
@@ -549,6 +549,7 @@ style10(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);
@@ -597,7 +598,8 @@ style10(game_state_t *b, move_t *ml)
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,
garray[b->gameNum].white_name,
garray[b->gameNum].black_name,
@@ -623,6 +625,11 @@ style10(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);
sprintf(tmp, ">10<\n");
@@ -724,9 +731,7 @@ style12(game_state_t *b, move_t *ml)
!(b->bkmoved || b->bqrmoved),
(garray[b->gameNum].numHalfMoves -
- (b->lastIrreversable == -1
- ? 0
- : b->lastIrreversable)));
+ (b->lastIrreversable == -1 ? 0 : b->lastIrreversable)));
strcat(bstring, tmp);
ret = snprintf(tmp, sizeof tmp, "%d %s %s %d %d %d %d %d %d %d %d %s "