Skip to contentSkip to conversation

tracing: Remove redundant assignment to event_var

PATCH Superseded Jiapeng Chong 2 participants 2 messages May 7, 2021 Tracing

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tracing: Remove redundant assignment to event_var

Variable event_var is set to 'ERR_PTR(-EINVAL)', but this value is never read as it is overwritten or not used later on, hence it is a redundant assignment and can be removed.

Clean up the following clang-analyzer warning:

kernel/trace/trace_events_hist.c:2437:21: warning: Value stored to 'event_var' during its initialization is never read [clang-analyzer-deadcode.DeadStores].

---
 kernel/trace/trace_events_hist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_hist.c +1 -1
index c1abd63..b37342c 100644
@@ -2434,7 +2434,7 @@ static struct trace_event_file *event_file(struct trace_array *tr,
 		      char *subsys_name, char *event_name, char *field_name)
 {
 	struct trace_array *tr = target_hist_data->event_file->tr;
-	struct hist_field *event_var = ERR_PTR(-EINVAL);
+	struct hist_field *event_var;
 	struct hist_trigger_data *hist_data;
 	unsigned int i, n, first = true;
 	struct field_var_hist *var_hist;
Signature · 1 line
1.8.3.1
maintainer
#1 lore raw
Quoted 21 lines · On Fri, 7 May 2021 18:23:50 +0800 Jiapeng Chong…

Variable event_var is set to 'ERR_PTR(-EINVAL)', but this value is never read as it is overwritten or not used later on, hence it is a redundant assignment and can be removed.

Clean up the following clang-analyzer warning:

kernel/trace/trace_events_hist.c:2437:21: warning: Value stored to 'event_var' during its initialization is never read [clang-analyzer-deadcode.DeadStores].

---
 kernel/trace/trace_events_hist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/trace_events_hist.c +0 -0
index c1abd63..b37342c 100644

kernel/trace/trace_events_hist.c static struct trace_event_file *event_file(struct trace_array *tr, · line 2440

Quoted 8 lines
kernel/trace/trace_events_hist.c +1 -1
@@ -2434,7 +2434,7 @@ static struct trace_event_file *event_file(struct trace_array *tr,
 		      char *subsys_name, char *event_name, char *field_name)
 {
 	struct trace_array *tr = target_hist_data->event_file->tr;
-	struct hist_field *event_var = ERR_PTR(-EINVAL);
+	struct hist_field *event_var;
 	struct hist_trigger_data *hist_data;
 	unsigned int i, n, first = true;
 	struct field_var_hist *var_hist;

Thanks, but if you are going to make this change, please move the declaration of event_var below (or above) key_field, as their names are both the same size in length and are of the same type. This keeps the "upside-down x-mas tree" look of the declarations.

-- Steve