linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH linux-next] perf stat: use sysfs_streq() instead of strncmp()
@ 2022-11-22 12:11 yang.yang29
  2022-11-22 18:31 ` Namhyung Kim
  0 siblings, 1 reply; 2+ messages in thread
From: yang.yang29 @ 2022-11-22 12:11 UTC (permalink / raw)
  To: mingo
  Cc: acme, mark.rutland, alexander.shishkin, jolsa, namhyung, irogers,
	james.clark, kan.liang, zhengjun.xing, cjense, linux-perf-users,
	linux-kernel, xu.panda, yang.yang29

From: Xu Panda <xu.panda@zte.com.cn>

Replace the open-code with sysfs_streq().

Signed-off-by: Xu Panda <xu.panda@zte.com.cn>
Signed-off-by: Yang Yang <yang.yang29@zte.com>
---
 tools/perf/util/stat-display.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
index f5501760ff2e..1fd9f7e9d2a1 100644
--- a/tools/perf/util/stat-display.c
+++ b/tools/perf/util/stat-display.c
@@ -463,7 +463,7 @@ static bool valid_only_metric(const char *unit)
 static const char *fixunit(char *buf, struct evsel *evsel,
 			   const char *unit)
 {
-	if (!strncmp(unit, "of all", 6)) {
+	if (sysfs_streq(unit, "of all")) {
 		snprintf(buf, 1024, "%s %s", evsel__name(evsel),
 			 unit);
 		return buf;
@@ -767,8 +767,7 @@ static void uniquify_event_name(struct evsel *counter)
 	int ret = 0;

 	if (counter->uniquified_name || counter->use_config_name ||
-	    !counter->pmu_name || !strncmp(counter->name, counter->pmu_name,
-					   strlen(counter->pmu_name)))
+	    !counter->pmu_name || sysfs_streq(counter->name, counter->pmu_name))
 		return;

 	config = strchr(counter->name, '/');
-- 
2.15.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH linux-next] perf stat: use sysfs_streq() instead of strncmp()
  2022-11-22 12:11 [PATCH linux-next] perf stat: use sysfs_streq() instead of strncmp() yang.yang29
@ 2022-11-22 18:31 ` Namhyung Kim
  0 siblings, 0 replies; 2+ messages in thread
From: Namhyung Kim @ 2022-11-22 18:31 UTC (permalink / raw)
  To: yang.yang29
  Cc: mingo, acme, mark.rutland, alexander.shishkin, jolsa, irogers,
	james.clark, kan.liang, zhengjun.xing, cjense, linux-perf-users,
	linux-kernel, xu.panda

Hello,

On Tue, Nov 22, 2022 at 4:11 AM <yang.yang29@zte.com.cn> wrote:
>
> From: Xu Panda <xu.panda@zte.com.cn>
>
> Replace the open-code with sysfs_streq().

I don't think it's equivalent to strncmp() and it seems not available
in the tools.

Thanks,
Namhyung

>
> Signed-off-by: Xu Panda <xu.panda@zte.com.cn>
> Signed-off-by: Yang Yang <yang.yang29@zte.com>
> ---
>  tools/perf/util/stat-display.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/tools/perf/util/stat-display.c b/tools/perf/util/stat-display.c
> index f5501760ff2e..1fd9f7e9d2a1 100644
> --- a/tools/perf/util/stat-display.c
> +++ b/tools/perf/util/stat-display.c
> @@ -463,7 +463,7 @@ static bool valid_only_metric(const char *unit)
>  static const char *fixunit(char *buf, struct evsel *evsel,
>                            const char *unit)
>  {
> -       if (!strncmp(unit, "of all", 6)) {
> +       if (sysfs_streq(unit, "of all")) {
>                 snprintf(buf, 1024, "%s %s", evsel__name(evsel),
>                          unit);
>                 return buf;
> @@ -767,8 +767,7 @@ static void uniquify_event_name(struct evsel *counter)
>         int ret = 0;
>
>         if (counter->uniquified_name || counter->use_config_name ||
> -           !counter->pmu_name || !strncmp(counter->name, counter->pmu_name,
> -                                          strlen(counter->pmu_name)))
> +           !counter->pmu_name || sysfs_streq(counter->name, counter->pmu_name))
>                 return;
>
>         config = strchr(counter->name, '/');
> --
> 2.15.2

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-11-22 18:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-22 12:11 [PATCH linux-next] perf stat: use sysfs_streq() instead of strncmp() yang.yang29
2022-11-22 18:31 ` Namhyung Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).