Re: [PATCH v8 4/6] perf tools: Add print support for namespace events

From: Arnaldo Carvalho de Melo
Date: Tue Mar 14 2017 - 10:31:03 EST


Em Wed, Mar 08, 2017 at 02:11:59AM +0530, Hari Bathini escreveu:
> +size_t perf_event__fprintf_namespaces(union perf_event *event, FILE *fp)
> +{
> + size_t ret = 0;
> + struct perf_ns_link_info *ns_link_info;
> + u32 nr_namespaces, idx;
> +
> + ns_link_info = event->namespaces.link_info;
> + nr_namespaces = event->namespaces.nr_namespaces;
> +
> + ret += fprintf(fp, " %d/%d - nr_namespaces: %u\n\t\t[",
> + event->namespaces.pid,
> + event->namespaces.tid,
> + nr_namespaces);
> +
> + for (idx = 0; idx < nr_namespaces; idx++) {
> + if (idx && (idx % 4 == 0))
> + ret += fprintf(fp, "\n\t\t ");
> +
> + ret += fprintf(fp, "%u/%s: %lu/0x%lx%s", idx,
> + perf_ns__name(idx), (u64)ns_link_info[idx].dev,
> + (u64)ns_link_info[idx].ino,
> + ((idx + 1) != nr_namespaces) ? ", " : "]\n");

Fails in some environments, such as debian:experimental-x-mipsel:

CC /tmp/build/perf/util/evlist.o
util/event.c: In function 'perf_event__fprintf_namespaces':
util/event.c:1129:33: error: format '%lu' expects argument of type 'long unsigned int', but argument 5 has type 'long long unsigned int' [-Werror=format=]
ret += fprintf(fp, "%u/%s: %lu/0x%lx%s", idx,
^
util/event.c:1129:39: error: format '%lx' expects argument of type 'long unsigned int', but argument 6 has type 'long long unsigned int' [-Werror=format=]
ret += fprintf(fp, "%u/%s: %lu/0x%lx%s", idx,
^
CC /tmp/build/perf/builtin-list.o

-------------------

Fixing this up to use PRIu64...

- Arnaldo