public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH] io_uring/net: Remove unneeded if check in io_net_vec_assign()
@ 2024-08-11 22:26 Thorsten Blum
  2024-08-11 22:31 ` Jens Axboe
  0 siblings, 1 reply; 3+ messages in thread
From: Thorsten Blum @ 2024-08-11 22:26 UTC (permalink / raw)
  To: axboe, asml.silence; +Cc: io-uring, linux-kernel, Thorsten Blum

kfree() already checks if its argument is NULL. Remove the unneeded if
check and fix the following Coccinelle/coccicheck warning reported by
ifnullfree.cocci:

  WARNING: NULL check before some freeing functions is not needed

Signed-off-by: Thorsten Blum <[email protected]>
---
 io_uring/net.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/io_uring/net.c b/io_uring/net.c
index d08abcca89cc..9f35f1eb54cb 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -189,8 +189,7 @@ static int io_net_vec_assign(struct io_kiocb *req, struct io_async_msghdr *kmsg,
 	if (iov) {
 		req->flags |= REQ_F_NEED_CLEANUP;
 		kmsg->free_iov_nr = kmsg->msg.msg_iter.nr_segs;
-		if (kmsg->free_iov)
-			kfree(kmsg->free_iov);
+		kfree(kmsg->free_iov);
 		kmsg->free_iov = iov;
 	}
 	return 0;
-- 
2.46.0


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

* Re: [PATCH] io_uring/net: Remove unneeded if check in io_net_vec_assign()
  2024-08-11 22:26 [PATCH] io_uring/net: Remove unneeded if check in io_net_vec_assign() Thorsten Blum
@ 2024-08-11 22:31 ` Jens Axboe
  2024-08-11 22:37   ` Thorsten Blum
  0 siblings, 1 reply; 3+ messages in thread
From: Jens Axboe @ 2024-08-11 22:31 UTC (permalink / raw)
  To: Thorsten Blum, asml.silence; +Cc: io-uring, linux-kernel

On 8/11/24 4:26 PM, Thorsten Blum wrote:
> kfree() already checks if its argument is NULL. Remove the unneeded if
> check and fix the following Coccinelle/coccicheck warning reported by
> ifnullfree.cocci:
> 
>   WARNING: NULL check before some freeing functions is not needed

Yes it's not needed, but the NULL check is done after a function call.
For the hot path, it's FASTER to check if it's NULL or not.

I can put a comment on these, but honestly I wish the ifnullfree
thing would just go away as it's hardly useful for anything. It's
not like it's a bug to check for NULL first, or that it would find
something useful.

-- 
Jens Axboe



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

* Re: [PATCH] io_uring/net: Remove unneeded if check in io_net_vec_assign()
  2024-08-11 22:31 ` Jens Axboe
@ 2024-08-11 22:37   ` Thorsten Blum
  0 siblings, 0 replies; 3+ messages in thread
From: Thorsten Blum @ 2024-08-11 22:37 UTC (permalink / raw)
  To: Jens Axboe; +Cc: asml.silence, io-uring, linux-kernel

On 12. Aug 2024, at 00:31, Jens Axboe <[email protected]> wrote:
> On 8/11/24 4:26 PM, Thorsten Blum wrote:
>> kfree() already checks if its argument is NULL. Remove the unneeded if
>> check and fix the following Coccinelle/coccicheck warning reported by
>> ifnullfree.cocci:
>> 
>>  WARNING: NULL check before some freeing functions is not needed
> 
> Yes it's not needed, but the NULL check is done after a function call.
> For the hot path, it's FASTER to check if it's NULL or not.
> 
> I can put a comment on these, but honestly I wish the ifnullfree
> thing would just go away as it's hardly useful for anything. It's
> not like it's a bug to check for NULL first, or that it would find
> something useful.

Ok, thanks for explaining.

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

end of thread, other threads:[~2024-08-11 22:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-11 22:26 [PATCH] io_uring/net: Remove unneeded if check in io_net_vec_assign() Thorsten Blum
2024-08-11 22:31 ` Jens Axboe
2024-08-11 22:37   ` Thorsten Blum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox