Re: [PATCH spice-common v2 2/2] log: Force format in log macro to be a string

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

 



On Wed, Jun 21, 2017 at 01:30:09PM +0100, Frediano Ziglio wrote:
> Make sure format is a string and not a pointer.

Having a rationale in the commit log would be useful ("Why do we want to
forbid that?") (I think the goal is to catch spice_debug(NULL)).
This breaks (arguably corner cases) usecases such as

char *format_str = g_strdup_printf("%s %s %%d", "foo", "bar");
spice_warning(format_str, 4);

I don't think this matters, but in case it becomes an issue in the
future, knowing in the changelog why this change was made will be useful
;)

Christophe

> 
> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> ---
>  common/log.h | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/common/log.h b/common/log.h
> index ed701ca..c6d260c 100644
> --- a/common/log.h
> +++ b/common/log.h
> @@ -62,23 +62,23 @@ void spice_log(GLogLevelFlags log_level,
>  } G_STMT_END
>  
>  #define spice_info(format, ...) G_STMT_START {                         \
> -    spice_log(G_LOG_LEVEL_INFO, SPICE_STRLOC, __FUNCTION__, format, ## __VA_ARGS__); \
> +    spice_log(G_LOG_LEVEL_INFO, SPICE_STRLOC, __FUNCTION__, "" format, ## __VA_ARGS__); \
>  } G_STMT_END
>  
>  #define spice_debug(format, ...) G_STMT_START {                         \
> -    spice_log(G_LOG_LEVEL_DEBUG, SPICE_STRLOC, __FUNCTION__, format, ## __VA_ARGS__); \
> +    spice_log(G_LOG_LEVEL_DEBUG, SPICE_STRLOC, __FUNCTION__, "" format, ## __VA_ARGS__); \
>  } G_STMT_END
>  
>  #define spice_warning(format, ...) G_STMT_START {                       \
> -    spice_log(G_LOG_LEVEL_WARNING, SPICE_STRLOC, __FUNCTION__, format, ## __VA_ARGS__); \
> +    spice_log(G_LOG_LEVEL_WARNING, SPICE_STRLOC, __FUNCTION__, "" format, ## __VA_ARGS__); \
>  } G_STMT_END
>  
>  #define spice_critical(format, ...) G_STMT_START {                          \
> -    spice_log(G_LOG_LEVEL_CRITICAL, SPICE_STRLOC, __FUNCTION__, format, ## __VA_ARGS__); \
> +    spice_log(G_LOG_LEVEL_CRITICAL, SPICE_STRLOC, __FUNCTION__, "" format, ## __VA_ARGS__); \
>  } G_STMT_END
>  
>  #define spice_error(format, ...) G_STMT_START {                         \
> -    spice_log(G_LOG_LEVEL_ERROR, SPICE_STRLOC, __FUNCTION__, format, ## __VA_ARGS__); \
> +    spice_log(G_LOG_LEVEL_ERROR, SPICE_STRLOC, __FUNCTION__, "" format, ## __VA_ARGS__); \
>  } G_STMT_END
>  
>  #define spice_warn_if_fail(x) G_STMT_START {            \
> -- 
> 2.9.4
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/spice-devel

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]