lkml.org 
[lkml]   [2018]   [Dec]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subjectperf: Use strcmp(str, "const") instead of strncmp(str, "const", sizeof("const"))
As strncmp(str, "const", sizeof("const") is exactly the same as
strcmp(str, "const") use that instead, otherwise it is confusing.

sizeof("const") includes the nul terminator ('\0') of the string
"const", and that means strncmp() will only return a match if str and
"const" are exactly the same, which is what strcmp() does.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 32ef7bdca1cf..eabf30f963a5 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -258,7 +258,7 @@ int parse_callchain_record(const char *arg, struct callchain_param *param)

do {
/* Framepointer style */
- if (!strncmp(name, "fp", sizeof("fp"))) {
+ if (!strcmp(name, "fp")) {
if (!strtok_r(NULL, ",", &saveptr)) {
param->record_mode = CALLCHAIN_FP;
ret = 0;
@@ -268,7 +268,7 @@ int parse_callchain_record(const char *arg, struct callchain_param *param)
break;

/* Dwarf style */
- } else if (!strncmp(name, "dwarf", sizeof("dwarf"))) {
+ } else if (!strcmp(name, "dwarf")) {
const unsigned long default_stack_dump_size = 8192;

ret = 0;
\
 
 \ /
  Last update: 2018-12-20 18:27    [W:0.048 / U:2.256 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site