Re: [spice-common v3 4/7] log: Use more glib macros

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

 



Hi,

On Wed, Dec 16, 2015 at 02:27:10PM +0100, Christophe Fergeau wrote:
> No need to have our own SPICE_STMT_BEGIN/END and SPICE_STRINGIFY
>
> Acked-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
> ---
>  common/log.h | 67 ++++++++++++++++++++++++++++++------------------------------
>  1 file changed, 33 insertions(+), 34 deletions(-)
>
> diff --git a/common/log.h b/common/log.h
> index f336909..af8f86c 100644
> --- a/common/log.h
> +++ b/common/log.h
> @@ -18,6 +18,8 @@
>  #ifndef H_SPICE_LOG
>  #define H_SPICE_LOG
>
> +#include <glib.h>
> +

This patch could came before of previous one, which also includes
<glib.h>

Acked-by: Victor Toso <victortoso@xxxxxxxxxx>

>  #include <spice/macros.h>
>  #include <stdarg.h>
>  #include "macros.h"
> @@ -28,10 +30,7 @@ SPICE_BEGIN_DECLS
>  #define SPICE_LOG_DOMAIN "Spice"
>  #endif
>  
> -#define SPICE_STRINGIFY(x) SPICE_STRINGIFY_ARG (x)
> -#define SPICE_STRINGIFY_ARG(x) #x
> -
> -#define SPICE_STRLOC  __FILE__ ":" SPICE_STRINGIFY (__LINE__)
> +#define SPICE_STRLOC  __FILE__ ":" G_STRINGIFY (__LINE__)
>  
>  typedef enum {
>      SPICE_LOG_LEVEL_ERROR,
> @@ -49,87 +48,87 @@ void spice_log(const char *log_domain,
>                 ...) SPICE_ATTR_PRINTF(5, 6);
>  
>  #ifndef spice_return_if_fail
> -#define spice_return_if_fail(x) SPICE_STMT_START {                      \
> -    if SPICE_LIKELY(x) { } else {                                       \
> -        spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_CRITICAL, SPICE_STRLOC, __FUNCTION__, "condition `%s' failed", #x); \
> +#define spice_return_if_fail(x) G_STMT_START {                          \
> +    if G_LIKELY(x) { } else {                                           \
> +        spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_CRITICAL, SPICE_STRLOC, G_STRFUNC, "condition `%s' failed", #x); \
>          return;                                                         \
>      }                                                                   \
> -} SPICE_STMT_END
> +} G_STMT_END
>  #endif
>  
>  #ifndef spice_return_val_if_fail
> -#define spice_return_val_if_fail(x, val) SPICE_STMT_START {             \
> -    if SPICE_LIKELY(x) { } else {                                       \
> +#define spice_return_val_if_fail(x, val) G_STMT_START {                 \
> +    if G_LIKELY(x) { } else {                                           \
>          spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_CRITICAL, SPICE_STRLOC, __FUNCTION__, "condition `%s' failed", #x); \
>          return (val);                                                   \
>      }                                                                   \
> -} SPICE_STMT_END
> +} G_STMT_END
>  #endif
>  
>  #ifndef spice_warn_if_reached
> -#define spice_warn_if_reached() SPICE_STMT_START {                      \
> +#define spice_warn_if_reached() G_STMT_START {                          \
>      spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_WARNING, SPICE_STRLOC, __FUNCTION__, "should not be reached"); \
> -} SPICE_STMT_END
> +} G_STMT_END
>  #endif
>  
>  #ifndef spice_printerr
> -#define spice_printerr(format, ...) SPICE_STMT_START {                  \
> +#define spice_printerr(format, ...) G_STMT_START {                      \
>      fprintf(stderr, "%s: " format "\n", __FUNCTION__, ## __VA_ARGS__);  \
> -} SPICE_STMT_END
> +} G_STMT_END
>  #endif
>  
>  #ifndef spice_info
> -#define spice_info(format, ...) SPICE_STMT_START {                     \
> +#define spice_info(format, ...) G_STMT_START {                         \
>      spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_INFO, SPICE_STRLOC, __FUNCTION__, format, ## __VA_ARGS__); \
> -} SPICE_STMT_END
> +} G_STMT_END
>  #endif
>  
>  #ifndef spice_debug
> -#define spice_debug(format, ...) SPICE_STMT_START {                     \
> +#define spice_debug(format, ...) G_STMT_START {                         \
>      spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_DEBUG, SPICE_STRLOC, __FUNCTION__, format, ## __VA_ARGS__); \
> -} SPICE_STMT_END
> +} G_STMT_END
>  #endif
>  
>  #ifndef spice_warning
> -#define spice_warning(format, ...) SPICE_STMT_START {                   \
> +#define spice_warning(format, ...) G_STMT_START {                       \
>      spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_WARNING, SPICE_STRLOC, __FUNCTION__, format, ## __VA_ARGS__); \
> -} SPICE_STMT_END
> +} G_STMT_END
>  #endif
>  
>  #ifndef spice_critical
> -#define spice_critical(format, ...) SPICE_STMT_START {                      \
> +#define spice_critical(format, ...) G_STMT_START {                          \
>      spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_CRITICAL, SPICE_STRLOC, __FUNCTION__, format, ## __VA_ARGS__); \
> -} SPICE_STMT_END
> +} G_STMT_END
>  #endif
>  
>  #ifndef spice_error
> -#define spice_error(format, ...) SPICE_STMT_START {                     \
> +#define spice_error(format, ...) G_STMT_START {                         \
>      spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_ERROR, SPICE_STRLOC, __FUNCTION__, format, ## __VA_ARGS__); \
> -} SPICE_STMT_END
> +} G_STMT_END
>  #endif
>  
>  #ifndef spice_warn_if_fail
> -#define spice_warn_if_fail(x) SPICE_STMT_START {        \
> -    if SPICE_LIKELY(x) { } else {                       \
> +#define spice_warn_if_fail(x) G_STMT_START {            \
> +    if G_LIKELY(x) { } else {                           \
>          spice_warning("condition `%s' failed", #x);     \
>      }                                                   \
> -} SPICE_STMT_END
> +} G_STMT_END
>  #endif
>  
>  #ifndef spice_warn_if
> -#define spice_warn_if(x) SPICE_STMT_START {             \
> -    if SPICE_UNLIKELY(x) {                              \
> +#define spice_warn_if(x) G_STMT_START {                 \
> +    if G_UNLIKELY(x) {                                  \
>          spice_warning("condition `%s' reached", #x);    \
>      }                                                   \
> -} SPICE_STMT_END
> +} G_STMT_END
>  #endif
>  
>  #ifndef spice_assert
> -#define spice_assert(x) SPICE_STMT_START {              \
> -    if SPICE_LIKELY(x) { } else {                       \
> +#define spice_assert(x) G_STMT_START {                  \
> +    if G_LIKELY(x) { } else {                           \
>          spice_error("assertion `%s' failed", #x);       \
>      }                                                   \
> -} SPICE_STMT_END
> +} G_STMT_END
>  #endif
>  
>  /* FIXME: improve that some day.. */
> -- 
> 2.5.0
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel@xxxxxxxxxxxxxxxxxxxxx
> http://lists.freedesktop.org/mailman/listinfo/spice-devel
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://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]