[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230625120341.5e738745@hermes.local>
Date: Sun, 25 Jun 2023 12:03:41 -0700
From: Stephen Hemminger <stephen@...workplumber.org>
To: Zahari Doychev <zahari.doychev@...ux.com>
Cc: netdev@...r.kernel.org, dsahern@...il.com, hmehrtens@...linear.com,
aleksander.lobakin@...el.com, simon.horman@...igine.com, idosch@...sch.org,
Zahari Doychev <zdoychev@...linear.com>
Subject: Re: [PATCH iproute2-next v2] f_flower: add cfm support
On Tue, 20 Jun 2023 22:10:36 +0200
Zahari Doychev <zahari.doychev@...ux.com> wrote:
> + print_nl();
> + print_string(PRINT_FP, NULL, " cfm", NULL);
> + open_json_object("cfm");
> +
> + v = tb[TCA_FLOWER_KEY_CFM_MD_LEVEL];
> + if (v) {
> + sz += sprintf(out, " mdl %u", rta_getattr_u8(v));
> + print_hhu(PRINT_JSON, "mdl", NULL, rta_getattr_u8(v));
> +
> + }
> +
> + v = tb[TCA_FLOWER_KEY_CFM_OPCODE];
> + if (v) {
> + sprintf(out + sz, " op %u", rta_getattr_u8(v));
> + print_hhu(PRINT_JSON, "op", NULL, rta_getattr_u8(v));
> +
> + }
> +
> + close_json_object();
> + print_string(PRINT_FP, "cfm", "%s", out);
Don't think you need to format the temporary string if you do this the easy way.
Just use print_uint?
if (tb[TCA_FLOWER_KEY_CFM_MD_LEVEL])
print_uint(PRINT_ANY, "mdl", " mdl %u",
rta_getattr_u8(tb[TCA_FLOWER_KEY_CFM_MD_LEVEL]);
Since argument to print_uint is unsigned, the u8 will naturally get expanded.
Powered by blists - more mailing lists