public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Andi Kleen <andi@firstfloor.org>, Kan Liang <kan.liang@intel.com>
Subject: Re: [PATCH v2 2/3] perf script python: Add more PMU fields
Date: Wed, 6 Jun 2018 15:36:57 -0300	[thread overview]
Message-ID: <20180606183657.GI24381@kernel.org> (raw)
In-Reply-To: <1527843663-32288-3-git-send-email-yao.jin@linux.intel.com>

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

  reply	other threads:[~2018-06-06 18:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-01  9:01 [PATCH v2 0/3] perf script python: Add more PMU fields Jin Yao
2018-06-01  1:55 ` Andi Kleen
2018-06-06 12:45   ` Arnaldo Carvalho de Melo
2018-06-01  9:01 ` [PATCH v2 1/3] perf script python: Move dsoname code to a new function Jin Yao
2018-06-07  8:25   ` [tip:perf/urgent] " tip-bot for Jin Yao
2018-06-01  9:01 ` [PATCH v2 2/3] perf script python: Add more PMU fields Jin Yao
2018-06-06 18:36   ` Arnaldo Carvalho de Melo [this message]
2018-06-07  1:00     ` Jin, Yao
2018-06-07  8:25   ` [tip:perf/urgent] perf script python: Add more PMU fields to event handler dict tip-bot for Jin Yao
2018-06-01  9:01 ` [PATCH v2 3/3] perf script python: Add fields introduction to Documentation Jin Yao
2018-06-07  8:26   ` [tip:perf/urgent] perf script python: Add dict " tip-bot for Jin Yao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180606183657.GI24381@kernel.org \
    --to=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=andi@firstfloor.org \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=yao.jin@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox