Skip to contentSkip to conversation

net: smc: fix different types in min()

PATCH Applied Jakub Kicinski 3 participants 3 messages Mar 1, 2022 – Mar 2, 2022

Subsystems (3)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/1 net: smc: fix different types in min()

Fix build:

include/linux/minmax.h:45:25: note: in expansion of macro ‘__careful_cmp’

   45 | #define min(x, y)       __careful_cmp(x, y, <)
      |                         ^~~~~~~~~~~~~

net/smc/smc_tx.c:150:24: note: in expansion of macro ‘min’
150 | corking_size = min(sock_net(&smc->sk)->smc.sysctl_autocorking_size,
| ^~~

Fixes 12bbb0d163a9 ("net/smc: add sysctl for autocorking")
---
 net/smc/smc_tx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/smc/smc_tx.c +2 -2
index 257dc0d0aeb1..98ca9229fe87 100644
@@ -147,8 +147,8 @@ static bool smc_should_autocork(struct smc_sock *smc)
 	struct smc_connection *conn = &smc->conn;
 	int corking_size;
 
-	corking_size = min(sock_net(&smc->sk)->smc.sysctl_autocorking_size,
-			   conn->sndbuf_desc->len >> 1);
+	corking_size = min_t(unsigned int, conn->sndbuf_desc->len >> 1,
+			     sock_net(&smc->sk)->smc.sysctl_autocorking_size);
 
 	if (atomic_read(&conn->cdc_pend_tx_wr) == 0 ||
 	    smc_tx_prepared_sends(conn) > corking_size)
Signature · 1 line
2.34.1
#1 lore raw
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Quoted 10 lines · On Tue, 1 Mar 2022 14:24:46 -0800 you wrote:

Fix build:

include/linux/minmax.h:45:25: note: in expansion of macro ‘__careful_cmp’

   45 | #define min(x, y)       __careful_cmp(x, y, <)
      |                         ^~~~~~~~~~~~~

net/smc/smc_tx.c:150:24: note: in expansion of macro ‘min’
150 | corking_size = min(sock_net(&smc->sk)->smc.sysctl_autocorking_size,
| ^~~

[...]

Here is the summary with links:
- [net-next] net: smc: fix different types in min()

    https://git.kernel.org/netdev/net-next/c/ef739f1dd3ac

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
maintainer
#2 lore raw
In reply to Jakub Kicinski
Quoted 8 lines · Jakub Kicinski

Fix build:

include/linux/minmax.h:45:25: note: in expansion of macro ‘__careful_cmp’

  45 | #define min(x, y)       __careful_cmp(x, y, <)
     |                         ^~~~~~~~~~~~~

net/smc/smc_tx.c:150:24: note: in expansion of macro ‘min’
150 | corking_size = min(sock_net(&smc->sk)->smc.sysctl_autocorking_size,
| ^~~

Really sorry for the break and thanks for the fix !
I found my compiler didn't complain about this, I will try to fix my development environment.

Quoted 24 lines
Fixes 12bbb0d163a9 ("net/smc: add sysctl for autocorking")

---
net/smc/smc_tx.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
net/smc/smc_tx.c +2 -2
index 257dc0d0aeb1..98ca9229fe87 100644
@@ -147,8 +147,8 @@ static bool smc_should_autocork(struct smc_sock *smc)
 	struct smc_connection *conn = &smc->conn;
 	int corking_size;
 
-	corking_size = min(sock_net(&smc->sk)->smc.sysctl_autocorking_size,
-			   conn->sndbuf_desc->len >> 1);
+	corking_size = min_t(unsigned int, conn->sndbuf_desc->len >> 1,
+			     sock_net(&smc->sk)->smc.sysctl_autocorking_size);
 
 	if (atomic_read(&conn->cdc_pend_tx_wr) == 0 ||
 	    smc_tx_prepared_sends(conn) > corking_size)
Signature · 1 line
2.34.1