netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] virtio_net: Use max() function for better coding conventions
@ 2023-07-10  1:20 Yang Rong
  2023-07-12  2:29 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: Yang Rong @ 2023-07-10  1:20 UTC (permalink / raw)
  To: Michael S. Tsirkin, Jason Wang, Xuan Zhuo, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	open list:VIRTIO CORE AND NET DRIVERS,
	open list:NETWORKING DRIVERS, open list
  Cc: opensource.kernel, luhongfei, Yang Rong

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-12  2:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-10  1:20 [PATCH] virtio_net: Use max() function for better coding conventions Yang Rong
2023-07-12  2:29 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).