Re: [PATCH 1/7] util: Fix regression of wwn reading

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/06/2013 06:45 AM, Osier Yang wrote:
> Introduced by commit 244ce462e29, which refactored the helper for wwn
> reading, however, it forgot to change the old "strndup" and "sizeof(buf)",
> "sizeof(buf)" operates on the fixed length array ("buf") in the old code,
> but now "buf" is a pointer.
> 

> +++ b/src/util/virutil.c
> @@ -3121,7 +3121,7 @@ virReadFCHost(const char *sysfs_prefix,
>      else
>          p = buf;
>  
> -    if (!(*result = strndup(p, sizeof(buf)))) {
> +    if (!(*result = strdup(p))) {
>          virReportOOMError();

Now that we have it, I'd write this as:

if (VIR_STRDUP(result, p) < 0)
    goto cleanup;

Of course, when backporting to v1.0.5-maint, you'll have to use the
long-hand (unless we backport VIR_STRDUP first).

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

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]