All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Petr Vorel <petr.vorel@gmail.com>
Cc: netdev@vger.kernel.org, Julien Fortin <julien@cumulusnetworks.com>
Subject: Re: [PATCH iproute2 1/1] color: Fix ip segfault in color_fprintf() when using --color switch
Date: Wed, 11 Oct 2017 10:53:52 -0700	[thread overview]
Message-ID: <20171011105352.46f1b207@xeon-e3> (raw)
In-Reply-To: <20171008143847.21699-1-petr.vorel@gmail.com>

On Sun,  8 Oct 2017 16:38:47 +0200
Petr Vorel <petr.vorel@gmail.com> wrote:

> diff --git a/include/json_print.h b/include/json_print.h
> index b6ce1f9f..2f3f07c8 100644
> --- a/include/json_print.h
> +++ b/include/json_print.h
> @@ -53,7 +53,7 @@ void close_json_array(enum output_type type, const char *delim);
>  					     const char *fmt,		\
>  					     type value)		\
>  	{								\
> -		print_color_##type_name(t, -1, key, fmt, value);	\
> +		print_color_##type_name(t, 0, key, fmt, value);	\
>  	}
>  _PRINT_FUNC(int, int);
>  _PRINT_FUNC(bool, bool);
> diff --git a/lib/color.c b/lib/color.c
> index 79d5e289..e597798f 100644
> --- a/lib/color.c
> +++ b/lib/color.c
> @@ -110,7 +110,7 @@ int color_fprintf(FILE *fp, enum color_attr attr, const char *fmt, ...)
>  	}
>  
>  	ret += fprintf(fp, "%s",
> -		       color_codes[attr_colors[is_dark_bg ? attr + 8 : attr]]);
> +		       color_codes[attr_colors[is_dark_bg ? attr + 6 : attr - 1]]);

Magic offsets (8 and -1) are error prone. Can this be changed to an enum value from colors?

      reply	other threads:[~2017-10-11 17:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-08 14:38 [PATCH iproute2 1/1] color: Fix ip segfault in color_fprintf() when using --color switch Petr Vorel
2017-10-11 17:53 ` Stephen Hemminger [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171011105352.46f1b207@xeon-e3 \
    --to=stephen@networkplumber.org \
    --cc=julien@cumulusnetworks.com \
    --cc=netdev@vger.kernel.org \
    --cc=petr.vorel@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.