[PATCH] virtio_net: Use max() function for better coding conventions

Yang Rong posted 1 patch 2 years, 7 months ago
drivers/net/virtio_net.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
mode change 100644 => 100755 drivers/net/virtio_net.c
[PATCH] virtio_net: Use max() function for better coding conventions
Posted by Yang Rong 2 years, 7 months ago
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

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);
 
-- 
2.35.3
Re: [PATCH] virtio_net: Use max() function for better coding conventions
Posted by Jakub Kicinski 2 years, 7 months ago
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.
-- 
pw-bot: reject