linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] staging: rtl8723bs: Code cleanup patches
@ 2025-04-02 17:16 Erick Karanja
  2025-04-02 17:16 ` [PATCH v2 1/3] staging: rtl8723bs: Modify struct rx_pkt_attrib attribute bdecrypted Erick Karanja
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Erick Karanja @ 2025-04-02 17:16 UTC (permalink / raw)
  To: gregkh, outreachy
  Cc: karanja99erick, philipp.g.hortmann, linux-staging, linux-kernel

This patchset refactors the rtl8723bs driver by replacing
integer literals (1 and 0) with true and false in instances where
values are already defined with true or false but some defination
contains (1 or 0)

Changes in v2:
	- [PATCH 1/3]: Rename the subject line and improve on the subject
	  body
	- [PATCH 2/3]: Rename the subject line and improve on the subject
	  body
	- [PATCH 3/3]: Rename the subject line and improve in the
	  subject body
improving code readability and consistency with standard kernel practices.
The transformation was performed using Coccinelle.

below is the coccinelle script used:
@initialize:ocaml@
@@

let same_function p q =
  (List.hd p).Coccilib.current_element = (List.hd q).Coccilib.current_element

@r@
expression e;
position p;
symbol true,false;
@@

e =@p \(true\|false\)

@@
expression r.e;
position q : script:ocaml(r.p) { same_function p q };
@@

e =@q
(
- 1
+ true
|
- 0
+ false
)

@s@
type T;
T e;
identifier fld;
symbol true,false;
@@

e.fld = \(true\|false\)

@@
type s.T;
T e;
identifier s.fld;
@@

e.fld =
(
- 1
+ true
|
- 0
+ false
)

Erick Karanja (3):
  staging: rtl8723bs: Modify struct rx_pkt_attrib attribute bdecrypted
  staging: rtl8723bs: Modify struct sta_info attribute qos_option
  staging: rtl8723bs: Modify struct sta_info attribute qos_option and
    ieee8021x_blocked

 drivers/staging/rtl8723bs/core/rtw_ap.c       | 12 ++++++------
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c |  4 ++--
 drivers/staging/rtl8723bs/core/rtw_recv.c     |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

-- 
2.43.0


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

* [PATCH v2 1/3] staging: rtl8723bs: Modify struct rx_pkt_attrib attribute bdecrypted
  2025-04-02 17:16 [PATCH v2 0/3] staging: rtl8723bs: Code cleanup patches Erick Karanja
@ 2025-04-02 17:16 ` Erick Karanja
  2025-04-02 19:21   ` Greg KH
  2025-04-02 17:16 ` [PATCH v2 2/3] staging: rtl8723bs: Modify struct sta_info attribute qos_option Erick Karanja
  2025-04-02 17:16 ` [PATCH v2 3/3] staging: rtl8723bs: Modify struct sta_info attribute qos_option and ieee8021x_blocked Erick Karanja
  2 siblings, 1 reply; 12+ messages in thread
From: Erick Karanja @ 2025-04-02 17:16 UTC (permalink / raw)
  To: gregkh, outreachy
  Cc: karanja99erick, philipp.g.hortmann, linux-staging, linux-kernel

Standardize boolean representation by ensuring consistency,
replace instances of 1/0 with true/false where boolean logic is implied,
as some definitions already use true/false.
This improves code clarity and aligns with the kernel’s bool type usage.

Signed-off-by: Erick Karanja <karanja99erick@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_recv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
index a389ba5ecc6f..fd04dbacb50f 100644
--- a/drivers/staging/rtl8723bs/core/rtw_recv.c
+++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
@@ -1358,7 +1358,7 @@ static signed int validate_80211w_mgmt(struct adapter *adapter, union recv_frame
 			u8 *mgmt_DATA;
 			u32 data_len = 0;
 
-			pattrib->bdecrypted = 0;
+			pattrib->bdecrypted = false;
 			pattrib->encrypt = _AES_;
 			pattrib->hdrlen = sizeof(struct ieee80211_hdr_3addr);
 			/* set iv and icv length */
-- 
2.43.0


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

* [PATCH v2 2/3] staging: rtl8723bs: Modify struct sta_info attribute qos_option
  2025-04-02 17:16 [PATCH v2 0/3] staging: rtl8723bs: Code cleanup patches Erick Karanja
  2025-04-02 17:16 ` [PATCH v2 1/3] staging: rtl8723bs: Modify struct rx_pkt_attrib attribute bdecrypted Erick Karanja
