From: David Ahern <dsahern@gmail.com>
To: Stephen Hemminger <stephen@networkplumber.org>, netdev@vger.kernel.org
Subject: Re: [PATCH iproute2 v2] allow overriding color option in environment
Date: Mon, 18 Sep 2023 09:11:51 -0600 [thread overview]
Message-ID: <76f6f003-defb-96c8-162b-7242fe51f1ec@gmail.com> (raw)
In-Reply-To: <20230916150326.7942-1-stephen@networkplumber.org>
On 9/16/23 9:03 AM, Stephen Hemminger wrote:
> diff --git a/lib/color.c b/lib/color.c
> index 59976847295c..e2ffefaf75a8 100644
> --- a/lib/color.c
> +++ b/lib/color.c
> @@ -93,6 +93,32 @@ bool check_enable_color(int color, int json)
> return false;
> }
>
> +static bool match_color_value(const char *arg, int *val)
> +{
> + if (*arg == '\0' || !strcmp(arg, "always"))
here you check for a null string
> + *val = COLOR_OPT_ALWAYS;
> + else if (!strcmp(arg, "auto"))
> + *val = COLOR_OPT_AUTO;
> + else if (!strcmp(arg, "never"))
> + *val = COLOR_OPT_NEVER;
> + else
> + return false;
> + return true;
> +}
> +
> +int default_color(void)
> +{
> + const char *name;
> + int val;
> +
> + name = getenv("IPROUTE_COLORS");
> + if (name && *name && match_color_value(name, &val))
so you can drop the `*name` check here
prev parent reply other threads:[~2023-09-18 15:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-16 15:03 [PATCH iproute2 v2] allow overriding color option in environment Stephen Hemminger
2023-09-18 9:28 ` Andrea Claudi
2023-09-18 15:11 ` David Ahern [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=76f6f003-defb-96c8-162b-7242fe51f1ec@gmail.com \
--to=dsahern@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/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.