Subject: Re: [PATCH iproute2-next v2] iproute2 Support lockless token bucket (ltb)

From: Stephen Hemminger <[email-masked]>
Date: Wed, 8 Jul 2020 23:33:05 -0700

On Thu, 09 Jul 2020 00:38:27 +0800
"YU, Xiangning" <[email-masked]> wrote:

> +static int ltb_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,
> +			       struct nlmsghdr *n, const char *dev)
> +{
> +	struct tc_ltb_opt opt;

If you use empty initializer in C it will make everything 0 and save you some pain.

	struct tc_ltb_opt opt = { };

> +		fprintf(f, "rate %s ", sprint_rate(rate64, b1));
> +		fprintf(f, "ceil %s ", sprint_rate(ceil64, b1));
> +		if (show_details) {
> +			fprintf(f, "measured %llu allocated %llu highwater %llu",
> +				lopt->measured, lopt->allocated,
> +				lopt->high_water);

All output has to be in JSON. Any use of fprintf(f, ...) directly
is a indication to me of code that is not supporting JSON correctly.