@ 2025-04-02 17:16 ` Erick Karanja
  2025-04-02 17:16 ` [PATCH v2 3/3] staging: rtl8723bs: Modify struct sta_info attribute qos_option and ieee8021x_blocked Erick Karanja
  2 siblings, 0 replies; 12+ messages in thread
From: Erick Karanja @ 2025-04-02 17:16 UTC (permalink / raw)
  To: gregkh, outreachy
  Cc: karanja99erick, philipp.g.hortmann, linux-staging, linux-kernel

Standardize boolean representation by ensuring consistency,
replacing instances of 1/0 with true/false where boolean logic
is implied, as some definitions already use true/false.
This improves code clarity and aligns with the kernel’s bool type usage.

Signed-off-by: Erick Karanja <karanja99erick@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
index 952ce6dd5af9..8f2c9c3e853c 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -1173,7 +1173,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
 
 	/*  check if there is WMM IE & support WWM-PS */
 	pstat->flags &= ~WLAN_STA_WME;
-	pstat->qos_option = 0;
+	pstat->qos_option = false;
 	pstat->qos_info = 0;
 	pstat->has_legacy_ac = true;
 	pstat->uapsd_vo = 0;
@@ -1189,7 +1189,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
 
 					pstat->flags |= WLAN_STA_WME;
 
-					pstat->qos_option = 1;
+					pstat->qos_option = true;
 					pstat->qos_info = *(p+8);
 
 					pstat->max_sp_len = (pstat->qos_info>>5)&0x3;
-- 
2.43.0


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

* [PATCH v2 3/3] staging: rtl8723bs: Modify struct sta_info attribute qos_option and ieee8021x_blocked
  2025-04-02 17:16 [PATCH v2 0/3] staging: rtl8723bs: Code cleanup patches Erick Karanja
  2025-04-02 17:16 ` [PATCH v2 1/3] staging: rtl8723bs: Modify struct rx_pkt_attrib attribute bdecrypted Erick Karanja
  2025-04-02 17:16 ` [PATCH v2 2/3] staging: rtl8723bs: Modify struct sta_info attribute qos_option Erick Karanja
@ 2025-04-02 17:16 ` Erick Karanja
  2 siblings, 0 replies; 12+ messages in thread
From: Erick Karanja @ 2025-04-02 17:16 UTC (permalink / raw)
  To: gregkh, outreachy
  Cc: karanja99erick, philipp.g.hortmann, linux-staging, linux-kernel

Standardize boolean representation by ensuring consistency,
replacing instances of 1/0 with true/false where boolean
logic is implied, as some definitions already use true/false.
This improves code clarity and aligns with the kernel’s bool type usage.

Signed-off-by: Erick Karanja <karanja99erick@gmail.com>
---
 drivers/staging/rtl8723bs/core/rtw_ap.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c
index d46a04b9a05e..199727f04516 100644
--- a/drivers/staging/rtl8723bs/core/rtw_ap.c
+++ b/drivers/staging/rtl8723bs/core/rtw_ap.c
@@ -386,10 +386,10 @@ void update_bmc_sta(struct adapter *padapter)
 
 		pmlmeinfo->FW_sta_info[psta->mac_id].psta = psta;
 
-		psta->qos_option = 0;
+		psta->qos_option = false;
 		psta->htpriv.ht_option = false;
 
-		psta->ieee8021x_blocked = 0;
+		psta->ieee8021x_blocked = false;
 
 		memset((void *)&psta->sta_stats, 0, sizeof(struct stainfo_stats));
 
@@ -1967,17 +1967,17 @@ void sta_info_update(struct adapter *padapter, struct sta_info *psta)
 
 	/* update wmm cap. */
 	if (WLAN_STA_WME & flags)
-		psta->qos_option = 1;
+		psta->qos_option = true;
 	else
-		psta->qos_option = 0;
+		psta->qos_option = false;
 
 	if (pmlmepriv->qospriv.qos_option == 0)
-		psta->qos_option = 0;
+		psta->qos_option = false;
 
 	/* update 802.11n ht cap. */
 	if (WLAN_STA_HT & flags) {
 		psta->htpriv.ht_option = true;
-		psta->qos_option = 1;
+		psta->qos_option = true;
 	} else {
 		psta->htpriv.ht_option = false;
 	}
-- 
2.43.0


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

* Re: [PATCH v2 1/3] staging: rtl8723bs: Modify struct rx_pkt_attrib attribute bdecrypted
  2025-04-02 17:16 ` [PATCH v2 1/3] staging: rtl8723bs: Modify struct rx_pkt_attrib attribute bdecrypted Erick Karanja
