diff mbox series

virtio_net: Use max() function for better coding conventions

Message ID 20230710012508.2119-1-yangrong@vivo.com (mailing list archive)
State Rejected
Delegated to: Netdev Maintainers
Headers show
Series virtio_net: Use max() function for better coding conventions | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1341 this patch: 1341
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 1364 this patch: 1364
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 No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1364 this patch: 1364
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 15 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yang Rong July 10, 2023, 1:20 a.m. UTC
It is advisable to utilize the max() function in the virtio_net.c file, 
as it conforms better to programming conventions.

Signed-off-by: Yang Rong <yangrong@vivo.com>
---
 drivers/net/virtio_net.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
 mode change 100644 => 100755 drivers/net/virtio_net.c

Comments

Jakub Kicinski July 12, 2023, 2:29 a.m. UTC | #1
On Mon, 10 Jul 2023 09:20:51 +0800 Yang Rong wrote:
> It is advisable to utilize the max() function in the virtio_net.c file, 
> as it conforms better to programming conventions.
> 
> Signed-off-by: Yang Rong <yangrong@vivo.com>

Unnecessary churn, please don't send max() conversions to networking.
diff mbox series

Patch

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 9b3721424e71..5bb7da885f00
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -22,6 +22,7 @@ 
 #include <net/route.h>
 #include <net/xdp.h>
 #include <net/net_failover.h>
+#include <linux/minmax.h>
 
 static int napi_weight = NAPI_POLL_WEIGHT;
 module_param(napi_weight, int, 0444);
@@ -1291,7 +1292,7 @@  static struct sk_buff *build_skb_from_xdp_buff(struct net_device *dev,
 	__skb_put(skb, data_len);
 
 	metasize = xdp->data - xdp->data_meta;
-	metasize = metasize > 0 ? metasize : 0;
+	metasize = max(metasize, 0);
 	if (metasize)
 		skb_metadata_set(skb, metasize);