mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Nilay Vaish <nilayvaish@gmail.com>
Cc: Stephane Eranian <eranian@google.com>,
	Linux Kernel list <linux-kernel@vger.kernel.org>,
	jolsa@redhat.com, peterz@infradead.org, mingo@elte.hu,
	anton@ozlabs.org, namhyung@kernel.org
Subject: Re: [PATCH 1/9] perf/jit: improve error messages from JVMTI
Date: Fri, 14 Oct 2016 08:13:59 -0300	[thread overview]
Message-ID: <20161014111359.GB12815@kernel.org> (raw)
In-Reply-To: <CACbG30--zoPwzFqda3Dns2sRibdMkPha+agNip82aCLBGoGjjQ@mail.gmail.com>

Em Thu, Oct 13, 2016 at 03:05:40PM -0500, Nilay Vaish escreveu:
> On 13 October 2016 at 05:59, Stephane Eranian <eranian@google.com> wrote:
> > +++ b/tools/perf/jvmti/libjvmti.c
> > @@ -12,6 +12,17 @@
> > +static void print_error(jvmtiEnv *jvmti, const char *msg, jvmtiError ret)
> > +{
> > +       char *err_msg = NULL;
> > +       jvmtiError err;
> > +       err = (*jvmti)->GetErrorName(jvmti, ret, &err_msg);
> > +       if (err == JVMTI_ERROR_NONE) {
> > +               warnx("%s failed with %s", msg, err_msg);
> > +               (*jvmti)->Deallocate(jvmti, (unsigned char *)err_msg);
> > +       }
> > +}
> 
> Do we not need to release the memory for err_msg if the condition for
> the 'if' statement evaluates to false?  Is it that we are going to
> kill the process, so no need to release the memory?

I guess that print_error() is called only when an error was returned
somewhere, that ret parameter, then if there was no error
(JVMTI_ERROR_NONE) in translating that numeric code to an string,
err_msg, it can then be used with warnx() (the main purpose of
print_error()) and then deallocated.

For err != JVMTI_ERROR_NONE it silently goes back to the caller that
expected it to print something.

I.e. probably it should have an else clause, something like:

	if (err == JVMTI_ERROR_NONE) {
		warnx("%s failed with %s", msg, err_msg);
		(*jvmti)->Deallocate(jvmti, (unsigned char *)err_msg);
	} else {
		warnx("%s failed with an unknown error %d", msg, (int)ret);
	}

Stephane?

- Arnaldo

  reply	other threads:[~2016-10-14 11:15 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-13 10:59 [PATCH 0/9] perf/jit: various improvements Stephane Eranian
2016-10-13 10:59 ` [PATCH 1/9] perf/jit: improve error messages from JVMTI Stephane Eranian
2016-10-13 20:05   ` Nilay Vaish
2016-10-14 11:13     ` Arnaldo Carvalho de Melo [this message]
2016-10-14 12:57       ` Stephane Eranian
2016-10-14 15:20         ` Arnaldo Carvalho de Melo
2016-10-17 13:52           ` Stephane Eranian
2016-10-24 18:58   ` [tip:perf/core] perf jit: Improve " tip-bot for Stephane Eranian
2016-10-13 10:59 ` [PATCH 2/9] perf/jit: enable jitdump support without dwarf Stephane Eranian
2016-10-13 18:16   ` Arnaldo Carvalho de Melo
2016-10-13 18:37     ` Arnaldo Carvalho de Melo
2016-10-13 18:51       ` Arnaldo Carvalho de Melo
2016-10-13 19:03         ` Arnaldo Carvalho de Melo
2016-10-13 19:44           ` Arnaldo Carvalho de Melo
2016-10-24 18:58   ` [tip:perf/core] perf jit: Enable " tip-bot for Maciej Debski
2016-10-13 10:59 ` [PATCH 3/9] perf/jit: remove unecessary padding in jitdump file Stephane Eranian
2016-10-24 18:59   ` [tip:perf/core] perf jit: Remove " tip-bot for Stephane Eranian
2016-10-13 10:59 ` [PATCH 4/9] perf/jit: make perf skip unknown records Stephane Eranian
2016-10-24 18:59   ` [tip:perf/core] perf jit: Make " tip-bot for Stefano Sanfilippo
2016-10-13 10:59 ` [PATCH 5/9] perf/jit: do not assume pgoff is zero Stephane Eranian
2016-10-24 19:00   ` [tip:perf/core] perf jit: Do " tip-bot for Stefano Sanfilippo
2016-10-13 10:59 ` [PATCH 6/9] perf/jit: add unwinding support Stephane Eranian
2016-10-24 19:00   ` [tip:perf/core] perf jit: Add " tip-bot for Stefano Sanfilippo
2016-10-13 10:59 ` [PATCH 7/9] perf/jit: generate .eh_frame/.eh_frame_hdr in DSO Stephane Eranian
2016-10-24 19:01   ` [tip:perf/core] perf jit: Generate " tip-bot for Stefano Sanfilippo
2016-10-13 10:59 ` [PATCH 8/9] perf/jit: Check JITHEADER_VERSION Stephane Eranian
2016-10-24 19:01   ` [tip:perf/core] perf jit: " tip-bot for Stefano Sanfilippo
2016-10-13 10:59 ` [PATCH 9/9] perf/jit: add jitdump format specification document Stephane Eranian
2016-10-24 19:02   ` [tip:perf/core] perf jit: Add " tip-bot for Stephane Eranian

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=20161014111359.GB12815@kernel.org \
    --to=acme@kernel.org \
    --cc=anton@ozlabs.org \
    --cc=eranian@google.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=namhyung@kernel.org \
    --cc=nilayvaish@gmail.com \
    --cc=peterz@infradead.org \
    /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

Powered by JetHome