Subject: Re: [PATCH iproute2-next 7/9] Add support for nexthop objects

From: Stephen Hemminger <[email-masked]>
Date: Thu, 30 May 2019 10:52:29 -0700

On Wed, 29 May 2019 20:17:44 -0700
David Ahern <[email-masked]> wrote:

> +
> +static void print_nh_gateway(FILE *fp, const struct nhmsg *nhm,
> +			      const struct rtattr *rta)
> +{
> +	const char *gateway = format_host_rta(nhm->nh_family, rta);
> +
> +	if (is_json_context())
> +		print_string(PRINT_JSON, "gateway", NULL, gateway);
> +	else {
> +		fprintf(fp, "via ");

I was trying to get rid of all use of /fprintf(fp, / since it was
indication of non-json code and fp is always stdout.

Maybe
	print_string(PRINT_FP, NULL, "via ", NULL);
	print_color_string(PRINT_ANY, ifa_family_color(nhm->nh_family),
			"gateway", "%s ", format_host_rta(nhm->nh_family, rta));