Re: [PATCH 1/8] Add virFileMakeParentPath helper function

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

 



On 02/17/2014 09:38 AM, Daniel P. Berrange wrote:
> Add a helper function which takes a file path and ensures
> that all directory components leading up to the file exist.
> IOW, it strips the filename part of the path and passes
> the result to virFileMakePath.
> 
> Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
> ---
>  src/libvirt_private.syms |  1 +
>  src/util/virfile.c       | 27 +++++++++++++++++++++++++++
>  src/util/virfile.h       |  1 +
>  3 files changed, 29 insertions(+)


> +int
> +virFileMakeParentPath(const char *path)
> +{
> +    char *p;
> +    char *tmp;
> +    int ret;
> +
> +    VIR_DEBUG("path=%s", path);
> +
> +    if (VIR_STRDUP(tmp, path) < 0) {
> +        errno = ENOMEM;
> +        return -1;
> +    }
> +
> +    if ((p = strrchr(tmp, '/')) == NULL) {
> +        errno = EINVAL;
> +        return -1;

Memleak of tmp.

ACK with that fixed.

-- 
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]