[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] ping: [PATCH v13] block/raw-posix.c: Make physical devi
From: |
Eric Blake |
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 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 |
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
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] ping: [PATCH v13] block/raw-posix.c: Make physical devices usable in QEMU under Mac OS X host, Programmingkid, 2016/02/02
- Re: [Qemu-devel] ping: [PATCH v13] block/raw-posix.c: Make physical devices usable in QEMU under Mac OS X host, Daniel P. Berrange, 2016/02/02
- Re: [Qemu-devel] ping: [PATCH v13] block/raw-posix.c: Make physical devices usable in QEMU under Mac OS X host, Programmingkid, 2016/02/02
- Re: [Qemu-devel] ping: [PATCH v13] block/raw-posix.c: Make physical devices usable in QEMU under Mac OS X host, Daniel P. Berrange, 2016/02/02
- Re: [Qemu-devel] ping: [PATCH v13] block/raw-posix.c: Make physical devices usable in QEMU under Mac OS X host, Programmingkid, 2016/02/02
- Re: [Qemu-devel] ping: [PATCH v13] block/raw-posix.c: Make physical devices usable in QEMU under Mac OS X host,
Eric Blake <=
- Re: [Qemu-devel] ping: [PATCH v13] block/raw-posix.c: Make physical devices usable in QEMU under Mac OS X host, Programmingkid, 2016/02/02
- Re: [Qemu-devel] ping: [PATCH v13] block/raw-posix.c: Make physical devices usable in QEMU under Mac OS X host, Programmingkid, 2016/02/02
- Re: [Qemu-devel] ping: [PATCH v13] block/raw-posix.c: Make physical devices usable in QEMU under Mac OS X host, Eric Blake, 2016/02/02
- Re: [Qemu-devel] ping: [PATCH v13] block/raw-posix.c: Make physical devices usable in QEMU under Mac OS X host, Programmingkid, 2016/02/02
- Re: [Qemu-devel] ping: [PATCH v13] block/raw-posix.c: Make physical devices usable in QEMU under Mac OS X host, Eric Blake, 2016/02/02
- Re: [Qemu-devel] ping: [PATCH v13] block/raw-posix.c: Make physical devices usable in QEMU under Mac OS X host, Programmingkid, 2016/02/02
- Re: [Qemu-devel] ping: [PATCH v13] block/raw-posix.c: Make physical devices usable in QEMU under Mac OS X host, Eric Blake, 2016/02/02
- Re: [Qemu-devel] ping: [PATCH v13] block/raw-posix.c: Make physical devices usable in QEMU under Mac OS X host, Programmingkid, 2016/02/03
- Re: [Qemu-devel] ping: [PATCH v13] block/raw-posix.c: Make physical devices usable in QEMU under Mac OS X host, Eric Blake, 2016/02/04
- Re: [Qemu-devel] ping: [PATCH v13] block/raw-posix.c: Make physical devices usable in QEMU under Mac OS X host, Eric Blake, 2016/02/02