[CRIU] [PATCH] proc_parse: parse_smaps -- Use @file_path instead of strstr helper
Cyrill Gorcunov
gorcunov at openvz.org
Fri Oct 10 04:36:16 PDT 2014
strstr is a really heavy one, lets use already defined
and filled @file_path variable instead.
Reported-by: Pavel Emelyanov <xemul at parallels.com>
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
proc_parse.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/proc_parse.c b/proc_parse.c
index 98fef4add2e2..09a368fdacf4 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -420,9 +420,10 @@ int parse_smaps(pid_t pid, struct vm_area_list *vma_area_list, bool use_map_file
if (vma_area->e->status != 0) {
continue;
- } else if (strstr(str, "[vsyscall]") || strstr(str, "[vectors]")) {
+ } else if (!strcmp(file_path, "[vsyscall]") ||
+ !strcmp(file_path, "[vectors]")) {
vma_area->e->status |= VMA_AREA_VSYSCALL;
- } else if (strstr(str, "[vdso]")) {
+ } else if (!strcmp(file_path, "[vdso]")) {
#ifdef CONFIG_VDSO
vma_area->e->status |= VMA_AREA_REGULAR;
if ((vma_area->e->prot & VDSO_PROT) == VDSO_PROT)
@@ -431,7 +432,7 @@ int parse_smaps(pid_t pid, struct vm_area_list *vma_area_list, bool use_map_file
pr_warn_once("Found vDSO area without support\n");
goto err;
#endif
- } else if (strstr(str, "[vvar]")) {
+ } else if (!strcmp(file_path, "[vvar]")) {
#ifdef CONFIG_VDSO
vma_area->e->status |= VMA_AREA_REGULAR;
if ((vma_area->e->prot & VVAR_PROT) == VVAR_PROT)
@@ -440,7 +441,7 @@ int parse_smaps(pid_t pid, struct vm_area_list *vma_area_list, bool use_map_file
pr_warn_once("Found VVAR area without support\n");
goto err;
#endif
- } else if (strstr(str, "[heap]")) {
+ } else if (!strcmp(file_path, "[heap]")) {
vma_area->e->status |= VMA_AREA_REGULAR | VMA_AREA_HEAP;
} else {
vma_area->e->status = VMA_AREA_REGULAR;
--
1.9.3
More information about the CRIU
mailing list