Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1571521

[PATCH 10/14] tools perf util: Make rm_rf(path) argument const

From Arnaldo Carvalho de Melo <acme@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 10/14] tools perf util: Make rm_rf(path) argument const
Date 2017-02-01 13:30 +0100
Message-ID <t62cW-5Vf-41@gated-at.bofh.it> (permalink)
References <t62cV-5Vf-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Joe Stringer <joe@ovn.org>

rm_rf() doesn't modify its path argument, and a future caller will pass
a string constant into it to delete.

Signed-off-by: Joe Stringer <joe@ovn.org>
Cc: Alexei Starovoitov <ast@fb.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: netdev@vger.kernel.org
Link: http://lkml.kernel.org/r/20170126212001.14103-5-joe@ovn.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/util.c | 2 +-
 tools/perf/util/util.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
index bf29aed16bd6..d8b45cea54d0 100644
--- a/tools/perf/util/util.c
+++ b/tools/perf/util/util.c
@@ -85,7 +85,7 @@ int mkdir_p(char *path, mode_t mode)
 	return (stat(path, &st) && mkdir(path, mode)) ? -1 : 0;
 }
 
-int rm_rf(char *path)
+int rm_rf(const char *path)
 {
 	DIR *dir;
 	int ret = 0;
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index 6e8be174ec0b..c74708da8571 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -209,7 +209,7 @@ static inline int sane_case(int x, int high)
 }
 
 int mkdir_p(char *path, mode_t mode);
-int rm_rf(char *path);
+int rm_rf(const char *path);
 struct strlist *lsdir(const char *name, bool (*filter)(const char *, struct dirent *));
 bool lsdir_no_dot_filter(const char *name, struct dirent *d);
 int copyfile(const char *from, const char *to);
-- 
2.9.3

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[GIT PULL 00/14] perf/core improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-02-01 13:30 +0100
  [PATCH 07/14] tools lib bpf: Add BPF program pinning APIs Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-02-01 13:30 +0100
  [PATCH 01/14] perf ftrace: Remove needless code setting default tracer Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-02-01 13:30 +0100
  [PATCH 10/14] tools perf util: Make rm_rf(path) argument const Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-02-01 13:30 +0100
  [PATCH 04/14] perf tools: Propagate perf_config() errors Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-02-01 13:30 +0100
  [PATCH 12/14] perf test: Add libbpf pinning test Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-02-01 13:30 +0100
  [PATCH 13/14] perf tools: Create for_each_event macro for tracepoints iteration Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-02-01 13:30 +0100
  [PATCH 02/14] tools build: Add tools tree support for 'make -s' Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-02-01 13:30 +0100
  [PATCH 09/14] tools lib bpf: Add bpf_object__pin() Arnaldo Carvalho de Melo <acme@kernel.org> - 2017-02-01 13:30 +0100
  Re: [GIT PULL 00/14] perf/core improvements and fixes Ingo Molnar <mingo@kernel.org> - 2017-02-01 15:40 +0100

csiph-web