From: Paul Brossier Date: Wed, 29 Dec 2021 16:22:00 +0000 (-0500) Subject: [tensor] add warning in get_shape_string snprintf X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=21173113f0e5619f106a562bdc20eadb4eb44473;p=aubio.git [tensor] add warning in get_shape_string snprintf Prevent gcc from emitting -Wformat-truncation warning --- diff --git a/src/ai/tensor.c b/src/ai/tensor.c index a15818e9..8be59285 100644 --- a/src/ai/tensor.c +++ b/src/ai/tensor.c @@ -181,8 +181,10 @@ const char_t *aubio_tensor_get_shape_string(aubio_tensor_t *t) { add_coma ? "," : "", add_space ? " " : ""); strncpy(shape_str_previous, shape_str, len); } - snprintf(shape_str, strnlen(shape_str, STRN_LENGTH - offset - 1) + offset, - "%s)", shape_str_previous); + if (snprintf(shape_str, + strnlen(shape_str, STRN_LENGTH - offset - 1) + offset, + "%s)", shape_str_previous) < 0) + AUBIO_WRN("aubio_tensor_get_shape_string snprintf failed"); return shape_str; }