Subject: Re: [PATCH ethtool-next 2/2] netlink: tsinfo: add statistics support

From: Rahul Rameshbabu <[email-masked]>
Date: Tue, 16 Apr 2024 18:25:24 -0700

On Tue, 16 Apr, 2024 17:07:42 -0700 Jakub Kicinski <[email-masked]> 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