Skip to content

Commit 3344996

Browse files
committed
perf symbols: Constify some DSO methods parameters
Those methods are not supposed to change the data structures they manipulate, so make that clearer by using the const qualifier in the function signature and in some variables. Suggested-by: Ingo Molnar <mingo@kernel.org> Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mike Galbraith <efault@gmx.de> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Link: http://lkml.kernel.org/n/tip-j7oyakex7zy3r82h33rdw25x@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent ee021d4 commit 3344996

4 files changed

Lines changed: 9 additions & 10 deletions

File tree

‎tools/perf/util/build-id.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ int build_id__sprintf(const u8 *build_id, int len, char *bf)
8989
return raw - build_id;
9090
}
9191

92-
char *dso__build_id_filename(struct dso *dso, char *bf, size_t size)
92+
char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size)
9393
{
9494
char build_id_hex[BUILD_ID_SIZE * 2 + 1];
9595

‎tools/perf/util/build-id.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ extern struct perf_tool build_id__mark_dso_hit_ops;
1010
struct dso;
1111

1212
int build_id__sprintf(const u8 *build_id, int len, char *bf);
13-
char *dso__build_id_filename(struct dso *dso, char *bf, size_t size);
13+
char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size);
1414

1515
int build_id__mark_dso_hit(struct perf_tool *tool, union perf_event *event,
1616
struct perf_sample *sample, struct perf_evsel *evsel,

‎tools/perf/util/dso.c‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ char dso__symtab_origin(const struct dso *dso)
2828
return origin[dso->symtab_type];
2929
}
3030

31-
int dso__binary_type_file(struct dso *dso, enum dso_binary_type type,
31+
int dso__binary_type_file(const struct dso *dso, enum dso_binary_type type,
3232
char *root_dir, char *file, size_t size)
3333
{
3434
char build_id_hex[BUILD_ID_SIZE * 2 + 1];
@@ -200,11 +200,10 @@ dso_cache__free(struct rb_root *root)
200200
}
201201
}
202202

203-
static struct dso_cache*
204-
dso_cache__find(struct rb_root *root, u64 offset)
203+
static struct dso_cache *dso_cache__find(const struct rb_root *root, u64 offset)
205204
{
206-
struct rb_node **p = &root->rb_node;
207-
struct rb_node *parent = NULL;
205+
struct rb_node * const *p = &root->rb_node;
206+
const struct rb_node *parent = NULL;
208207
struct dso_cache *cache;
209208

210209
while (*p != NULL) {
@@ -566,7 +565,7 @@ void dsos__add(struct list_head *head, struct dso *dso)
566565
list_add_tail(&dso->node, head);
567566
}
568567

569-
struct dso *dsos__find(struct list_head *head, const char *name, bool cmp_short)
568+
struct dso *dsos__find(const struct list_head *head, const char *name, bool cmp_short)
570569
{
571570
struct dso *pos;
572571

‎tools/perf/util/dso.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ void dso__read_running_kernel_build_id(struct dso *dso,
128128
int dso__kernel_module_get_build_id(struct dso *dso, const char *root_dir);
129129

130130
char dso__symtab_origin(const struct dso *dso);
131-
int dso__binary_type_file(struct dso *dso, enum dso_binary_type type,
131+
int dso__binary_type_file(const struct dso *dso, enum dso_binary_type type,
132132
char *root_dir, char *file, size_t size);
133133

134134
int dso__data_fd(struct dso *dso, struct machine *machine);
@@ -143,7 +143,7 @@ struct dso *dso__kernel_findnew(struct machine *machine, const char *name,
143143
const char *short_name, int dso_type);
144144

145145
void dsos__add(struct list_head *head, struct dso *dso);
146-
struct dso *dsos__find(struct list_head *head, const char *name,
146+
struct dso *dsos__find(const struct list_head *head, const char *name,
147147
bool cmp_short);
148148
struct dso *__dsos__findnew(struct list_head *head, const char *name);
149149
bool __dsos__read_build_ids(struct list_head *head, bool with_hits);

0 commit comments

Comments
 (0)