[Spice-devel] [spice-common v3 5/7] log: Remove unneeded #ifdef/#endif

Victor Toso lists at victortoso.com
Wed Dec 16 06:08:35 PST 2015


Hi,

On Wed, Dec 16, 2015 at 02:27:11PM +0100, Christophe Fergeau wrote:
> If header guards are working as expected, there should not be multiple
> definitions of these macros. If they are redefined somewhere else, this
> is a bug we want to fix.
> 
> Acked-by: Jonathon Jongsma <jjongsma at redhat.com>
Acked-by: Victor Toso <victortoso at redhat.com>
> ---
>  common/log.h | 26 --------------------------
>  1 file changed, 26 deletions(-)
> 
> diff --git a/common/log.h b/common/log.h
> index af8f86c..a56105a 100644
> --- a/common/log.h
> +++ b/common/log.h
> @@ -47,96 +47,70 @@ void spice_log(const char *log_domain,
>                 const char *format,
>                 ...) SPICE_ATTR_PRINTF(5, 6);
>  
> -#ifndef spice_return_if_fail
>  #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;                                                         \
>      }                                                                   \
>  } G_STMT_END
> -#endif
>  
> -#ifndef spice_return_val_if_fail
>  #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);                                                   \
>      }                                                                   \
>  } G_STMT_END
> -#endif
>  
> -#ifndef spice_warn_if_reached
>  #define spice_warn_if_reached() G_STMT_START {                          \
>      spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_WARNING, SPICE_STRLOC, __FUNCTION__, "should not be reached"); \
>  } G_STMT_END
> -#endif
>  
> -#ifndef spice_printerr
>  #define spice_printerr(format, ...) G_STMT_START {                      \
>      fprintf(stderr, "%s: " format "\n", __FUNCTION__, ## __VA_ARGS__);  \
>  } G_STMT_END
> -#endif
>  
> -#ifndef spice_info
>  #define spice_info(format, ...) G_STMT_START {                         \
>      spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_INFO, SPICE_STRLOC, __FUNCTION__, format, ## __VA_ARGS__); \
>  } G_STMT_END
> -#endif
>  
> -#ifndef spice_debug
>  #define spice_debug(format, ...) G_STMT_START {                         \
>      spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_DEBUG, SPICE_STRLOC, __FUNCTION__, format, ## __VA_ARGS__); \
>  } G_STMT_END
> -#endif
>  
> -#ifndef spice_warning
>  #define spice_warning(format, ...) G_STMT_START {                       \
>      spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_WARNING, SPICE_STRLOC, __FUNCTION__, format, ## __VA_ARGS__); \
>  } G_STMT_END
> -#endif
>  
> -#ifndef spice_critical
>  #define spice_critical(format, ...) G_STMT_START {                          \
>      spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_CRITICAL, SPICE_STRLOC, __FUNCTION__, format, ## __VA_ARGS__); \
>  } G_STMT_END
> -#endif
>  
> -#ifndef spice_error
>  #define spice_error(format, ...) G_STMT_START {                         \
>      spice_log(SPICE_LOG_DOMAIN, SPICE_LOG_LEVEL_ERROR, SPICE_STRLOC, __FUNCTION__, format, ## __VA_ARGS__); \
>  } G_STMT_END
> -#endif
>  
> -#ifndef spice_warn_if_fail
>  #define spice_warn_if_fail(x) G_STMT_START {            \
>      if G_LIKELY(x) { } else {                           \
>          spice_warning("condition `%s' failed", #x);     \
>      }                                                   \
>  } G_STMT_END
> -#endif
>  
> -#ifndef spice_warn_if
>  #define spice_warn_if(x) G_STMT_START {                 \
>      if G_UNLIKELY(x) {                                  \
>          spice_warning("condition `%s' reached", #x);    \
>      }                                                   \
>  } G_STMT_END
> -#endif
>  
> -#ifndef spice_assert
>  #define spice_assert(x) G_STMT_START {                  \
>      if G_LIKELY(x) { } else {                           \
>          spice_error("assertion `%s' failed", #x);       \
>      }                                                   \
>  } G_STMT_END
> -#endif
>  
>  /* FIXME: improve that some day.. */
> -#ifndef spice_static_assert
>  #define spice_static_assert(x) SPICE_STMT_START {       \
>      spice_assert(x);                                    \
>  } SPICE_STMT_END
> -#endif
>  
>  SPICE_END_DECLS
>  
> -- 
> 2.5.0
> 
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/spice-devel


More information about the Spice-devel mailing list