lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:   Thu, 20 Dec 2018 12:36:21 -0500
From:   Steven Rostedt <rostedt@...dmis.org>
To:     LKML <linux-kernel@...r.kernel.org>
Cc:     Arnaldo Carvalho de Melo <acme@...nel.org>,
        Ingo Molnar <mingo@...nel.org>, Jiri Olsa <jolsa@...hat.com>,
        Namhyung Kim <namhyung@...nel.org>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>
Subject: [PATCH] perf: Use strcmp() for "ftrace:function" check

As strncmp(str, "const", sizeof("const") is exactly the same as
strcmp(str, "const") use that instead, otherwise it is confusing.

The test if the event name is "ftrace:function" in
perf_evsel__set_sample_id() is rather strange as it makes an
unnecessary macro of FUNCTION_EVENT to equal "ftrace:function" and uses
that twice so that it can do the sizeof(). But since sizeof("const")
includes the nul terminator ('\0') of the string "const" that compare
is the same as using strcmp().

With strcmp() there's no need to use the string twice, and that also
means the FUNCTION_EVENT macro is not needed.

Signed-off-by: Steven Rostedt (VMware) <rostedt@...dmis.org>
---
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index d37bb1566cd9..58a452d77951 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -215,12 +215,7 @@ void perf_evsel__set_sample_id(struct perf_evsel *evsel,
  */
 bool perf_evsel__is_function_event(struct perf_evsel *evsel)
 {
-#define FUNCTION_EVENT "ftrace:function"
-
-	return evsel->name &&
-	       !strncmp(FUNCTION_EVENT, evsel->name, sizeof(FUNCTION_EVENT));
-
-#undef FUNCTION_EVENT
+	return evsel->name && !strcmp("ftrace:function", evsel->name);
 }
 
 void perf_evsel__init(struct perf_evsel *evsel,

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