2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-22 20:23:57 +08:00

perf script perl: Do error checking on new backtrace routine

This ended up triggering these warnings when building on Ubuntu 12.04.5:

  util/scripting-engines/trace-event-perl.c: In function 'perl_process_callchain':
  util/scripting-engines/trace-event-perl.c:293:4: error: value computed is not used [-Werror=unused-value]
  util/scripting-engines/trace-event-perl.c:294:4: error: value computed is not used [-Werror=unused-value]
  util/scripting-engines/trace-event-perl.c:295:4: error: value computed is not used [-Werror=unused-value]
  util/scripting-engines/trace-event-perl.c:297:4: error: value computed is not used [-Werror=unused-value]
  util/scripting-engines/trace-event-perl.c:309:4: error: value computed is not used [-Werror=unused-value]
  cc1: all warnings being treated as errors
  mv: cannot stat `/tmp/build/perf/util/scripting-engines/.trace-event-perl.o.tmp': No such file or directory
  make[4]: *** [/tmp/build/perf/util/scripting-engines/trace-event-perl.o] Error 1

Fix it by doing error checking when building the perl data structures
related to callchains.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Dima Kogan <dima@secretsauce.net>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@gmail.com>
Fixes: f7380c12ec ("perf script perl: Perl scripts now get a backtrace, like the python ones")
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo 2016-04-05 12:21:44 -03:00
parent bd0419e2a5
commit 76e20522b7

View File

@ -283,18 +283,27 @@ static SV *perl_process_callchain(struct perf_sample *sample,
if (!elem)
goto exit;
hv_stores(elem, "ip", newSVuv(node->ip));
if (!hv_stores(elem, "ip", newSVuv(node->ip))) {
hv_undef(elem);
goto exit;
}
if (node->sym) {
HV *sym = newHV();
if (!sym)
if (!sym) {
hv_undef(elem);
goto exit;
hv_stores(sym, "start", newSVuv(node->sym->start));
hv_stores(sym, "end", newSVuv(node->sym->end));
hv_stores(sym, "binding", newSVuv(node->sym->binding));
hv_stores(sym, "name", newSVpvn(node->sym->name,
node->sym->namelen));
hv_stores(elem, "sym", newRV_noinc((SV*)sym));
}
if (!hv_stores(sym, "start", newSVuv(node->sym->start)) ||
!hv_stores(sym, "end", newSVuv(node->sym->end)) ||
!hv_stores(sym, "binding", newSVuv(node->sym->binding)) ||
!hv_stores(sym, "name", newSVpvn(node->sym->name,
node->sym->namelen)) ||
!hv_stores(elem, "sym", newRV_noinc((SV*)sym))) {
hv_undef(sym);
hv_undef(elem);
goto exit;
}
}
if (node->map) {
@ -306,7 +315,10 @@ static SV *perl_process_callchain(struct perf_sample *sample,
else if (map->dso->name)
dsoname = map->dso->name;
}
hv_stores(elem, "dso", newSVpv(dsoname,0));
if (!hv_stores(elem, "dso", newSVpv(dsoname,0))) {
hv_undef(elem);
goto exit;
}
}
callchain_cursor_advance(&callchain_cursor);