From: Thomas Gleixner <tglx@linutronix.de>
To: James Bottomley <James.Bottomley@HansenPartnership.com>,
LKML <linux-kernel@vger.kernel.org>
Cc: Marc Zyngier <maz@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Nishanth Menon <nm@ti.com>, Dhruva Gole <d-gole@ti.com>,
Tero Kristo <kristo@kernel.org>,
Santosh Shilimkar <ssantosh@kernel.org>,
Logan Gunthorpe <logang@deltatee.com>,
Dave Jiang <dave.jiang@intel.com>, Jon Mason <jdmason@kudzu.us>,
Allen Hubbe <allenbh@gmail.com>,
ntb@lists.linux.dev, Bjorn Helgaas <bhelgaas@google.com>,
linux-pci@vger.kernel.org, Michael Kelley <mhklinux@outlook.com>,
Wei Liu <wei.liu@kernel.org>,
Haiyang Zhang <haiyangz@microsoft.com>,
linux-hyperv@vger.kernel.org, Wei Huang <wei.huang2@amd.com>,
Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
linux-scsi@vger.kernel.org,
Jonathan Cameron <Jonathan.Cameron@huwei.com>
Subject: Re: [patch V3 01/10] cleanup: Provide retain_ptr()
Date: Tue, 18 Mar 2025 09:37:14 +0100 [thread overview]
Message-ID: <87r02u4tvp.ffs@tglx> (raw)
In-Reply-To: <4a6efcf37b3cf8812dcfaaa66d4c1760b3e2a95a.camel@HansenPartnership.com>
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...):
next prev parent reply other threads:[~2025-03-18 8:37 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-17 13:29 [patch V3 00/10] genirq/msi: Spring cleaning Thomas Gleixner
2025-03-17 13:29 ` [patch V3 01/10] cleanup: Provide retain_ptr() Thomas Gleixner
2025-03-17 13:57 ` James Bottomley
2025-03-18 8:37 ` Thomas Gleixner [this message]
2025-03-17 13:29 ` [patch V3 02/10] genirq/msi: Use lock guards for MSI descriptor locking Thomas Gleixner
2025-03-17 13:29 ` [patch V3 03/10] soc: ti: ti_sci_inta_msi: Switch MSI descriptor locking to guard() Thomas Gleixner
2025-03-17 13:29 ` [patch V3 04/10] NTB/msi: Switch MSI descriptor locking to lock guard() Thomas Gleixner
2025-03-17 13:29 ` [patch V3 05/10] PCI/MSI: Switch to MSI descriptor locking to guard() Thomas Gleixner
2025-03-18 20:24 ` Bjorn Helgaas
2025-03-17 13:29 ` [patch V3 06/10] PCI: hv: Switch " Thomas Gleixner
2025-03-17 13:29 ` [patch V3 07/10] PCI/MSI: Provide a sane mechanism for TPH Thomas Gleixner
2025-03-17 13:29 ` [patch V3 08/10] PCI/TPH: Replace the broken MSI-X control word update Thomas Gleixner
2025-03-17 13:29 ` [patch V3 09/10] scsi: ufs: qcom: Remove the MSI descriptor abuse Thomas Gleixner
2025-03-17 16:26 ` James Bottomley
2025-03-18 8:40 ` Thomas Gleixner
2025-03-17 13:29 ` [patch V3 10/10] genirq/msi: Rename msi_[un]lock_descs() Thomas Gleixner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r02u4tvp.ffs@tglx \
--to=tglx@linutronix.de \
--cc=James.Bottomley@HansenPartnership.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=Jonathan.Cameron@huwei.com \
--cc=allenbh@gmail.com \
--cc=bhelgaas@google.com \
--cc=d-gole@ti.com \
--cc=dave.jiang@intel.com \
--cc=haiyangz@microsoft.com \
--cc=jdmason@kudzu.us \
--cc=kristo@kernel.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=logang@deltatee.com \
--cc=manivannan.sadhasivam@linaro.org \
--cc=martin.petersen@oracle.com \
--cc=maz@kernel.org \
--cc=mhklinux@outlook.com \
--cc=nm@ti.com \
--cc=ntb@lists.linux.dev \
--cc=peterz@infradead.org \
--cc=ssantosh@kernel.org \
--cc=wei.huang2@amd.com \
--cc=wei.liu@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).