[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 16 Apr 2024 18:25:24 -0700
From: Rahul Rameshbabu <rrameshbabu@...dia.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: netdev@...r.kernel.org, Vadim Fedorenko <vadim.fedorenko@...ux.dev>,
Jacob Keller <jacob.e.keller@...el.com>, Paolo Abeni <pabeni@...hat.com>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet
<edumazet@...gle.com>, Gal Pressman <gal@...dia.com>, Tariq Toukan
<tariqt@...dia.com>, Saeed Mahameed <saeedm@...dia.com>, Carolina Jubran
<cjubran@...dia.com>, Cosmin Ratiu <cratiu@...dia.com>, Michal Kubecek
<mkubecek@...e.cz>
Subject: Re: [PATCH ethtool-next 2/2] netlink: tsinfo: add statistics support
On Tue, 16 Apr, 2024 17:07:42 -0700 Jakub Kicinski <kuba@...nel.org> wrote:
> On Tue, 16 Apr 2024 13:37:17 -0700 Rahul Rameshbabu wrote:
>> + if (mnl_attr_validate(tb[stats[i].attr], MNL_TYPE_U32)) {
>> + is_u64 = true;
>> + if (mnl_attr_validate(tb[stats[i].attr], MNL_TYPE_U64)) {
>> + fprintf(stderr, "malformed netlink message (statistic)\n");
>> + goto err_close_stats;
>> + }
>> + }
>
> possibly cleaner:
>
> __u64 val;
>
> if (!mnl_attr_validate(tb[stats[i].attr], MNL_TYPE_U32)) {
> val = mnl_attr_get_u32(tb[stats[i].attr]);
> } else if (!mnl_attr_validate(tb[stats[i].attr], MNL_TYPE_U64)) {
> val = mnl_attr_get_u64(tb[stats[i].attr]);
> } else {
> fprintf(stderr, "malformed netlink message (statistic)\n");
> goto err_close_stats;
> }
I think this refactor is nice as well. Will wait 24 hours before
reposting but will send out a v2.
--
Thanks,
Rahul Rameshbabu
Powered by blists - more mailing lists