This is an automated email from Gerrit. "Antonio Borneo <borneo.anto...@gmail.com>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/9091
-- gerrit commit ea9462f8141b87ddea5215621d5d74d3a31f38fc Author: Antonio Borneo <borneo.anto...@gmail.com> Date: Wed Aug 20 14:43:35 2025 +0200 helper: command: assert on command_print() with no command_invocation Commit 7f260f5009a7 ("helper/command: Handle Tcl return values consistently") allows calling command_print with the first parameter set to NULL. This should not be allowed. I cannot identify any part of OpenOCD that calls a command that in turn calls command_print() with NULL command_invocation. Adding __attribute__((nonnull (1, 2))) to the prototype of the functions does not trigger any positive with GCC and scan-build. Add an assert to detect such corner cases. This change is kept small and self contained to allow reverting it easily if a real use case is identified. Change-Id: I8aa6e5c0c341e818c0327eaa0d2bd5b6304c93b8 Signed-off-by: Antonio Borneo <borneo.anto...@gmail.com> diff --git a/src/helper/command.c b/src/helper/command.c index 4aaeacdcba..d6c9b931b7 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -352,13 +352,7 @@ void command_output_text(struct command_context *context, const char *data) static int command_vprint(struct command_invocation *cmd, va_list ap, const char *format, bool add_lf) { - /* - * FIXME: Why this check on !cmd ? - * Commit 7f260f5009a7 that introduces it, does not explain why! - * Was author not confident on the code change? - */ - if (!cmd) - return ERROR_OK; + assert(cmd); char *string = alloc_vprintf(format, ap); if (!string) { --