fgraph: fix unused value in register_ftrace_graph()
PATCH 1/1 fgraph: fix unused value in register_ftrace_graph()
Coverity reports unused assignment to value ret. [1]
ret is assigned to 0 here, but that stored value is overwritten before it can be used. The overwrite might happen either at line 1277, 1290 or eventually at line 1306. Therefore, cleanup the unused assignment.
[1] Coverity Scan, CID 1633338
--- kernel/trace/fgraph.c | 1 - 1 file changed, 1 deletion(-)
kernel/trace/fgraph.c +0 -1
@@ -1262,7 +1262,6 @@ int register_ftrace_graph(struct fgraph_ops *gops)return ret; } fgraph_initialized = true; - ret =0 ; }if (!fgraph_array[0 ]) {
Signature · 1 line
2.43.0
Steven Rostedt
maintainerQuoted 6 lines · On Mon, 21 Oct 2024 12:24:29 +0200 Gianfranco Trad <[email protected]> wrote:
Coverity reports unused assignment to value ret. [1]
ret is assigned to 0 here, but that stored value is overwritten before it can be used. The overwrite might happen either at line 1277, 1290 or eventually at line 1306. Therefore, cleanup the unused assignment.[1] Coverity Scan, CID 1633338
What does the above mean? For such a simple change, is it really unnecessary?
Quoted 11 lines
Signed-off-by Gianfranco Trad <[email protected]>--- kernel/trace/fgraph.c | 1 - 1 file changed, 1 deletion(-)kernel/trace/fgraph.c +0
-0
kernel/trace/fgraph.c int register_ftrace_graph(struct fgraph_ops *gops) · line 1265
Quoted 4 lines
kernel/trace/fgraph.c +0
-1@@ -1262,7 +1262,6 @@ int register_ftrace_graph(struct fgraph_ops *gops)return ret; } fgraph_initialized = true; - ret =0 ;
Not to mention that if this is to go, why not get rid of the declaration part too? That is:
- int ret = 0;
+ int ret;
But still, this code is about to be merged with other code where this change may cause issues. This is such a slow path that getting rid of the extra initialization may not be worth it.
-- Steve
Quoted 3 lines
kernel/trace/fgraph.c +0
-0}if (!fgraph_array[0 ]) {