From: Stephen Hemminger <stephen@networkplumber.org>
To: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>,
linux-can@vger.kernel.org,
Oliver Hartkopp <socketcan@hartkopp.net>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH v1 1/1] iplink_can: add new CAN FD bittiming parameters: Transmitter Delay Compensation (TDC)
Date: Thu, 6 May 2021 08:50:35 -0700 [thread overview]
Message-ID: <20210506085035.2fc33bf3@hermes.local> (raw)
In-Reply-To: <20210506112007.1666738-2-mailhol.vincent@wanadoo.fr>
On Thu, 6 May 2021 20:20:07 +0900
Vincent Mailhol <mailhol.vincent@wanadoo.fr> wrote:
> + if (tb[IFLA_CAN_TDC_TDCV] && tb[IFLA_CAN_TDC_TDCO] &&
> + tb[IFLA_CAN_TDC_TDCF]) {
> + __u32 *tdcv = RTA_DATA(tb[IFLA_CAN_TDC_TDCV]);
> + __u32 *tdco = RTA_DATA(tb[IFLA_CAN_TDC_TDCO]);
> + __u32 *tdcf = RTA_DATA(tb[IFLA_CAN_TDC_TDCF]);
> +
> + if (is_json_context()) {
> + open_json_object("tdc");
> + print_int(PRINT_JSON, "tdcv", NULL, *tdcv);
> + print_int(PRINT_JSON, "tdco", NULL, *tdco);
> + print_int(PRINT_JSON, "tdcf", NULL, *tdcf);
> + close_json_object();
> + } else {
> + fprintf(f, "\n tdcv %d tdco %d tdcf %d",
> + *tdcv, *tdco, *tdcf);
> + }
> + }
> +
The most common pattern in iproute2 is to let json/non-json be decided
inside the print routine. I search for all instances of fprintf as
indication of broken code. Also these are not signed values so please
print unsigned. The code should use print_nl() to handle the single line
case. Also, there is helper to handle
Something like:
__u32 tdc = rte_getattr_u32(tb[IFLA_CAN_TDC_TDCV]);
open_json_object("tdc");
print_nl();
print_u32(PRINT_ANY, "tdcv", " tdcv %u", tdcv);
...
next prev parent reply other threads:[~2021-05-06 15:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-06 11:20 [RFC PATCH v1 0/1] add commandline support for Transmitter Delay Compensation (TDC) in iproute Vincent Mailhol
2021-05-06 11:20 ` [RFC PATCH v1 1/1] iplink_can: add new CAN FD bittiming parameters: Transmitter Delay Compensation (TDC) Vincent Mailhol
2021-05-06 15:50 ` Stephen Hemminger [this message]
2021-05-07 10:35 ` Vincent MAILHOL
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=20210506085035.2fc33bf3@hermes.local \
--to=stephen@networkplumber.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mailhol.vincent@wanadoo.fr \
--cc=mkl@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=socketcan@hartkopp.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).