* [PATCH 0/2] Unnecessary code cleanup patches
@ 2025-04-02 23:28 Abraham Samuel Adekunle
2025-04-02 23:29 ` [PATCH 1/2] staging: media: Remove NULL test on an already tested value Abraham Samuel Adekunle
2025-04-02 23:29 ` [PATCH 2/2] staging: rtl8723bs: Prevent duplicate NULL tests on a value Abraham Samuel Adekunle
0 siblings, 2 replies; 6+ messages in thread
From: Abraham Samuel Adekunle @ 2025-04-02 23:28 UTC (permalink / raw)
To: outreachy, julia.lawall
Cc: hdegoede, mchehab, sakari.ailus, andy, gregkh, linux-staging,
linux-kernel, Abraham Samuel Adekunle
The patchset modifies unnecessary duplicate NULL test
on a value in an expression, when the value has been NULL
tested in a previous expression.
Abraham Samuel Adekunle (2):
staging: media: Remove NULL test on an already tested value
staging: rtl8723bs: Prevent duplicate NULL tests on a value
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 2 +-
drivers/staging/media/av7110/sp8870.c | 2 +-
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +-
drivers/staging/rtl8723bs/core/rtw_xmit.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] staging: media: Remove NULL test on an already tested value
2025-04-02 23:28 [PATCH 0/2] Unnecessary code cleanup patches Abraham Samuel Adekunle
@ 2025-04-02 23:29 ` Abraham Samuel Adekunle
2025-04-03 5:18 ` Andy Shevchenko
2025-04-02 23:29 ` [PATCH 2/2] staging: rtl8723bs: Prevent duplicate NULL tests on a value Abraham Samuel Adekunle
1 sibling, 1 reply; 6+ messages in thread
From: Abraham Samuel Adekunle @ 2025-04-02 23:29 UTC (permalink / raw)
To: outreachy, julia.lawall
Cc: hdegoede, mchehab, sakari.ailus, andy, gregkh, linux-staging,
linux-kernel, Abraham Samuel Adekunle
When a value has been tested for NULL in an expression, a
second NULL test on the same value in another expression
is unnecessary when the value has not been assigned NULL.
Remove unnecessary duplicate NULL tests on the same value that
has previously been NULL tested.
Found by Coccinelle
Signed-off-by: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
---
drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 2 +-
drivers/staging/media/av7110/sp8870.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
index e176483df301..0abac820299a 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
@@ -1292,7 +1292,7 @@ static int gmin_get_config_dsm_var(struct device *dev,
* if it founds something different than string, letting it
* to fall back to the old code.
*/
- if (cur && cur->type != ACPI_TYPE_STRING) {
+ if (cur->type != ACPI_TYPE_STRING) {
dev_info(dev, "found non-string _DSM entry for '%s'\n", var);
ACPI_FREE(obj);
return -EINVAL;
diff --git a/drivers/staging/media/av7110/sp8870.c b/drivers/staging/media/av7110/sp8870.c
index 0c813860f5b2..8c5fa5ed5340 100644
--- a/drivers/staging/media/av7110/sp8870.c
+++ b/drivers/staging/media/av7110/sp8870.c
@@ -508,7 +508,7 @@ static int sp8870_set_frontend(struct dvb_frontend *fe)
}
if (debug) {
- if (valid) {
+ {
if (trials > 1) {
pr_info("%s(): firmware lockup!!!\n", __func__);
pr_info("%s(): recovered after %i trial(s))\n", __func__, trials - 1);
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] staging: rtl8723bs: Prevent duplicate NULL tests on a value
2025-04-02 23:28 [PATCH 0/2] Unnecessary code cleanup patches Abraham Samuel Adekunle
2025-04-02 23:29 ` [PATCH 1/2] staging: media: Remove NULL test on an already tested value Abraham Samuel Adekunle
@ 2025-04-02 23:29 ` Abraham Samuel Adekunle
2025-04-03 5:26 ` Andy Shevchenko
1 sibling, 1 reply; 6+ messages in thread
From: Abraham Samuel Adekunle @ 2025-04-02 23:29 UTC (permalink / raw)
To: outreachy, julia.lawall
Cc: hdegoede, mchehab, sakari.ailus, andy, gregkh, linux-staging,
linux-kernel, Abraham Samuel Adekunle
When a value has been tested for NULL in an expression, a
second NULL test on the same value in another expression
is unnecessary when the value has not been assigned NULL.
Remove unnecessary duplicate NULL tests on the same value that
has previously been NULL tested.
Found by Coccinelle
Signed-off-by: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com>
---
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +-
drivers/staging/rtl8723bs/core/rtw_xmit.c | 2 +-
2 files 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 90966b7034ab..675226535cd1 100644
--- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c
@@ -1323,7 +1323,7 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame)
spin_unlock_bh(&pstapriv->asoc_list_lock);
/* now the station is qualified to join our BSS... */
- if (pstat && (pstat->state & WIFI_FW_ASSOC_SUCCESS) && (status == WLAN_STATUS_SUCCESS)) {
+ if ((pstat->state & WIFI_FW_ASSOC_SUCCESS) && (status == WLAN_STATUS_SUCCESS)) {
/* 1 bss_cap_update & sta_info_update */
bss_cap_update_on_sta_join(padapter, pstat);
sta_info_update(padapter, pstat);
diff --git a/drivers/staging/rtl8723bs/core/rtw_xmit.c b/drivers/staging/rtl8723bs/core/rtw_xmit.c
index 026061b464f7..5d5278eefabe 100644
--- a/drivers/staging/rtl8723bs/core/rtw_xmit.c
+++ b/drivers/staging/rtl8723bs/core/rtw_xmit.c
@@ -941,7 +941,7 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr
if (!(psta->state & _FW_LINKED))
return _FAIL;
- if (psta) {
+ {
psta->sta_xmitpriv.txseq_tid[pattrib->priority]++;
psta->sta_xmitpriv.txseq_tid[pattrib->priority] &= 0xFFF;
pattrib->seqnum = psta->sta_xmitpriv.txseq_tid[pattrib->priority];
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] staging: media: Remove NULL test on an already tested value
2025-04-02 23:29 ` [PATCH 1/2] staging: media: Remove NULL test on an already tested value Abraham Samuel Adekunle
@ 2025-04-03 5:18 ` Andy Shevchenko
2025-04-03 7:10 ` Samuel Abraham
0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2025-04-03 5:18 UTC (permalink / raw)
To: Abraham Samuel Adekunle
Cc: outreachy, julia.lawall, hdegoede, mchehab, sakari.ailus, andy,
gregkh, linux-staging, linux-kernel
On Thu, Apr 3, 2025 at 2:30 AM Abraham Samuel Adekunle
<abrahamadekunle50@gmail.com> wrote:
>
> When a value has been tested for NULL in an expression, a
> second NULL test on the same value in another expression
> is unnecessary when the value has not been assigned NULL.
>
> Remove unnecessary duplicate NULL tests on the same value that
> has previously been NULL tested.
> drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 2 +-
> drivers/staging/media/av7110/sp8870.c | 2 +-
Please, split this on per driver basis, as they have different
maintainers and trees to go through.
...
> --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
> +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
> @@ -1292,7 +1292,7 @@ static int gmin_get_config_dsm_var(struct device *dev,
> * if it founds something different than string, letting it
> * to fall back to the old code.
> */
> - if (cur && cur->type != ACPI_TYPE_STRING) {
> + if (cur->type != ACPI_TYPE_STRING) {
> dev_info(dev, "found non-string _DSM entry for '%s'\n", var);
> ACPI_FREE(obj);
> return -EINVAL;
This change is good.
...
> diff --git a/drivers/staging/media/av7110/sp8870.c b/drivers/staging/media/av7110/sp8870.c
> index 0c813860f5b2..8c5fa5ed5340 100644
> --- a/drivers/staging/media/av7110/sp8870.c
> +++ b/drivers/staging/media/av7110/sp8870.c
> @@ -508,7 +508,7 @@ static int sp8870_set_frontend(struct dvb_frontend *fe)
> }
>
> if (debug) {
> - if (valid) {
> + {
> if (trials > 1) {
> pr_info("%s(): firmware lockup!!!\n", __func__);
> pr_info("%s(): recovered after %i trial(s))\n", __func__, trials - 1);
But this is not fully done. Why do we need to keep {}? Just shift left
the code and remove those {} altogether.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] staging: rtl8723bs: Prevent duplicate NULL tests on a value
2025-04-02 23:29 ` [PATCH 2/2] staging: rtl8723bs: Prevent duplicate NULL tests on a value Abraham Samuel Adekunle
@ 2025-04-03 5:26 ` Andy Shevchenko
0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2025-04-03 5:26 UTC (permalink / raw)
To: Abraham Samuel Adekunle
Cc: outreachy, julia.lawall, hdegoede, mchehab, sakari.ailus, andy,
gregkh, linux-staging, linux-kernel
On Thu, Apr 3, 2025 at 2:30 AM Abraham Samuel Adekunle
<abrahamadekunle50@gmail.com> wrote:
>
> When a value has been tested for NULL in an expression, a
> second NULL test on the same value in another expression
> is unnecessary when the value has not been assigned NULL.
>
> Remove unnecessary duplicate NULL tests on the same value that
> has previously been NULL tested.
>
> Found by Coccinelle
...
> - if (psta) {
> + {
> psta->sta_xmitpriv.txseq_tid[pattrib->priority]++;
> psta->sta_xmitpriv.txseq_tid[pattrib->priority] &= 0xFFF;
> pattrib->seqnum = psta->sta_xmitpriv.txseq_tid[pattrib->priority];
Same comment, shift left and remove pointless {} altogether.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] staging: media: Remove NULL test on an already tested value
2025-04-03 5:18 ` Andy Shevchenko
@ 2025-04-03 7:10 ` Samuel Abraham
0 siblings, 0 replies; 6+ messages in thread
From: Samuel Abraham @ 2025-04-03 7:10 UTC (permalink / raw)
To: Andy Shevchenko
Cc: outreachy, julia.lawall, hdegoede, mchehab, sakari.ailus, andy,
gregkh, linux-staging, linux-kernel
On Thu, Apr 3, 2025 at 6:19 AM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
>
> On Thu, Apr 3, 2025 at 2:30 AM Abraham Samuel Adekunle
> <abrahamadekunle50@gmail.com> wrote:
> >
> > When a value has been tested for NULL in an expression, a
> > second NULL test on the same value in another expression
> > is unnecessary when the value has not been assigned NULL.
> >
> > Remove unnecessary duplicate NULL tests on the same value that
> > has previously been NULL tested.
>
> > drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 2 +-
> > drivers/staging/media/av7110/sp8870.c | 2 +-
>
> Please, split this on per driver basis, as they have different
> maintainers and trees to go through.
Thank you for your review.
I will do that.
>
> ...
>
> > --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
> > +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c
> > @@ -1292,7 +1292,7 @@ static int gmin_get_config_dsm_var(struct device *dev,
> > * if it founds something different than string, letting it
> > * to fall back to the old code.
> > */
> > - if (cur && cur->type != ACPI_TYPE_STRING) {
> > + if (cur->type != ACPI_TYPE_STRING) {
> > dev_info(dev, "found non-string _DSM entry for '%s'\n", var);
> > ACPI_FREE(obj);
> > return -EINVAL;
>
> This change is good.
>
> ...
>
> > diff --git a/drivers/staging/media/av7110/sp8870.c b/drivers/staging/media/av7110/sp8870.c
> > index 0c813860f5b2..8c5fa5ed5340 100644
> > --- a/drivers/staging/media/av7110/sp8870.c
> > +++ b/drivers/staging/media/av7110/sp8870.c
> > @@ -508,7 +508,7 @@ static int sp8870_set_frontend(struct dvb_frontend *fe)
> > }
> >
> > if (debug) {
> > - if (valid) {
> > + {
> > if (trials > 1) {
> > pr_info("%s(): firmware lockup!!!\n", __func__);
> > pr_info("%s(): recovered after %i trial(s))\n", __func__, trials - 1);
>
> But this is not fully done. Why do we need to keep {}? Just shift left
> the code and remove those {} altogether.
Okay I will effect the change.
Thanks
Adekunle
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-04-03 7:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-02 23:28 [PATCH 0/2] Unnecessary code cleanup patches Abraham Samuel Adekunle
2025-04-02 23:29 ` [PATCH 1/2] staging: media: Remove NULL test on an already tested value Abraham Samuel Adekunle
2025-04-03 5:18 ` Andy Shevchenko
2025-04-03 7:10 ` Samuel Abraham
2025-04-02 23:29 ` [PATCH 2/2] staging: rtl8723bs: Prevent duplicate NULL tests on a value Abraham Samuel Adekunle
2025-04-03 5:26 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox