Re: [PATCH spice-common 2/3] log: Optimise glib_debug_level check

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

 



On Wed, 2017-05-31 at 08:53 +0100, Frediano Ziglio wrote:
> Use INT_MAX for invalid value to remove a test in code.
Does not need limits.h ? I'd go for G_MAXINT, the file already has the
 glib header.

Pavel

(yeah, I know it is defined as INT_MAX)

> 
> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> ---
>  common/log.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/common/log.c b/common/log.c
> index 014b416..dae955a 100644
> --- a/common/log.c
> +++ b/common/log.c
> @@ -30,7 +30,7 @@
>  #include "log.h"
>  #include "backtrace.h"
>  
> -static int glib_debug_level = 0;
> +static int glib_debug_level = INT_MAX;
>  static int abort_level = -1;
>  
>  #ifndef SPICE_ABORT_LEVEL_DEFAULT
> @@ -58,7 +58,7 @@ static GLogLevelFlags
> spice_log_level_to_glib(SpiceLogLevel level)
>  
>  static void spice_log_set_debug_level(void)
>  {
> -    if (glib_debug_level == 0) {
> +    if (glib_debug_level == INT_MAX) {
>          const char *debug_str = g_getenv("SPICE_DEBUG_LEVEL");
>          if (debug_str != NULL) {
>              int debug_level;
> @@ -121,9 +121,8 @@ static void spice_logger(const gchar
> *log_domain,
>                           const gchar *message,
>                           gpointer user_data G_GNUC_UNUSED)
>  {
> -    if (glib_debug_level != 0) {
> -        if ((log_level & G_LOG_LEVEL_MASK) > glib_debug_level)
> -            return; // do not print anything
> +    if ((log_level & G_LOG_LEVEL_MASK) > glib_debug_level) {
> +        return; // do not print anything
>      }
>      g_log_default_handler(log_domain, log_level, message, NULL);
>  }
_______________________________________________
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]