All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf map: Use strstarts() to look for Android libraries
@ 2020-03-09 20:01 Arnaldo Carvalho de Melo
  0 siblings, 0 replies; only message in thread
From: Arnaldo Carvalho de Melo @ 2020-03-09 20:01 UTC (permalink / raw)
  To: Dominik Czarnota
  Cc: Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, Song Liu, John Keeping, Stephane Eranian,
	linux-kernel

I took your ok to use strstarts() as an Acked-by, ok?

If nobody have any other consideration I'll keep this in my private
perf/core branch for later submission,

- Arnaldo

commit 565cb8e4fb09ddee6e4d1e8112218a212c2ef54d
Author: Arnaldo Carvalho de Melo <acme@redhat.com>
Date:   Mon Mar 9 16:53:41 2020 -0300

    perf map: Use strstarts() to look for Android libraries
    
    And add the '/' to avoid looking at things like "/system/libsomething",
    when all we want to know if it is like "/system/lib/something", i.e. if
    it is in that system library dir.
    
    Using strstarts() avoids off-by-one errors like recently fixed in this
    file.
    
    Since this adds the '/' I separated this patch, another patch will make
    this consistent by removing other strncmp(str, prefix, manually
    calculated prefix length) usage.
    
    Reported-by: Dominik Czarnota <dominik.b.czarnota@gmail.com>
    Acked-by: Dominik Czarnota <dominik.b.czarnota@gmail.com>
    Cc: Adrian Hunter <adrian.hunter@intel.com>
    Cc: Jiri Olsa <jolsa@kernel.org>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Link: Link: http://lore.kernel.org/lkml/CABEVAa0_q-uC0vrrqpkqRHy_9RLOSXOJxizMLm1n5faHRy2AeA@mail.gmail.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index b342f744b1fc..53d96611e6a6 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -44,8 +44,8 @@ static inline int is_no_dso_memory(const char *filename)
 
 static inline int is_android_lib(const char *filename)
 {
-	return !strncmp(filename, "/data/app-lib", 13) ||
-	       !strncmp(filename, "/system/lib", 11);
+	return strstarts(filename, "/data/app-lib/") ||
+	       strstarts(filename, "/system/lib/");
 }
 
 static inline bool replace_android_lib(const char *filename, char *newfilename)
@@ -65,7 +65,7 @@ static inline bool replace_android_lib(const char *filename, char *newfilename)
 
 	app_abi_length = strlen(app_abi);
 
-	if (!strncmp(filename, "/data/app-lib", 13)) {
+	if (strstarts(filename, "/data/app-lib/")) {
 		char *apk_path;
 
 		if (!app_abi_length)
@@ -89,7 +89,7 @@ static inline bool replace_android_lib(const char *filename, char *newfilename)
 		return true;
 	}
 
-	if (!strncmp(filename, "/system/lib/", 12)) {
+	if (strstarts(filename, "/system/lib/")) {
 		char *ndk, *app;
 		const char *arch;
 		size_t ndk_length;

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-03-09 20:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-09 20:01 [PATCH] perf map: Use strstarts() to look for Android libraries Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.