@ 2025-04-02 19:21   ` Greg KH
  2025-04-02 20:34     ` Julia Lawall
  0 siblings, 1 reply; 12+ messages in thread
From: Greg KH @ 2025-04-02 19:21 UTC (permalink / raw)
  To: Erick Karanja; +Cc: outreachy, philipp.g.hortmann, linux-staging, linux-kernel

On Wed, Apr 02, 2025 at 08:16:42PM +0300, Erick Karanja wrote:
> Standardize boolean representation by ensuring consistency,
> replace instances of 1/0 with true/false where boolean logic is implied,
> as some definitions already use true/false.
> This improves code clarity and aligns with the kernel’s bool type usage.
> 
> Signed-off-by: Erick Karanja <karanja99erick@gmail.com>
> ---
>  drivers/staging/rtl8723bs/core/rtw_recv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
> index a389ba5ecc6f..fd04dbacb50f 100644
> --- a/drivers/staging/rtl8723bs/core/rtw_recv.c
> +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
> @@ -1358,7 +1358,7 @@ static signed int validate_80211w_mgmt(struct adapter *adapter, union recv_frame
>  			u8 *mgmt_DATA;
>  			u32 data_len = 0;
>  
> -			pattrib->bdecrypted = 0;
> +			pattrib->bdecrypted = false;

but bdecrypted is a u8, not a boolean type.  So setting it to "false"
does not seem correct here, right?

Also, the name of the variable should really be changed.

But, step back, are you _SURE_ you can change this structure at all?
At a quick glance it kind of looks like it comes directly from the
hardware, or am I mis-reading the driver code?

Have you tested this series on an actual device?

thanks,

greg k-h

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

* Re: [PATCH v2 1/3] staging: rtl8723bs: Modify struct rx_pkt_attrib attribute bdecrypted
  2025-04-02 19:21   ` Greg KH
@ 2025-04-02 20:34     ` Julia Lawall
  2025-04-02 20:41       ` Greg KH
  0 siblings, 1 reply; 12+ messages in thread
From: Julia Lawall @ 2025-04-02 20:34 UTC (permalink / raw)
  To: Greg KH
  Cc: Erick Karanja, outreachy, philipp.g.hortmann, linux-staging,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1556 bytes --]



On Wed, 2 Apr 2025, Greg KH wrote:

> On Wed, Apr 02, 2025 at 08:16:42PM +0300, Erick Karanja wrote:
> > Standardize boolean representation by ensuring consistency,
> > replace instances of 1/0 with true/false where boolean logic is implied,
> > as some definitions already use true/false.
> > This improves code clarity and aligns with the kernel’s bool type usage.
> >
> > Signed-off-by: Erick Karanja <karanja99erick@gmail.com>
> > ---
> >  drivers/staging/rtl8723bs/core/rtw_recv.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
> > index a389ba5ecc6f..fd04dbacb50f 100644
> > --- a/drivers/staging/rtl8723bs/core/rtw_recv.c
> > +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
> > @@ -1358,7 +1358,7 @@ static signed int validate_80211w_mgmt(struct adapter *adapter, union recv_frame
> >  			u8 *mgmt_DATA;
> >  			u32 data_len = 0;
> >
> > -			pattrib->bdecrypted = 0;
> > +			pattrib->bdecrypted = false;
>
> but bdecrypted is a u8, not a boolean type.  So setting it to "false"
> does not seem correct here, right?

Is false different than 0?

Elsewhere there is an assignment to true.

julia

>
> Also, the name of the variable should really be changed.
>
> But, step back, are you _SURE_ you can change this structure at all?
> At a quick glance it kind of looks like it comes directly from the
> hardware, or am I mis-reading the driver code?
>
> Have you tested this series on an actual device?
>
> thanks,
>
> greg k-h
>
>

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

* Re: [PATCH v2 1/3] staging: rtl8723bs: Modify struct rx_pkt_attrib attribute bdecrypted
  2025-04-02 20:34     ` Julia Lawall
@ 2025-04-02 20:41       ` Greg KH
  2025-04-02 21:02         ` Julia Lawall
                           ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Greg KH @ 2025-04-02 20:41 UTC (permalink / raw)
  To: Julia Lawall
  Cc: Erick Karanja, outreachy, philipp.g.hortmann, linux-staging,
	linux-kernel

On Wed, Apr 02, 2025 at 10:34:22PM +0200, Julia Lawall wrote:
> 
> 
> On Wed, 2 Apr 2025, Greg KH wrote:
> 
> > On Wed, Apr 02, 2025 at 08:16:42PM +0300, Erick Karanja wrote:
> > > Standardize boolean representation by ensuring consistency,
> > > replace instances of 1/0 with true/false where boolean logic is implied,
> > > as some definitions already use true/false.
> > > This improves code clarity and aligns with the kernel’s bool type usage.
> > >
> > > Signed-off-by: Erick Karanja <karanja99erick@gmail.com>
> > > ---
> > >  drivers/staging/rtl8723bs/core/rtw_recv.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
> > > index a389ba5ecc6f..fd04dbacb50f 100644
> > > --- a/drivers/staging/rtl8723bs/core/rtw_recv.c
> > > +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
> > > @@ -1358,7 +1358,7 @@ static signed int validate_80211w_mgmt(struct adapter *adapter, union recv_frame
> > >  			u8 *mgmt_DATA;
> > >  			u32 data_len = 0;
> > >
> > > -			pattrib->bdecrypted = 0;
> > > +			pattrib->bdecrypted = false;
> >
> > but bdecrypted is a u8, not a boolean type.  So setting it to "false"
> > does not seem correct here, right?
> 
> Is false different than 0?

Does C guarantee that?  I can never remember.  I don't think it
guarantees that a 'bool' will only be 8 bits, or am I mistaken there
too?

> Elsewhere there is an assignment to true.

Was that in the original driver?

If this doesn't come from the hardware, then it's fine to make the
change.  If it does, it needs to be verified that the layout and bit
values are identical.

thanks,

greg k-h

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

* Re: [PATCH v2 1/3] staging: rtl8723bs: Modify struct rx_pkt_attrib attribute bdecrypted
  2025-04-02 20:41       ` Greg KH
@ 2025-04-02 21:02         ` Julia Lawall
  2025-04-03 12:13         ` Dan Carpenter
  2025-04-04  6:58         ` Erick Karanja
  2 siblings, 0 replies; 12+ messages in thread
From: Julia Lawall @ 2025-04-02 21:02 UTC (permalink / raw)
  To: Greg KH
  Cc: Julia Lawall, Erick Karanja, outreachy, philipp.g.hortmann,
	linux-staging, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2113 bytes --]



On Wed, 2 Apr 2025, Greg KH wrote:

> On Wed, Apr 02, 2025 at 10:34:22PM +0200, Julia Lawall wrote:
> >
> >
> > On Wed, 2 Apr 2025, Greg KH wrote:
> >
> > > On Wed, Apr 02, 2025 at 08:16:42PM +0300, Erick Karanja wrote:
> > > > Standardize boolean representation by ensuring consistency,
> > > > replace instances of 1/0 with true/false where boolean logic is implied,
> > > > as some definitions already use true/false.
> > > > This improves code clarity and aligns with the kernel’s bool type usage.
> > > >
> > > > Signed-off-by: Erick Karanja <karanja99erick@gmail.com>
> > > > ---
> > > >  drivers/staging/rtl8723bs/core/rtw_recv.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
> > > > index a389ba5ecc6f..fd04dbacb50f 100644
> > > > --- a/drivers/staging/rtl8723bs/core/rtw_recv.c
> > > > +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
> > > > @@ -1358,7 +1358,7 @@ static signed int validate_80211w_mgmt(struct adapter *adapter, union recv_frame
> > > >  			u8 *mgmt_DATA;
> > > >  			u32 data_len = 0;
> > > >
> > > > -			pattrib->bdecrypted = 0;
> > > > +			pattrib->bdecrypted = false;
> > >
> > > but bdecrypted is a u8, not a boolean type.  So setting it to "false"
> > > does not seem correct here, right?
> >
> > Is false different than 0?
>
> Does C guarantee that?  I can never remember.  I don't think it
> guarantees that a 'bool' will only be 8 bits, or am I mistaken there
> too?
>
> > Elsewhere there is an assignment to true.
>
> Was that in the original driver?

Yes:

git blame -L 436,436 drivers/staging/rtl8723bs/core/rtw_recv.c

554c0a3abf216 (Hans de Goede 2017-03-29 19:47:51 +0200 436)
prxattrib->bdecrypted = true;

> If this doesn't come from the hardware, then it's fine to make the
> change.  If it does, it needs to be verified that the layout and bit
> values are identical.

Erick, you can see if the generated assembly code is the same before and
after the same.  You can see that with
make drivers/staging/rtl8723bs/core/rtw_recv.s

julia

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

* Re: [PATCH v2 1/3] staging: rtl8723bs: Modify struct rx_pkt_attrib attribute bdecrypted
  2025-04-02 20:41       ` Greg KH
  2025-04-02 21:02         ` Julia Lawall
@ 2025-04-03 12:13         ` Dan Carpenter
  2025-04-04  6:58         ` Erick Karanja
  2 siblings, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2025-04-03 12:13 UTC (permalink / raw)
  To: Greg KH
  Cc: Julia Lawall, Erick Karanja, outreachy, philipp.g.hortmann,
	linux-staging, linux-kernel

On Wed, Apr 02, 2025 at 09:41:57PM +0100, Greg KH wrote:
> On Wed, Apr 02, 2025 at 10:34:22PM +0200, Julia Lawall wrote:
> > 
> > 
> > On Wed, 2 Apr 2025, Greg KH wrote:
> > 
> > > On Wed, Apr 02, 2025 at 08:16:42PM +0300, Erick Karanja wrote:
> > > > Standardize boolean representation by ensuring consistency,
> > > > replace instances of 1/0 with true/false where boolean logic is implied,
> > > > as some definitions already use true/false.
> > > > This improves code clarity and aligns with the kernel’s bool type usage.
> > > >
> > > > Signed-off-by: Erick Karanja <karanja99erick@gmail.com>
> > > > ---
> > > >  drivers/staging/rtl8723bs/core/rtw_recv.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c
> > > > index a389ba5ecc6f..fd04dbacb50f 100644
> > > > --- a/drivers/staging/rtl8723bs/core/rtw_recv.c
> > > > +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
> > > > @@ -1358,7 +1358,7 @@ static signed int validate_80211w_mgmt(struct adapter *adapter, union recv_frame
> > > >  			u8 *mgmt_DATA;
> > > >  			u32 data_len = 0;
> > > >
> > > > -			pattrib->bdecrypted = 0;
> > > > +			pattrib->bdecrypted = false;
> > >
> > > but bdecrypted is a u8, not a boolean type.  So setting it to "false"
> > > does not seem correct here, right?
> > 
> > Is false different than 0?
> 
> Does C guarantee that?  I can never remember.  I don't think it
> guarantees that a 'bool' will only be 8 bits, or am I mistaken there
> too?
> 

These patches are fine.  This does come from the hardware but the
patches don't change the layout of the struct, just the right
hand side of the assignment.

The C standard doesn't specify the size of _Bool.  It just has to
be unsigned and at least one bit large.  The surprising thing about
_Bool type is that it doesn't truncate anything.  So you can do:
"_Bool x = y & BIT(20);" and it works, but if we use unsigned char
then we would have to add a !!.  "unsigned char x = !!(y & BIT(20));"

Btw, true/false are not keywords in C.  They're defined in
include/linux/stddef.h.

The main review here is if there is a typo where we accidentally type
true instead of false.

regards,
dan carpenter


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

* Re: [PATCH v2 1/3] staging: rtl8723bs: Modify struct rx_pkt_attrib attribute bdecrypted
  2025-04-02 20:41       ` Greg KH
  2025-04-02 21:02         ` Julia Lawall
  2025-04-03 12:13         ` Dan Carpenter
@ 2025-04-04  6:58         ` Erick Karanja
  2025-04-04  8:00           ` Greg KH
  2 siblings, 1 reply; 12+ messages in thread
From: Erick Karanja @ 2025-04-04  6:58 UTC (permalink / raw)
  To: Greg KH, Julia Lawall
  Cc: outreachy, philipp.g.hortmann, linux-staging, linux-kernel

On Wed, 2025-04-02 at 21:41 +0100, Greg KH wrote:
> On Wed, Apr 02, 2025 at 10:34:22PM +0200, Julia Lawall wrote:
> > 
> > 
> > On Wed, 2 Apr 2025, Greg KH wrote:
> > 
> > > On Wed, Apr 02, 2025 at 08:16:42PM +0300, Erick Karanja wrote:
> > > > Standardize boolean representation by ensuring consistency,
> > > > replace instances of 1/0 with true/false where boolean logic is
> > > > implied,
> > > > as some definitions already use true/false.
> > > > This improves code clarity and aligns with the kernel’s bool
> > > > type usage.
> > > > 
> > > > Signed-off-by: Erick Karanja <karanja99erick@gmail.com>
> > > > ---
> > > >  drivers/staging/rtl8723bs/core/rtw_recv.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > 
> > > > diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c
> > > > b/drivers/staging/rtl8723bs/core/rtw_recv.c
> > > > index a389ba5ecc6f..fd04dbacb50f 100644
> > > > --- a/drivers/staging/rtl8723bs/core/rtw_recv.c
> > > > +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
> > > > @@ -1358,7 +1358,7 @@ static signed int
> > > > validate_80211w_mgmt(struct adapter *adapter, union recv_frame
> > > >  			u8 *mgmt_DATA;
> > > >  			u32 data_len = 0;
> > > > 
> > > > -			pattrib->bdecrypted = 0;
> > > > +			pattrib->bdecrypted = false;
> > > 
> > > but bdecrypted is a u8, not a boolean type.  So setting it to
> > > "false"
> > > does not seem correct here, right?
> > 
> > Is false different than 0?
> 
> Does C guarantee that?  I can never remember.  I don't think it
> guarantees that a 'bool' will only be 8 bits, or am I mistaken there
> too?
> 
> > Elsewhere there is an assignment to true.
> 
> Was that in the original driver?
> 
> If this doesn't come from the hardware, then it's fine to make the
> change.  If it does, it needs to be verified that the layout and bit
> values are identical.
> 
> thanks,
I have compared the generated assembly code
before and after and I have observed the only
change is the comment below.
-# drivers/staging/rtl8723bs/core/rtw_recv.c:1361:
 			pattrib->bdecrypted = 0;
+# drivers/staging/rtl8723bs/core/rtw_recv.c:1361:
 			pattrib->bdecrypted = false;
There is no change in the assembly instructions.

> 
> greg k-h


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

* Re: [PATCH v2 1/3] staging: rtl8723bs: Modify struct rx_pkt_attrib attribute bdecrypted
  2025-04-04  6:58         ` Erick Karanja
@ 2025-04-04  8:00           ` Greg KH
  2025-04-04  8:21             ` Erick Karanja
  0 siblings, 1 reply; 12+ messages in thread
From: Greg KH @ 2025-04-04  8:00 UTC (permalink / raw)
  To: Erick Karanja
  Cc: Julia Lawall, outreachy, philipp.g.hortmann, linux-staging,
	linux-kernel

On Fri, Apr 04, 2025 at 09:58:23AM +0300, Erick Karanja wrote:
> On Wed, 2025-04-02 at 21:41 +0100, Greg KH wrote:
> > On Wed, Apr 02, 2025 at 10:34:22PM +0200, Julia Lawall wrote:
> > > 
> > > 
> > > On Wed, 2 Apr 2025, Greg KH wrote:
> > > 
> > > > On Wed, Apr 02, 2025 at 08:16:42PM +0300, Erick Karanja wrote:
> > > > > Standardize boolean representation by ensuring consistency,
> > > > > replace instances of 1/0 with true/false where boolean logic is
> > > > > implied,
> > > > > as some definitions already use true/false.
> > > > > This improves code clarity and aligns with the kernel’s bool
> > > > > type usage.
> > > > > 
> > > > > Signed-off-by: Erick Karanja <karanja99erick@gmail.com>
> > > > > ---
> > > > >  drivers/staging/rtl8723bs/core/rtw_recv.c | 2 +-
> > > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > > 
> > > > > diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c
> > > > > b/drivers/staging/rtl8723bs/core/rtw_recv.c
> > > > > index a389ba5ecc6f..fd04dbacb50f 100644
> > > > > --- a/drivers/staging/rtl8723bs/core/rtw_recv.c
> > > > > +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
> > > > > @@ -1358,7 +1358,7 @@ static signed int
> > > > > validate_80211w_mgmt(struct adapter *adapter, union recv_frame
> > > > >  			u8 *mgmt_DATA;
> > > > >  			u32 data_len = 0;
> > > > > 
> > > > > -			pattrib->bdecrypted = 0;
> > > > > +			pattrib->bdecrypted = false;
> > > > 
> > > > but bdecrypted is a u8, not a boolean type.  So setting it to
> > > > "false"
> > > > does not seem correct here, right?
> > > 
> > > Is false different than 0?
> > 
> > Does C guarantee that?  I can never remember.  I don't think it
> > guarantees that a 'bool' will only be 8 bits, or am I mistaken there
> > too?
> > 
> > > Elsewhere there is an assignment to true.
> > 
> > Was that in the original driver?
> > 
> > If this doesn't come from the hardware, then it's fine to make the
> > change.  If it does, it needs to be verified that the layout and bit
> > values are identical.
> > 
> > thanks,
> I have compared the generated assembly code
> before and after and I have observed the only
> change is the comment below.
> -# drivers/staging/rtl8723bs/core/rtw_recv.c:1361:
>  			pattrib->bdecrypted = 0;
> +# drivers/staging/rtl8723bs/core/rtw_recv.c:1361:
>  			pattrib->bdecrypted = false;
> There is no change in the assembly instructions.

Showing the assembly is key, not just a comment :)

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

* Re: [PATCH v2 1/3] staging: rtl8723bs: Modify struct rx_pkt_attrib attribute bdecrypted
  2025-04-04  8:00           ` Greg KH
@ 2025-04-04  8:21             ` Erick Karanja
  0 siblings, 0 replies; 12+ messages in thread
From: Erick Karanja @ 2025-04-04  8:21 UTC (permalink / raw)
  To: Greg KH
  Cc: Julia Lawall, outreachy, philipp.g.hortmann, linux-staging,
	linux-kernel

On Fri, 2025-04-04 at 09:00 +0100, Greg KH wrote:
> On Fri, Apr 04, 2025 at 09:58:23AM +0300, Erick Karanja wrote:
> > On Wed, 2025-04-02 at 21:41 +0100, Greg KH wrote:
> > > On Wed, Apr 02, 2025 at 10:34:22PM +0200, Julia Lawall wrote:
> > > > 
> > > > 
> > > > On Wed, 2 Apr 2025, Greg KH wrote:
> > > > 
> > > > > On Wed, Apr 02, 2025 at 08:16:42PM +0300, Erick Karanja
> > > > > wrote:
> > > > > > Standardize boolean representation by ensuring consistency,
> > > > > > replace instances of 1/0 with true/false where boolean
> > > > > > logic is
> > > > > > implied,
> > > > > > as some definitions already use true/false.
> > > > > > This improves code clarity and aligns with the kernel’s
> > > > > > bool
> > > > > > type usage.
> > > > > > 
> > > > > > Signed-off-by: Erick Karanja <karanja99erick@gmail.com>
> > > > > > ---
> > > > > >  drivers/staging/rtl8723bs/core/rtw_recv.c | 2 +-
> > > > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > > > 
> > > > > > diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c
> > > > > > b/drivers/staging/rtl8723bs/core/rtw_recv.c
> > > > > > index a389ba5ecc6f..fd04dbacb50f 100644
> > > > > > --- a/drivers/staging/rtl8723bs/core/rtw_recv.c
> > > > > > +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c
> > > > > > @@ -1358,7 +1358,7 @@ static signed int
> > > > > > validate_80211w_mgmt(struct adapter *adapter, union
> > > > > > recv_frame
> > > > > >  			u8 *mgmt_DATA;
> > > > > >  			u32 data_len = 0;
> > > > > > 
> > > > > > -			pattrib->bdecrypted = 0;
> > > > > > +			pattrib->bdecrypted = false;
> > > > > 
> > > > > but bdecrypted is a u8, not a boolean type.  So setting it to
> > > > > "false"
> > > > > does not seem correct here, right?
> > > > 
> > > > Is false different than 0?
> > > 
> > > Does C guarantee that?  I can never remember.  I don't think it
> > > guarantees that a 'bool' will only be 8 bits, or am I mistaken
> > > there
> > > too?
> > > 
> > > > Elsewhere there is an assignment to true.
> > > 
> > > Was that in the original driver?
> > > 
> > > If this doesn't come from the hardware, then it's fine to make
> > > the
> > > change.  If it does, it needs to be verified that the layout and
> > > bit
> > > values are identical.
> > > 
> > > thanks,
> > I have compared the generated assembly code
> > before and after and I have observed the only
> > change is the comment below.
> > -# drivers/staging/rtl8723bs/core/rtw_recv.c:1361:
> >  			pattrib->bdecrypted = 0;
> > +# drivers/staging/rtl8723bs/core/rtw_recv.c:1361:
> >  			pattrib->bdecrypted = false;
> > There is no change in the assembly instructions.
> 
> Showing the assembly is key, not just a comment :)
Thank you for the update. I will take this into consideration.
Erick

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

end of thread, other threads:[~2025-04-04  8:21 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-02 17:16 [PATCH v2 0/3] staging: rtl8723bs: Code cleanup patches Erick Karanja
2025-04-02 17:16 ` [PATCH v2 1/3] staging: rtl8723bs: Modify struct rx_pkt_attrib attribute bdecrypted Erick Karanja
2025-04-02 19:21   ` Greg KH
2025-04-02 20:34     ` Julia Lawall
2025-04-02 20:41       ` Greg KH
2025-04-02 21:02         ` Julia Lawall
2025-04-03 12:13         ` Dan Carpenter
2025-04-04  6:58         ` Erick Karanja
2025-04-04  8:00           ` Greg KH
2025-04-04  8:21             ` Erick Karanja
2025-04-02 17:16 ` [PATCH v2 2/3] staging: rtl8723bs: Modify struct sta_info attribute qos_option Erick Karanja
2025-04-02 17:16 ` [PATCH v2 3/3] staging: rtl8723bs: Modify struct sta_info attribute qos_option and ieee8021x_blocked Erick Karanja

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).