All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Programmingkid <programmingkidx@gmail.com>,
	"Daniel P. Berrange" <berrange@redhat.com>
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-devel qemu-devel <qemu-devel@nongnu.org>,
	Qemu-block <qemu-block@nongnu.org>
Subject: Re: [Qemu-devel] ping: [PATCH v13] block/raw-posix.c: Make physical devices usable in QEMU under Mac OS X host
Date: Tue, 2 Feb 2016 12:24:50 -0700	[thread overview]
Message-ID: <56B10282.1030609@redhat.com> (raw)
In-Reply-To: <70C3852E-1807-419B-9205-F24B5409EABF@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1584 bytes --]

On 02/02/2016 12:10 PM, Programmingkid wrote:

>> There was/is no leak because it qdict_get_str() returns 'const char *' and
>> so nothing needs freeing. So your change is still a backwards steps IMHO.
> 
> char filename[MAXPATHLEN];
> snprintf(filename, MAXPATHLEN, "%s", qdict_get_str(options, "filename"));
> 
> So you want the above to be changed so that it goes back to this:
> 
> const char *filename = qdict_get_str(options, "filename");

Correct.

> 
> then this code would have to be changed:
> 
> snprintf(filename, MAXPATHLEN, "%s", bsd_path);
> qdict_put(options, "filename", qstring_from_str(filename));
> 
> I could change it to this:
> 
> qdict_put(options, "filename", qstring_from_str(bsd_path));

Correct.

> 
> If I did that, then this part would not be accurate anymore:
> 
> if (strncmp(filename, "/dev/", 5) == 0) {
>             print_unmounting_directions(filename);
>             return -1;
>         }
> 
> filename would be just "/dev/cdrom" for when the user uses the optical drive. This would print incorrect unmounting directions. 

So fix it to call print_unmounting_directions(bsd_path), after hoisting
the declaration of bsd_path to be earlier to have a long enough scope.

> 
> I could add another variable that keeps track of the real device name, but that would consume more memory. It is so much easier and simpler to just use the fixed array.

And why isn't bsd_path usable for that purpose?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2016-02-02 19:25 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-02 17:08 [Qemu-devel] ping: [PATCH v13] block/raw-posix.c: Make physical devices usable in QEMU under Mac OS X host Programmingkid
2016-02-02 17:16 ` Daniel P. Berrange
2016-02-02 17:28   ` Programmingkid
2016-02-02 17:31     ` Daniel P. Berrange
2016-02-02 19:10       ` Programmingkid
2016-02-02 19:24         ` Eric Blake [this message]
2016-02-02 19:46           ` Programmingkid
2016-02-02 21:23           ` Programmingkid
2016-02-02 22:04             ` Eric Blake
2016-02-03  1:15               ` Programmingkid
2016-02-03  2:30                 ` Eric Blake
2016-02-03  4:21                   ` Programmingkid
2016-02-03  4:36                     ` Eric Blake
2016-02-03 15:54                       ` Programmingkid
2016-02-04 20:58                         ` Eric Blake
2016-02-02 19:29     ` Eric Blake
2016-02-03 10:37       ` Kevin Wolf

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=56B10282.1030609@redhat.com \
    --to=eblake@redhat.com \
    --cc=berrange@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=programmingkidx@gmail.com \
    --cc=qemu-block@nongnu.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.