On Tue, 2 Dec 2025 11:32:26 +0300
Dan Carpenter <[email protected]> wrote:
I just noticed this email.
> Hello pengdonglin,
>
> Commit f83ac7544fbf ("function_graph: Enable funcgraph-args and
> funcgraph-retaddr to work simultaneously") from Nov 25, 2025
> (linux-next), leads to the following Smatch static checker warning:
>
> kernel/trace/trace_functions_graph.c:1033 print_graph_entry_nested() warn:
> unsigned 'call->depth' is never less than zero.
> kernel/trace/trace_functions_graph.c:975 print_graph_entry_leaf() warn:
> unsigned 'call->depth' is never less than zero.
> kernel/trace/trace.h:1130 ftrace_graph_ignore_func() warn: unsigned
> 'trace->depth' is never less than zero.
>
> kernel/trace/trace_functions_graph.c
> 1012 static enum print_line_t
> 1013 print_graph_entry_nested(struct trace_iterator *iter,
> 1014 struct ftrace_graph_ent_entry *entry,
> 1015 struct trace_seq *s, int cpu, u32 flags)
> 1016 {
> 1017 struct ftrace_graph_ent *call = &entry->graph_ent;
> 1018 struct fgraph_data *data = iter->private;
> 1019 struct trace_array *tr = iter->tr;
> 1020 unsigned long func;
> 1021 int args_size;
> 1022 int i;
> 1023
> 1024 if (data) {
> 1025 struct fgraph_cpu_data *cpu_data;
> 1026 int cpu = iter->cpu;
> 1027
> 1028 cpu_data = per_cpu_ptr(data->cpu_data, cpu);
> 1029 cpu_data->depth = call->depth;
> 1030
> 1031 /* Save this function pointer to see if the exit
> matches */
> 1032 if (call->depth < FTRACE_RETFUNC_DEPTH &&
> --> 1033 !WARN_ON_ONCE(call->depth < 0))
> ^^^^^^^^^^^^^^^
> The patch changed call->depth from int to unsigned long.
Yep, I'm fixing this with:
!WARN_ON_ONCE((long)call->depth < 0))
Thanks!
-- Steve
>
> 1034 cpu_data->enter_funcs[call->depth] =
> call->func;
> 1035 }
> 1036
> 1037 /* No time */
> 1038 print_graph_duration(tr, 0, s, flags | FLAGS_FILL_FULL);
>
> regards,
> dan carpenter