[PATCH 4/4] comparison: silence a -Wformat-truncation warning
Arka Mondal <[email protected]>
| Newsgroups | org.kernel.vger.smatch |
|---|---|
| Message-ID | <[email protected]> |
The names can be up to 128 characters each so they don't always fit. Check for truncation instead of storing a truncated name. Signed-off-by: Arka Mondal <[email protected]> --- smatch_comparison.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/smatch_comparison.c b/smatch_comparison.c index c1af79f0..1a408fb8 100644 --- a/smatch_comparison.c +++ b/smatch_comparison.c @@ -2638,7 +2638,7 @@ void select_caller_info(const char *name, struct symbol *sym, char *value) struct symbol *right_sym; char comparison_name[128]; char right_buf[128]; - int op, right_param; + int op, right_param, cnt; if (!split_op_param_key(value, &op, &right_param, &right_key)) return; @@ -2669,7 +2669,9 @@ void select_caller_info(const char *name, struct symbol *sym, char *value) add_var_sym(&left_vsl, name, sym); add_var_sym(&right_vsl, right_name, right_sym); - snprintf(comparison_name, sizeof(comparison_name), "%s vs %s", name, right_name); + cnt = snprintf(comparison_name, sizeof(comparison_name), "%s vs %s", name, right_name); + if (cnt >= sizeof(comparison_name)) + return; set_state(comparison_id, comparison_name, NULL, alloc_compare_state(NULL, name, left_vsl, -- 2.55.0