Replace usage of the custom FIELD_OFFSET macro with the standard
offsetof() macro in drv_types.h. This improves code readability and
standardization.
Signed-off-by: Navaneeth K <knavaneeth786@gmail.com>
---
drivers/staging/rtl8723bs/include/drv_types.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/rtl8723bs/include/drv_types.h b/drivers/staging/rtl8723bs/include/drv_types.h
index dd9018aa4ee5..47cabf8707f6 100644
--- a/drivers/staging/rtl8723bs/include/drv_types.h
+++ b/drivers/staging/rtl8723bs/include/drv_types.h
@@ -173,9 +173,9 @@ struct registry_priv {
/* For registry parameters */
-#define RGTRY_OFT(field) ((u32)FIELD_OFFSET(struct registry_priv, field))
+#define RGTRY_OFT(field) ((u32)offsetof(struct registry_priv, field))
#define RGTRY_SZ(field) sizeof(((struct registry_priv *)0)->field)
-#define BSSID_OFT(field) ((u32)FIELD_OFFSET(struct wlan_bssid_ex, field))
+#define BSSID_OFT(field) ((u32)offsetof(struct wlan_bssid_ex, field))
#define BSSID_SZ(field) sizeof(((struct wlan_bssid_ex *) 0)->field)
#include <drv_types_sdio.h>
--
2.43.0
On Sat, Nov 22, 2025 at 05:45:52PM +0000, Navaneeth K wrote:
> Replace usage of the custom FIELD_OFFSET macro with the standard
> offsetof() macro in drv_types.h. This improves code readability and
> standardization.
>
> Signed-off-by: Navaneeth K <knavaneeth786@gmail.com>
> ---
> drivers/staging/rtl8723bs/include/drv_types.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/rtl8723bs/include/drv_types.h b/drivers/staging/rtl8723bs/include/drv_types.h
> index dd9018aa4ee5..47cabf8707f6 100644
> --- a/drivers/staging/rtl8723bs/include/drv_types.h
> +++ b/drivers/staging/rtl8723bs/include/drv_types.h
> @@ -173,9 +173,9 @@ struct registry_priv {
>
>
> /* For registry parameters */
> -#define RGTRY_OFT(field) ((u32)FIELD_OFFSET(struct registry_priv, field))
> +#define RGTRY_OFT(field) ((u32)offsetof(struct registry_priv, field))
These casts to u32 are bogus garbage. Delete them.
regards,
dan carpenter
On Mon, 24 Nov 2025 11:08:35 +0300
Dan Carpenter <dan.carpenter@linaro.org> wrote:
> On Sat, Nov 22, 2025 at 05:45:52PM +0000, Navaneeth K wrote:
> > Replace usage of the custom FIELD_OFFSET macro with the standard
> > offsetof() macro in drv_types.h. This improves code readability and
> > standardization.
> >
> > Signed-off-by: Navaneeth K <knavaneeth786@gmail.com>
> > ---
> > drivers/staging/rtl8723bs/include/drv_types.h | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/staging/rtl8723bs/include/drv_types.h b/drivers/staging/rtl8723bs/include/drv_types.h
> > index dd9018aa4ee5..47cabf8707f6 100644
> > --- a/drivers/staging/rtl8723bs/include/drv_types.h
> > +++ b/drivers/staging/rtl8723bs/include/drv_types.h
> > @@ -173,9 +173,9 @@ struct registry_priv {
> >
> >
> > /* For registry parameters */
> > -#define RGTRY_OFT(field) ((u32)FIELD_OFFSET(struct registry_priv, field))
> > +#define RGTRY_OFT(field) ((u32)offsetof(struct registry_priv, field))
>
> These casts to u32 are bogus garbage. Delete them.
Dunno - they might be needed (or have been needed) to stop min()
complaining about type mismatch.
They can also stop expressions being evaluated as 64bit (on 64bit)
which may reduce code size.
But that is a bit subtle...
David
>
> regards,
> dan carpenter
>
>
>
On Mon, Nov 24, 2025 at 09:17:54AM +0000, david laight wrote:
> On Mon, 24 Nov 2025 11:08:35 +0300
> Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> > On Sat, Nov 22, 2025 at 05:45:52PM +0000, Navaneeth K wrote:
> > > Replace usage of the custom FIELD_OFFSET macro with the standard
> > > offsetof() macro in drv_types.h. This improves code readability and
> > > standardization.
> > >
> > > Signed-off-by: Navaneeth K <knavaneeth786@gmail.com>
> > > ---
> > > drivers/staging/rtl8723bs/include/drv_types.h | 4 ++--
> > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/staging/rtl8723bs/include/drv_types.h b/drivers/staging/rtl8723bs/include/drv_types.h
> > > index dd9018aa4ee5..47cabf8707f6 100644
> > > --- a/drivers/staging/rtl8723bs/include/drv_types.h
> > > +++ b/drivers/staging/rtl8723bs/include/drv_types.h
> > > @@ -173,9 +173,9 @@ struct registry_priv {
> > >
> > >
> > > /* For registry parameters */
> > > -#define RGTRY_OFT(field) ((u32)FIELD_OFFSET(struct registry_priv, field))
> > > +#define RGTRY_OFT(field) ((u32)offsetof(struct registry_priv, field))
> >
> > These casts to u32 are bogus garbage. Delete them.
>
> Dunno - they might be needed (or have been needed) to stop min()
> complaining about type mismatch.
> They can also stop expressions being evaluated as 64bit (on 64bit)
> which may reduce code size.
> But that is a bit subtle...
Actually the macros are unused. Just delete them entirely.
regards,
dan carpenter
On Mon, 24 Nov 2025 12:45:46 +0300
Dan Carpenter <dan.carpenter@linaro.org> wrote:
> On Mon, Nov 24, 2025 at 09:17:54AM +0000, david laight wrote:
> > On Mon, 24 Nov 2025 11:08:35 +0300
> > Dan Carpenter <dan.carpenter@linaro.org> wrote:
> >
> > > On Sat, Nov 22, 2025 at 05:45:52PM +0000, Navaneeth K wrote:
> > > > Replace usage of the custom FIELD_OFFSET macro with the standard
> > > > offsetof() macro in drv_types.h. This improves code readability and
> > > > standardization.
> > > >
> > > > Signed-off-by: Navaneeth K <knavaneeth786@gmail.com>
> > > > ---
> > > > drivers/staging/rtl8723bs/include/drv_types.h | 4 ++--
> > > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/drivers/staging/rtl8723bs/include/drv_types.h b/drivers/staging/rtl8723bs/include/drv_types.h
> > > > index dd9018aa4ee5..47cabf8707f6 100644
> > > > --- a/drivers/staging/rtl8723bs/include/drv_types.h
> > > > +++ b/drivers/staging/rtl8723bs/include/drv_types.h
> > > > @@ -173,9 +173,9 @@ struct registry_priv {
> > > >
> > > >
> > > > /* For registry parameters */
> > > > -#define RGTRY_OFT(field) ((u32)FIELD_OFFSET(struct registry_priv, field))
> > > > +#define RGTRY_OFT(field) ((u32)offsetof(struct registry_priv, field))
> > >
> > > These casts to u32 are bogus garbage. Delete them.
> >
> > Dunno - they might be needed (or have been needed) to stop min()
> > complaining about type mismatch.
> > They can also stop expressions being evaluated as 64bit (on 64bit)
> > which may reduce code size.
> > But that is a bit subtle...
>
> Actually the macros are unused. Just delete them entirely.
Sounds good to me :-)
>
> regards,
> dan carpenter
>
Hi Dan, Hi David,
Thanks for the clarification.
I’ll remove the unused macro entirely in v2 instead of adjusting the cast.
Regards,
Navaneeth K
On 24-11-2025 17:43, david laight wrote:
> On Mon, 24 Nov 2025 12:45:46 +0300
> Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
>> On Mon, Nov 24, 2025 at 09:17:54AM +0000, david laight wrote:
>>> On Mon, 24 Nov 2025 11:08:35 +0300
>>> Dan Carpenter <dan.carpenter@linaro.org> wrote:
>>>
>>>> On Sat, Nov 22, 2025 at 05:45:52PM +0000, Navaneeth K wrote:
>>>>> Replace usage of the custom FIELD_OFFSET macro with the standard
>>>>> offsetof() macro in drv_types.h. This improves code readability and
>>>>> standardization.
>>>>>
>>>>> Signed-off-by: Navaneeth K <knavaneeth786@gmail.com>
>>>>> ---
>>>>> drivers/staging/rtl8723bs/include/drv_types.h | 4 ++--
>>>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>>>
>>>>> diff --git a/drivers/staging/rtl8723bs/include/drv_types.h b/drivers/staging/rtl8723bs/include/drv_types.h
>>>>> index dd9018aa4ee5..47cabf8707f6 100644
>>>>> --- a/drivers/staging/rtl8723bs/include/drv_types.h
>>>>> +++ b/drivers/staging/rtl8723bs/include/drv_types.h
>>>>> @@ -173,9 +173,9 @@ struct registry_priv {
>>>>>
>>>>>
>>>>> /* For registry parameters */
>>>>> -#define RGTRY_OFT(field) ((u32)FIELD_OFFSET(struct registry_priv, field))
>>>>> +#define RGTRY_OFT(field) ((u32)offsetof(struct registry_priv, field))
>>>> These casts to u32 are bogus garbage. Delete them.
>>> Dunno - they might be needed (or have been needed) to stop min()
>>> complaining about type mismatch.
>>> They can also stop expressions being evaluated as 64bit (on 64bit)
>>> which may reduce code size.
>>> But that is a bit subtle...
>> Actually the macros are unused. Just delete them entirely.
> Sounds good to me :-)
>
>> regards,
>> dan carpenter
>>
© 2016 - 2025 Red Hat, Inc.