All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Zahari Doychev <zahari.doychev@linux.com>
Cc: netdev@vger.kernel.org, dsahern@gmail.com,
	hmehrtens@maxlinear.com, aleksander.lobakin@intel.com,
	simon.horman@corigine.com, idosch@idosch.org,
	Zahari Doychev <zdoychev@maxlinear.com>
Subject: Re: [PATCH iproute2-next v2] f_flower: add cfm support
Date: Sun, 25 Jun 2023 12:03:41 -0700	[thread overview]
Message-ID: <20230625120341.5e738745@hermes.local> (raw)
In-Reply-To: <20230620201036.539994-1-zahari.doychev@linux.com>

On Tue, 20 Jun 2023 22:10:36 +0200
Zahari Doychev <zahari.doychev@linux.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.

  parent reply	other threads:[~2023-06-25 19:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-20 20:10 [PATCH iproute2-next v2] f_flower: add cfm support Zahari Doychev
2023-06-21  6:00 ` Ido Schimmel
2023-06-21  7:41   ` Zahari Doychev
2023-06-21 15:58   ` David Ahern
2023-06-25 19:03 ` Stephen Hemminger [this message]
2023-06-26 20:27   ` Zahari Doychev

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=20230625120341.5e738745@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=aleksander.lobakin@intel.com \
    --cc=dsahern@gmail.com \
    --cc=hmehrtens@maxlinear.com \
    --cc=idosch@idosch.org \
    --cc=netdev@vger.kernel.org \
    --cc=simon.horman@corigine.com \
    --cc=zahari.doychev@linux.com \
    --cc=zdoychev@maxlinear.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.