1 | The patchset modifies unnecessary duplicate NULL test | 1 | The patchset modifies unnecessary duplicate NULL tests on a value in an |
---|---|---|---|
2 | on a value in an expression, when the value has been NULL | 2 | expression, when the value has been NULL tested in a previous expression. |
3 | tested in a previous expression. | ||
4 | 3 | ||
5 | Abraham Samuel Adekunle (2): | 4 | - Changes in v3: |
6 | staging: media: Remove NULL test on an already tested value | 5 | - Changed other cases to use modulo (% 4096) over (& 0xfff). |
6 | - Modified commit message to reflect these changes. | ||
7 | - Changes in v2: | ||
8 | - Dropped patch files for media drivers from patchset as it is | ||
9 | not meant for outreachy applicants. | ||
10 | - Added full-stop sign to text in commit message. | ||
11 | - Made code more readable by adding a line break. | ||
12 | - Changed cases to use modulo (% 4096) over (& 0xff). | ||
13 | - Changes in v1 | ||
14 | - Patch for drivers/staging/media/av7110/sp8870.c and | ||
15 | drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | ||
16 | is split into two different patches in the patchset for use by the different | ||
17 | driver maintainers. | ||
18 | - Added subject title for each of the separated patches. | ||
19 | - Patch 1: Removed unnecessary curly braces {} initially inserted. | ||
20 | - Patch 2: Unnecessary {} was also removed for v1. | ||
21 | |||
22 | Abraham Samuel Adekunle (1): | ||
7 | staging: rtl8723bs: Prevent duplicate NULL tests on a value | 23 | staging: rtl8723bs: Prevent duplicate NULL tests on a value |
8 | 24 | ||
9 | drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 2 +- | 25 | drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +- |
10 | drivers/staging/media/av7110/sp8870.c | 2 +- | 26 | drivers/staging/rtl8723bs/core/rtw_xmit.c | 58 +++++++++---------- |
11 | drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +- | 27 | 2 files changed, 30 insertions(+), 30 deletions(-) |
12 | drivers/staging/rtl8723bs/core/rtw_xmit.c | 2 +- | ||
13 | 4 files changed, 4 insertions(+), 4 deletions(-) | ||
14 | 28 | ||
15 | -- | 29 | -- |
16 | 2.34.1 | 30 | 2.34.1 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | When a value has been tested for NULL in an expression, a | ||
2 | second NULL test on the same value in another expression | ||
3 | is unnecessary when the value has not been assigned NULL. | ||
4 | 1 | ||
5 | Remove unnecessary duplicate NULL tests on the same value that | ||
6 | has previously been NULL tested. | ||
7 | |||
8 | Found by Coccinelle | ||
9 | |||
10 | Signed-off-by: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com> | ||
11 | --- | ||
12 | drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 2 +- | ||
13 | drivers/staging/media/av7110/sp8870.c | 2 +- | ||
14 | 2 files changed, 2 insertions(+), 2 deletions(-) | ||
15 | |||
16 | diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | ||
17 | index XXXXXXX..XXXXXXX 100644 | ||
18 | --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | ||
19 | +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | ||
20 | @@ -XXX,XX +XXX,XX @@ static int gmin_get_config_dsm_var(struct device *dev, | ||
21 | * if it founds something different than string, letting it | ||
22 | * to fall back to the old code. | ||
23 | */ | ||
24 | - if (cur && cur->type != ACPI_TYPE_STRING) { | ||
25 | + if (cur->type != ACPI_TYPE_STRING) { | ||
26 | dev_info(dev, "found non-string _DSM entry for '%s'\n", var); | ||
27 | ACPI_FREE(obj); | ||
28 | return -EINVAL; | ||
29 | diff --git a/drivers/staging/media/av7110/sp8870.c b/drivers/staging/media/av7110/sp8870.c | ||
30 | index XXXXXXX..XXXXXXX 100644 | ||
31 | --- a/drivers/staging/media/av7110/sp8870.c | ||
32 | +++ b/drivers/staging/media/av7110/sp8870.c | ||
33 | @@ -XXX,XX +XXX,XX @@ static int sp8870_set_frontend(struct dvb_frontend *fe) | ||
34 | } | ||
35 | |||
36 | if (debug) { | ||
37 | - if (valid) { | ||
38 | + { | ||
39 | if (trials > 1) { | ||
40 | pr_info("%s(): firmware lockup!!!\n", __func__); | ||
41 | pr_info("%s(): recovered after %i trial(s))\n", __func__, trials - 1); | ||
42 | -- | ||
43 | 2.34.1 | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
3 | is unnecessary when the value has not been assigned NULL. | 3 | is unnecessary when the value has not been assigned NULL. |
4 | 4 | ||
5 | Remove unnecessary duplicate NULL tests on the same value that | 5 | Remove unnecessary duplicate NULL tests on the same value that |
6 | has previously been NULL tested. | 6 | has previously been NULL tested. |
7 | 7 | ||
8 | Found by Coccinelle | 8 | While at it, convert '& 0xfff' cases to use modulo operator and |
9 | decimal number to make the upper limit visible and clear what the | ||
10 | semantic of it is. | ||
11 | |||
12 | Found by Coccinelle. | ||
9 | 13 | ||
10 | Signed-off-by: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com> | 14 | Signed-off-by: Abraham Samuel Adekunle <abrahamadekunle50@gmail.com> |
11 | --- | 15 | --- |
12 | drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +- | 16 | drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +- |
13 | drivers/staging/rtl8723bs/core/rtw_xmit.c | 2 +- | 17 | drivers/staging/rtl8723bs/core/rtw_xmit.c | 58 +++++++++---------- |
14 | 2 files changed, 2 insertions(+), 2 deletions(-) | 18 | 2 files changed, 30 insertions(+), 30 deletions(-) |
15 | 19 | ||
16 | diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 20 | diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c |
17 | index XXXXXXX..XXXXXXX 100644 | 21 | index XXXXXXX..XXXXXXX 100644 |
18 | --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 22 | --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c |
19 | +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 23 | +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c |
... | ... | ||
33 | @@ -XXX,XX +XXX,XX @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr | 37 | @@ -XXX,XX +XXX,XX @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr |
34 | if (!(psta->state & _FW_LINKED)) | 38 | if (!(psta->state & _FW_LINKED)) |
35 | return _FAIL; | 39 | return _FAIL; |
36 | 40 | ||
37 | - if (psta) { | 41 | - if (psta) { |
38 | + { | 42 | - psta->sta_xmitpriv.txseq_tid[pattrib->priority]++; |
39 | psta->sta_xmitpriv.txseq_tid[pattrib->priority]++; | 43 | - psta->sta_xmitpriv.txseq_tid[pattrib->priority] &= 0xFFF; |
40 | psta->sta_xmitpriv.txseq_tid[pattrib->priority] &= 0xFFF; | 44 | - pattrib->seqnum = psta->sta_xmitpriv.txseq_tid[pattrib->priority]; |
41 | pattrib->seqnum = psta->sta_xmitpriv.txseq_tid[pattrib->priority]; | 45 | - |
46 | - SetSeqNum(hdr, pattrib->seqnum); | ||
47 | - | ||
48 | - /* check if enable ampdu */ | ||
49 | - if (pattrib->ht_en && psta->htpriv.ampdu_enable) | ||
50 | - if (psta->htpriv.agg_enable_bitmap & BIT(pattrib->priority)) | ||
51 | - pattrib->ampdu_en = true; | ||
52 | - | ||
53 | - /* re-check if enable ampdu by BA_starting_seqctrl */ | ||
54 | - if (pattrib->ampdu_en == true) { | ||
55 | - u16 tx_seq; | ||
56 | - | ||
57 | - tx_seq = psta->BA_starting_seqctrl[pattrib->priority & 0x0f]; | ||
58 | - | ||
59 | - /* check BA_starting_seqctrl */ | ||
60 | - if (SN_LESS(pattrib->seqnum, tx_seq)) { | ||
61 | - pattrib->ampdu_en = false;/* AGG BK */ | ||
62 | - } else if (SN_EQUAL(pattrib->seqnum, tx_seq)) { | ||
63 | - psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (tx_seq+1)&0xfff; | ||
64 | - | ||
65 | - pattrib->ampdu_en = true;/* AGG EN */ | ||
66 | - } else { | ||
67 | - psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (pattrib->seqnum+1)&0xfff; | ||
68 | - pattrib->ampdu_en = true;/* AGG EN */ | ||
69 | - } | ||
70 | + psta->sta_xmitpriv.txseq_tid[pattrib->priority]++; | ||
71 | + psta->sta_xmitpriv.txseq_tid[pattrib->priority] &= 0xFFF; | ||
72 | + pattrib->seqnum = psta->sta_xmitpriv.txseq_tid[pattrib->priority]; | ||
73 | + | ||
74 | + SetSeqNum(hdr, pattrib->seqnum); | ||
75 | + | ||
76 | + /* check if enable ampdu */ | ||
77 | + if (pattrib->ht_en && psta->htpriv.ampdu_enable) | ||
78 | + if (psta->htpriv.agg_enable_bitmap & BIT(pattrib->priority)) | ||
79 | + pattrib->ampdu_en = true; | ||
80 | + | ||
81 | + /* re-check if enable ampdu by BA_starting_seqctrl */ | ||
82 | + if (pattrib->ampdu_en == true) { | ||
83 | + u16 tx_seq; | ||
84 | + | ||
85 | + tx_seq = psta->BA_starting_seqctrl[pattrib->priority & 0x0f]; | ||
86 | + | ||
87 | + /* check BA_starting_seqctrl */ | ||
88 | + if (SN_LESS(pattrib->seqnum, tx_seq)) { | ||
89 | + pattrib->ampdu_en = false;/* AGG BK */ | ||
90 | + } else if (SN_EQUAL(pattrib->seqnum, tx_seq)) { | ||
91 | + psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = | ||
92 | + (tx_seq + 1) % 4096; | ||
93 | + | ||
94 | + pattrib->ampdu_en = true;/* AGG EN */ | ||
95 | + } else { | ||
96 | + psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = | ||
97 | + (pattrib->seqnum + 1) % 4096; | ||
98 | + pattrib->ampdu_en = true;/* AGG EN */ | ||
99 | } | ||
100 | } | ||
101 | } | ||
42 | -- | 102 | -- |
43 | 2.34.1 | 103 | 2.34.1 | diff view generated by jsdifflib |