瀏覽代碼

tracing/kprobe: Remove unneeded extra strchr() from create_trace_kprobe()

By utilizing a temporary variable, we can avoid adding another call to
strchr(). Instead, save the first call to a temp variable, and then use that
variable as the reference to set the event variable.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Steven Rostedt (VMware) 7 年之前
父節點
當前提交
d6b183eda4
共有 1 個文件被更改,包括 6 次插入3 次删除
  1. 6 3
      kernel/trace/trace_kprobe.c

+ 6 - 3
kernel/trace/trace_kprobe.c

@@ -749,10 +749,13 @@ static int create_trace_kprobe(int argc, char **argv)
 	}
 
 	if (event) {
-		if (strchr(event, '/')) {
+		char *slash;
+
+		slash = strchr(event, '/');
+		if (slash) {
 			group = event;
-			event = strchr(group, '/') + 1;
-			event[-1] = '\0';
+			event = slash + 1;
+			slash[0] = '\0';
 			if (strlen(group) == 0) {
 				pr_info("Group name is not specified\n");
 				return -EINVAL;