[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87r02u4tvp.ffs@tglx>
Date: Tue, 18 Mar 2025 09:37:14 +0100
From: Thomas Gleixner <tglx@...utronix.de>
To: James Bottomley <James.Bottomley@...senPartnership.com>, LKML
<linux-kernel@...r.kernel.org>
Cc: Marc Zyngier <maz@...nel.org>, Peter Zijlstra <peterz@...radead.org>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>, Nishanth Menon
<nm@...com>, Dhruva Gole <d-gole@...com>, Tero Kristo <kristo@...nel.org>,
Santosh
Shilimkar <ssantosh@...nel.org>, Logan Gunthorpe <logang@...tatee.com>,
Dave Jiang <dave.jiang@...el.com>, Jon Mason <jdmason@...zu.us>, Allen
Hubbe <allenbh@...il.com>, ntb@...ts.linux.dev, Bjorn Helgaas
<bhelgaas@...gle.com>, linux-pci@...r.kernel.org, Michael Kelley
<mhklinux@...look.com>, Wei Liu <wei.liu@...nel.org>, Haiyang Zhang
<haiyangz@...rosoft.com>, linux-hyperv@...r.kernel.org, Wei Huang
<wei.huang2@....com>, Manivannan Sadhasivam
<manivannan.sadhasivam@...aro.org>, "Martin K. Petersen"
<martin.petersen@...cle.com>, linux-scsi@...r.kernel.org, Jonathan Cameron
<Jonathan.Cameron@...ei.com>
Subject: Re: [patch V3 01/10] cleanup: Provide retain_ptr()
On Mon, Mar 17 2025 at 09:57, James Bottomley wrote:
> On Mon, 2025-03-17 at 14:29 +0100, Thomas Gleixner wrote:
>> +#define retain_ptr(p) \
>> + __get_and_null(p, NULL)
>
> This doesn't score very highly on the Rusty API design scale because it
> can be used anywhere return_ptr() should be used. To force the
> distinction between the two cases at the compiler level, should there
> be a cast to void in the above to prevent using the return value?
Indeed. Delta patch below seems to do the trick.
Thanks,
tglx
---
diff --git a/include/linux/cleanup.h b/include/linux/cleanup.h
index 6537f8dfe1bb..859b06d4ad7a 100644
--- a/include/linux/cleanup.h
+++ b/include/linux/cleanup.h
@@ -231,8 +231,7 @@ const volatile void * __must_check_fn(const volatile void *val)
* retain_ptr(f);
* return ret;
*/
-#define retain_ptr(p) \
- __get_and_null(p, NULL)
+#define retain_ptr(p) ((void)__get_and_null(p, NULL))
/*
* DEFINE_CLASS(name, type, exit, init, init_args...):
Powered by blists - more mailing lists