diff mbox series

[net,2/3] net: ethtool: tsconfig: Fix ts filters and types enums size check

Message ID 20250128-fix_tsconfig-v1-2-87adcdc4e394@bootlin.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: ethtool: timestamping: Fix small issues in the new uAPI | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; GEN HAS DIFF 2 files changed, 61 insertions(+), 10 deletions(-);
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 2 this patch: 2
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2025-01-29--12-00 (tests: 885)

Commit Message

Kory Maincent Jan. 28, 2025, 3:35 p.m. UTC
Fix the size check for the hwtstamp_tx_types and hwtstamp_rx_filters
enumerations. Align this check with the approach used in tsinfo for
consistency and correctness.

Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
Fixes: 6e9e2eed4f39 ("net: ethtool: Add support for tsconfig command to get/set hwtstamp config")
---
 net/ethtool/tsconfig.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Jakub Kicinski Jan. 30, 2025, 12:45 a.m. UTC | #1
On Tue, 28 Jan 2025 16:35:47 +0100 Kory Maincent wrote:
> Fix the size check for the hwtstamp_tx_types and hwtstamp_rx_filters
> enumerations.

This is just a code cleanup, the constants are way smaller than 32
today. The assert being too restrictive makes no functional difference.

> Align this check with the approach used in tsinfo for
> consistency and correctness.

First-principles based explanation of why 32 is the correct value would
be much better than just alignment. Otherwise reviewer has to figure out
whether we should be changing from >= to > or vice versa...

> Signed-off-by: Kory Maincent <kory.maincent@bootlin.com>
> Fixes: 6e9e2eed4f39 ("net: ethtool: Add support for tsconfig command to get/set hwtstamp config")
Kory Maincent Jan. 30, 2025, 9:24 a.m. UTC | #2
On Wed, 29 Jan 2025 16:45:08 -0800
Jakub Kicinski <kuba@kernel.org> wrote:

> On Tue, 28 Jan 2025 16:35:47 +0100 Kory Maincent wrote:
> > Fix the size check for the hwtstamp_tx_types and hwtstamp_rx_filters
> > enumerations.  
> 
> This is just a code cleanup, the constants are way smaller than 32
> today. The assert being too restrictive makes no functional difference.

That's right, it was mainly for consistency with the other assert. And to avoid
possible future mistake but indeed reaching 32 bit is not expected soon. Should
I remove the patch as it is not a functional issue?

> > Align this check with the approach used in tsinfo for
> > consistency and correctness.  
> 
> First-principles based explanation of why 32 is the correct value would
> be much better than just alignment. Otherwise reviewer has to figure out
> whether we should be changing from >= to > or vice versa...

Ack, I will if I keep the patch.

Regards,
Jakub Kicinski Jan. 30, 2025, 4:42 p.m. UTC | #3
On Thu, 30 Jan 2025 10:24:51 +0100 Kory Maincent wrote:
> > This is just a code cleanup, the constants are way smaller than 32
> > today. The assert being too restrictive makes no functional difference.  
> 
> That's right, it was mainly for consistency with the other assert. And to avoid
> possible future mistake but indeed reaching 32 bit is not expected soon. Should
> I remove the patch as it is not a functional issue?

Yes, drop it please and repost after net-next re-opens.
diff mbox series

Patch

diff --git a/net/ethtool/tsconfig.c b/net/ethtool/tsconfig.c
index 9188e088fb2f..2dc3a3b76615 100644
--- a/net/ethtool/tsconfig.c
+++ b/net/ethtool/tsconfig.c
@@ -294,8 +294,8 @@  static int ethnl_set_tsconfig(struct ethnl_req_info *req_base,
 	struct nlattr **tb = info->attrs;
 	int ret;
 
-	BUILD_BUG_ON(__HWTSTAMP_TX_CNT >= 32);
-	BUILD_BUG_ON(__HWTSTAMP_FILTER_CNT >= 32);
+	BUILD_BUG_ON(__HWTSTAMP_TX_CNT > 32);
+	BUILD_BUG_ON(__HWTSTAMP_FILTER_CNT > 32);
 
 	if (!netif_device_present(dev))
 		return -ENODEV;