2023-07-10 02:20:56

by Yang Rong

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

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 <[email protected]>
---
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



2023-07-12 03:09:20

by Jakub Kicinski

[permalink] [raw]
Subject: Re: [PATCH] virtio_net: Use max() function for better coding conventions

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 <[email protected]>

Unnecessary churn, please don't send max() conversions to networking.
--
pw-bot: reject