From 21173113f0e5619f106a562bdc20eadb4eb44473 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Wed, 29 Dec 2021 11:22:00 -0500 Subject: [PATCH] [tensor] add warning in get_shape_string snprintf Prevent gcc from emitting -Wformat-truncation warning --- src/ai/tensor.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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; } -- 2.11.0