Messages in this thread | | | Subject | Re: [PATCH v2 2/3] perf script python: Add more PMU fields | From | "Jin, Yao" <> | Date | Thu, 7 Jun 2018 09:00:25 +0800 |
| |
On 6/7/2018 2:36 AM, Arnaldo Carvalho de Melo wrote: > Em Fri, Jun 01, 2018 at 05:01:02PM +0800, Jin Yao escreveu: > > <SNIP> > >> +static int get_symoff(struct symbol *sym, struct addr_location *al, >> + bool print_off, char *bf, int size) >> +{ >> + unsigned long offset; >> + >> + if (!sym || !sym->name) >> + return scnprintf(bf, size, "%s", "[unknown]"); > > 52 54.22 ubuntu:17.04 : FAIL gcc (Ubuntu 6.3.0-12ubuntu2) 6.3.0 20170406 > > CC /tmp/build/perf/util/scripting-engines/trace-event-python.o > util/scripting-engines/trace-event-python.c:534:20: error: address of array 'sym->name' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion] > if (!sym || !sym->name) > ~~~~~~^~~~ > 1 error generated. > mv: cannot stat '/tmp/build/perf/util/scripting-engines/.trace-event-python.o.tmp': No such file or directory > /git/linux/tools/build/Makefile.build:96: recipe for target '/tmp/build/perf/util/scripting-engines/trace-event-python.o' failed > make[5]: *** [/tmp/build/perf/util/scripting-engines/trace-event-python.o] Error 1 > > Because: > > struct symbol { > struct rb_node rb_node; > u64 start; > u64 end; > u16 namelen; > <SNIP> > char name[0]; > }; > > It sym->name is not a pointer, in symbol's constructor we have: > > struct symbol *symbol__new(u64 start, u64 len, u8 binding, u8 type, const char *name) > { > size_t namelen = strlen(name) + 1; > struct symbol *sym = calloc(1, (symbol_conf.priv_size + > sizeof(*sym) + namelen)); > if (sym == NULL) > return NULL; > <SNIP> > sym->namelen = namelen - 1; > memcpy(sym->name, name, namelen); > > return sym; > } > > So it is at least 1 char long, the test above should be: > > if (!sym || !sym->name[0]) > return scnprintf(bf, size, "%s", "[unknown]"); > > I'm fixing this up here. > > - Arnaldo >
Oh, yes, my mistake, very sorry about that.
Thanks for helping me to fix this.
Thanks Jin Yao
| |