Re: [spice-common v2 8/8] log: Let gcc know about the logging macros which abort

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

 



> 
> Without the added abort(), it cannot know g_log(G_LOG_LEVEL_CRITICAL)
> will never return.
> 
> Signed-off-by: Christophe Fergeau <cfergeau@xxxxxxxxxx>

I prefer the "for" way. But by the way, this is not telling the compiler
that spice_log (NOT g_log) is not returning but to call abort() after
spice_log.
I don't think the compiler will warn that with that flag the function
it not returning, is not clear why you need these changes.
Optimization? I don't think that calling an additional function
and jumping back to original flow would change much.

> ---
>  common/log.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/common/log.h b/common/log.h
> index 7c67e7a..1482358 100644
> --- a/common/log.h
> +++ b/common/log.h
> @@ -20,6 +20,7 @@
>  
>  #include <stdarg.h>
>  #include <stdio.h>
> +#include <stdlib.h>
>  #include <glib.h>
>  #include <spice/macros.h>
>  
> @@ -42,6 +43,7 @@ void spice_log(GLogLevelFlags log_level,
>  #define spice_return_if_fail(x) G_STMT_START {                          \
>      if G_LIKELY(x) { } else {                                           \
>          spice_log(G_LOG_LEVEL_CRITICAL, SPICE_STRLOC, G_STRFUNC, "condition
>          `%s' failed", #x); \
> +        abort();
> \
>          return;                                                         \
>      }                                                                   \
>  } G_STMT_END
> @@ -49,6 +51,7 @@ void spice_log(GLogLevelFlags log_level,
>  #define spice_return_val_if_fail(x, val) G_STMT_START {                 \
>      if G_LIKELY(x) { } else {                                           \
>          spice_log(G_LOG_LEVEL_CRITICAL, SPICE_STRLOC, __FUNCTION__,
>          "condition `%s' failed", #x); \
> +        abort();
> \
>          return (val);                                                   \
>      }                                                                   \
>  } G_STMT_END
> @@ -71,10 +74,12 @@ void spice_log(GLogLevelFlags log_level,
>  
>  #define spice_critical(format, ...) G_STMT_START {
>  \
>      spice_log(G_LOG_LEVEL_CRITICAL, SPICE_STRLOC, __FUNCTION__, "" format,
>      ## __VA_ARGS__); \
> +    abort();
> \
>  } G_STMT_END
>  
>  #define spice_error(format, ...) G_STMT_START {                         \
>      spice_log(G_LOG_LEVEL_ERROR, SPICE_STRLOC, __FUNCTION__, "" format, ##
>      __VA_ARGS__); \
> +    abort();
> \
>  } G_STMT_END
>  
>  #define spice_warn_if_fail(x) G_STMT_START {            \

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




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