From: Thiemo Seufer <ths@networkno.de>
To: "Kirill A. Shutemov" <k.shutemov@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] [REPOST] Simplily linux-user/path.c
Date: Fri, 23 Feb 2007 16:58:56 +0000 [thread overview]
Message-ID: <20070223165856.GC2521@networkno.de> (raw)
In-Reply-To: <20070219130409.GD25556@localhost.localdomain>
Kirill A. Shutemov wrote:
> Fixed version of the patch in the attacment. Please, comment.
[snip]
> /* Look for path in emulation dir, otherwise return name. */
> const char *path(const char *name)
> {
> + char *newname = (char *) alloca(strlen(pref)+strlen(name)+1);
> + struct stat buf;
> /* Only do absolute paths: quick and dirty, but should mostly be OK.
> Could do relative by tracking cwd. */
> - if (!base || name[0] != '/')
> - return name;
> + if (!pref || name[0] != '/')
> + return name;
> +
> + strcpy(newname,pref);
> + strcat(newname,name);
>
> - return follow_path(base, name) ?: name;
> + return stat(newname,&buf) ? name : strdup(newname);
> }
This leaks memory allocated by strdup(). Also, the old code tries to
avoid syscalls by memorizing the paths. AFAICS we should do some
caching here.
Thiemo
next prev parent reply other threads:[~2007-02-23 16:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-19 13:04 [Qemu-devel] [PATCH] [REPOST] Simplily linux-user/path.c Kirill A. Shutemov
2007-02-23 16:58 ` Thiemo Seufer [this message]
2007-03-20 14:41 ` Kirill A. Shutemov
-- strict thread matches above, loose matches on Subject: below --
2007-02-19 14:02 Kirill A. Shutemov
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=20070223165856.GC2521@networkno.de \
--to=ths@networkno.de \
--cc=k.shutemov@gmail.com \
--cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).