main/say: Work around gcc 9 format-truncation false positive

Version: gcc (Ubuntu 9.3.0-10ubuntu2) 9.3.0
Warning:
  say.c:2371:24: error: ‘%d’ directive output may be truncated writing
    between 1 and 11 bytes into a region of size 10
    [-Werror=format-truncation=]
  2371 |     snprintf(buf, 10, "%d", num);
  say.c:2371:23: note: directive argument in the range [-2147483648, 9]

That's not possible though, as the if() starts out checking for (num < 0),
making this Warning a false positive.

(Also replaced some else<TAB>if with else<SP>if while in the vicinity.)

Change-Id: Ic7a70120188c9aa525a6d70289385bfce878438a
pull/22/head
Walter Doekes 5 years ago
parent c62193c5de
commit 1650d50e91

@ -2472,7 +2472,7 @@ static int ast_say_number_full_zh(struct ast_channel *chan, int num, const char
snprintf(fn, sizeof(fn), "digits/thousand"); snprintf(fn, sizeof(fn), "digits/thousand");
playt = 0; playt = 0;
} else if (num < 10) { } else if (num < 10) {
snprintf(buf, 10, "%d", num); snprintf(buf, 12, "%d", num);
if (last_length - strlen(buf) > 1 && last_length != 0) { if (last_length - strlen(buf) > 1 && last_length != 0) {
last_length = strlen(buf); last_length = strlen(buf);
playz++; playz++;

Loading…
Cancel
Save