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

Re: [libvirt] [PATCH 1/7] util: consolidate duplicated error messages in virnetlink.c



On 03/08/2012 02:24 AM, Laine Stump wrote:
> There are special stub versions of all public functions in this file
> that are compiled when either libnl isn't available or the platform
> isn't linux. Each of these functions had two almost identical message,
> differing only in the function name included in the message. Since log
> messages already contain the function name, we can just define a const
> char* with the common part of the string, and use that same string for
> all the log messages.
> 
> Also, rather than doing #if defined ... #else ... #endif *inside the
> error log macro invocation*, this patch does #if defined ... just
> once, using it to decide which single string to define. This turns the
> error log in each function from 6 lines, to 1 line.
> ---
>  src/util/virnetlink.c |   47 ++++++++++++-----------------------------------
>  1 files changed, 12 insertions(+), 35 deletions(-)
> 
> diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c
> index 59f3e39..77dde9f 100644
> --- a/src/util/virnetlink.c
> +++ b/src/util/virnetlink.c
> @@ -525,17 +525,18 @@ cleanup:
>  
>  #else

This else matches up to an earlier:

#if defined(__linux__) && defined(HAVE_LIBNL)

>  
> +# if defined(__linux) && !defined(HAVE_LIBNL)

Which means the && !defined(HAVE_LIBNL) is redundant here; you could
simplify to:

# ifdef __linux

and get the same results.

> +static const char *unsupported = _("libnl was not available at build time");
> +# else
> +static const char *unsupported = _("not supported on non-linux platforms");
> +# endif

GCC correctly complains that the initializer is not a constant.  This
needs to be N_()...

> +    netlinkError(VIR_ERR_INTERNAL_ERROR, "%s", unsupported);

and all of these changed to _(unsupported).

ACK to the idea, once you fix the compilation errors that you get on
non-Linux or with HAVE_LIBNL forcefully undefined in config.h.

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

Attachment: signature.asc
Description: OpenPGP digital signature


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