Re: [PATCH 07/14] driver: use normal error reporting APIs when loading modules

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

 



On 04/19/2018 07:09 PM, Daniel P. Berrangé wrote:
> The driver module loading code is one of the few places that still uses
> VIR_ERROR for reporting failures. Convert it to normal error reporting
> APIs.
> 
> Signed-off-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>
> ---
>  src/driver.c | 34 +++++++++++++++++++++++++++-------
>  1 file changed, 27 insertions(+), 7 deletions(-)
> 
> diff --git a/src/driver.c b/src/driver.c
> index e02efe2615..9b137c39e4 100644
> --- a/src/driver.c
> +++ b/src/driver.c
> @@ -33,6 +33,7 @@
>  
>  VIR_LOG_INIT("driver");
>  
> +#define VIR_FROM_THIS VIR_FROM_NONE
>  
>  /* XXX re-implement this for other OS, or use libtools helper lib ? */
>  #define DEFAULT_DRIVER_DIR LIBDIR "/libvirt/connection-driver"
> @@ -55,8 +56,11 @@ virDriverLoadModuleFile(const char *file)
>  
>      virUpdateSelfLastChanged(file);
>  
> -    if (!(handle = dlopen(file, flags)))
> -        VIR_ERROR(_("failed to load module %s %s"), file, dlerror());
> +    if (!(handle = dlopen(file, flags))) {
> +        virReportError(VIR_ERR_INTERNAL_ERROR,
> +                       _("Failed to load module '%s': %s"), file, dlerror());

Sweet. dlerror() returns 'char *' instead of 'const char *' even though
it's returning a pointer to statically allocated buffer.

> +        return NULL;
> +    }
>  
>      return handle;
>  }

ACK

Michal

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

  Powered by Linux