From: openocd-gerrit <ope...@us...> - 2025-03-15 10:20:15
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via e12ceddd5ee4d946107e3764d05ce2810befb293 (commit) from a2d4b9b718552a4bbb88e0f210444b4f5047bc0c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit e12ceddd5ee4d946107e3764d05ce2810befb293 Author: Evgeniy Naydanov <evg...@sy...> Date: Fri Feb 14 19:20:58 2025 +0300 helper/log: mark `fmt` argument of `alloc_vprintf()` as format string Building on Ubuntu 22.04 with `-fsanitize=undefined` (GCC 12.3.0) results in an error: Checkpatch-ignore: COMMIT_LOG_LONG_LINE ``` In file included from /usr/include/stdio.h:894, from <openocd>/src/helper/system.h:23, from <openocd>/src/helper/replacements.h:18, from <openocd>/src/helper/log.c:20: In function âvsnprintfâ, inlined from âalloc_vprintfâ at <openocd>/src/helper/log.c:347:8: /usr/include/x86_64-linux-gnu/bits/stdio2.h:85:10: error: null format string [-Werror=format-truncation=] 85 | return __builtin___vsnprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 86 | __glibc_objsize (__s), __fmt, __ap); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors ``` The error mentiones the call site `src/helper/log.c:347`. There `vsnprintf()` is called passing `fmt` as format string. To mitigate this, mark the format string with the corresponding attribute in `alloc_vprintf()` Change-Id: I91011490715998ef5a931c19c3c9d74a1a304e5d Signed-off-by: Evgeniy Naydanov <evg...@sy...> Reviewed-on: https://review.openocd.org/c/openocd/+/8764 Reviewed-by: Antonio Borneo <bor...@gm...> Tested-by: jenkins diff --git a/src/helper/log.h b/src/helper/log.h index e2bb131ed..ac24f8e83 100644 --- a/src/helper/log.h +++ b/src/helper/log.h @@ -85,7 +85,8 @@ struct log_callback { int log_add_callback(log_callback_fn fn, void *priv); int log_remove_callback(log_callback_fn fn, void *priv); -char *alloc_vprintf(const char *fmt, va_list ap); +char *alloc_vprintf(const char *fmt, va_list ap) + __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 1, 0))); char *alloc_printf(const char *fmt, ...) __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 1, 2))); ----------------------------------------------------------------------- Summary of changes: src/helper/log.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) hooks/post-receive -- Main OpenOCD repository |