qemu-devel
[Top][All Lists]
Advanced

[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

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]