qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Alex Williamson <alex.williamson@redhat.com>,
	Julia Suvorova via Qemu-devel <qemu-devel@nongnu.org>
Cc: Julia Suvorova <jusual@mail.ru>,
	Stefan Hajnoczi <stefanha@gmail.com>,
	Jim Mussared <jim@groklearning.com>,
	Cornelia Huck <cohuck@redhat.com>, Joel Stanley <joel@jms.id.au>,
	Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH] use g_path_get_basename instead of basename
Date: Fri, 2 Mar 2018 11:50:51 +0100	[thread overview]
Message-ID: <7864bf9f-5726-1cdc-06a5-35ab51679568@redhat.com> (raw)
In-Reply-To: <20180301092046.7cb959d8@w520.home>

On 01/03/2018 17:20, Alex Williamson wrote:
>> basename(3) and dirname(3) modify their argument and may return
>> pointers to statically allocated memory which may be overwritten by
>> subsequent calls.
>> g_path_get_basename and g_path_get_dirname have no such issues, and
>> therefore more preferable.
>
> I think it's quite a bit arguable whether it's preferable, afaict there
> are no bugs fixed here.  The basic functions are being used correctly
> and are more conservative of memory usage than the glib variants.  In
> several cases below the basic functions seem far more efficient and we
> don't need to worry about freeing unnecessarily allocated memory, the
> diffstat seems to attest to this.  Is the inefficiency and possibility
> of leaking unintentionally allocated memory a statistical improvement
> over the claimed perils of these absolutely standard and well known
> functions?
> 
> I know mine is a losing battle against glib, but the changelog might as
> well just say "Succumb to glib" because I fail to see that there's
> actually an improvement here.  If Paolo wants to take this,
> 
> Acked-by: Alex Williamson <alex.williamson@redhat.com>

Fair enough, I'll apply only the obvious cases like g_strdup(basename()).

Paolo

  reply	other threads:[~2018-03-02 10:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-01  7:08 [Qemu-devel] [PATCH] use g_path_get_basename instead of basename Julia Suvorova
2018-03-01  9:47 ` Marc-André Lureau
2018-03-01 10:59   ` Cornelia Huck
2018-03-01 11:21     ` Paolo Bonzini
2018-03-01 12:02       ` Julia Suvorova
2018-03-01 11:25     ` Julia Suvorova
2018-03-01 11:19 ` Paolo Bonzini
2018-03-01 16:20 ` Alex Williamson
2018-03-02 10:50   ` Paolo Bonzini [this message]
2018-03-02 15:20   ` Eric Blake

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=7864bf9f-5726-1cdc-06a5-35ab51679568@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=jim@groklearning.com \
    --cc=joel@jms.id.au \
    --cc=jusual@mail.ru \
    --cc=qemu-devel@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=stefanha@gmail.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;
as well as URLs for NNTP newsgroup(s).