2024-03-11 18:08:10

by Felix N. Kimbu

[permalink] [raw]
Subject: [PATCH] staging: p80211conv: Rename local foo to decrypt_check

This change renames the local variable foo to decrypt_check in functions
skb_ether_to_p80211(...) and skb_p80211_to_ether(...), giving intuitive
meaning to the identifier.

It also indents the parameters to match the the opening parentheses.

Signed-off-by: Felix N. Kimbu <[email protected]>
---
drivers/staging/wlan-ng/p80211conv.c | 30 ++++++++++++++--------------
1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c
index 8336435eccc2..a0413928a843 100644
--- a/drivers/staging/wlan-ng/p80211conv.c
+++ b/drivers/staging/wlan-ng/p80211conv.c
@@ -93,7 +93,7 @@ int skb_ether_to_p80211(struct wlandevice *wlandev, u32 ethconv,
struct wlan_ethhdr e_hdr;
struct wlan_llc *e_llc;
struct wlan_snap *e_snap;
- int foo;
+ int decrypt_check;

memcpy(&e_hdr, skb->data, sizeof(e_hdr));

@@ -185,14 +185,14 @@ int skb_ether_to_p80211(struct wlandevice *wlandev, u32 ethconv,
p80211_wep->data = kmalloc(skb->len, GFP_ATOMIC);
if (!p80211_wep->data)
return -ENOMEM;
- foo = wep_encrypt(wlandev, skb->data, p80211_wep->data,
- skb->len,
- wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK,
- p80211_wep->iv, p80211_wep->icv);
- if (foo) {
+ decrypt_check = wep_encrypt(wlandev, skb->data, p80211_wep->data,
+ skb->len,
+ wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK,
+ p80211_wep->iv, p80211_wep->icv);
+ if (decrypt_check) {
netdev_warn(wlandev->netdev,
"Host en-WEP failed, dropping frame (%d).\n",
- foo);
+ decrypt_check);
kfree(p80211_wep->data);
return 2;
}
@@ -265,7 +265,7 @@ int skb_p80211_to_ether(struct wlandevice *wlandev, u32 ethconv,
struct wlan_llc *e_llc;
struct wlan_snap *e_snap;

- int foo;
+ int decrypt_check;

payload_length = skb->len - WLAN_HDR_A3_LEN - WLAN_CRC_LEN;
payload_offset = WLAN_HDR_A3_LEN;
@@ -305,15 +305,15 @@ int skb_p80211_to_ether(struct wlandevice *wlandev, u32 ethconv,
"WEP frame too short (%u).\n", skb->len);
return 1;
}
- foo = wep_decrypt(wlandev, skb->data + payload_offset + 4,
- payload_length - 8, -1,
- skb->data + payload_offset,
- skb->data + payload_offset +
- payload_length - 4);
- if (foo) {
+ decrypt_check = wep_decrypt(wlandev, skb->data + payload_offset + 4,
+ payload_length - 8, -1,
+ skb->data + payload_offset,
+ skb->data + payload_offset +
+ payload_length - 4);
+ if (decrypt_check) {
/* de-wep failed, drop skb. */
netdev_dbg(netdev, "Host de-WEP failed, dropping frame (%d).\n",
- foo);
+ decrypt_check);
wlandev->rx.decrypt_err++;
return 2;
}
--
2.34.1



2024-03-11 19:31:25

by Philipp Hortmann

[permalink] [raw]
Subject: Re: [PATCH] staging: p80211conv: Rename local foo to decrypt_check

On 3/11/24 19:07, Felix N. Kimbu wrote:
> This change renames the local variable foo to decrypt_check in functions
> skb_ether_to_p80211(...) and skb_p80211_to_ether(...), giving intuitive
> meaning to the identifier.
>
> It also indents the parameters to match the the opening parentheses.
>
> Signed-off-by: Felix N. Kimbu <[email protected]>

Hi Felix,

I think the subject names the subsystem "staging" and then the driver
which is "wlan-ng" the file can follow but you cannot omit the driver
name.


Please check the following checkpatch warnings:
File Nr: 0 Patch: ../../../Downloads/20240311-[PATCH] staging_
p80211conv_ Rename local foo to decrypt_check-15036.txt
WARNING: Possible repeated word: 'the'
#11:
It also indents the parameters to match the the opening parentheses.

ERROR: code indent should use tabs where possible
#41: FILE: drivers/staging/wlan-ng/p80211conv.c:189:
+^I^I^I^I ^I^I^I^I^Iskb->len,$

WARNING: please, no space before tabs
#41: FILE: drivers/staging/wlan-ng/p80211conv.c:189:
+^I^I^I^I ^I^I^I^I^Iskb->len,$

CHECK: Alignment should match open parenthesis
#41: FILE: drivers/staging/wlan-ng/p80211conv.c:189:
+ decrypt_check = wep_encrypt(wlandev, skb->data, p80211_wep->data,
+ skb->len,

WARNING: line length of 115 exceeds 100 columns
#42: FILE: drivers/staging/wlan-ng/p80211conv.c:190:
+ wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK,

WARNING: line length of 105 exceeds 100 columns
#43: FILE: drivers/staging/wlan-ng/p80211conv.c:191:
+ p80211_wep->iv, p80211_wep->icv);

CHECK: Alignment should match open parenthesis
#72: FILE: drivers/staging/wlan-ng/p80211conv.c:309:
+ decrypt_check = wep_decrypt(wlandev, skb->data + payload_offset + 4,
+ payload_length - 8, -1,

total: 1 errors, 4 warnings, 2 checks, 58 lines checked

Thanks for your support.

Bye Philipp


> ---
> drivers/staging/wlan-ng/p80211conv.c | 30 ++++++++++++++--------------
> 1 file changed, 15 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c
> index 8336435eccc2..a0413928a843 100644
> --- a/drivers/staging/wlan-ng/p80211conv.c
> +++ b/drivers/staging/wlan-ng/p80211conv.c
> @@ -93,7 +93,7 @@ int skb_ether_to_p80211(struct wlandevice *wlandev, u32 ethconv,
> struct wlan_ethhdr e_hdr;
> struct wlan_llc *e_llc;
> struct wlan_snap *e_snap;
> - int foo;
> + int decrypt_check;
>
> memcpy(&e_hdr, skb->data, sizeof(e_hdr));
>
> @@ -185,14 +185,14 @@ int skb_ether_to_p80211(struct wlandevice *wlandev, u32 ethconv,
> p80211_wep->data = kmalloc(skb->len, GFP_ATOMIC);
> if (!p80211_wep->data)
> return -ENOMEM;
> - foo = wep_encrypt(wlandev, skb->data, p80211_wep->data,
> - skb->len,
> - wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK,
> - p80211_wep->iv, p80211_wep->icv);
> - if (foo) {
> + decrypt_check = wep_encrypt(wlandev, skb->data, p80211_wep->data,
> + skb->len,
> + wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK,
> + p80211_wep->iv, p80211_wep->icv);
> + if (decrypt_check) {
> netdev_warn(wlandev->netdev,
> "Host en-WEP failed, dropping frame (%d).\n",
> - foo);
> + decrypt_check);
> kfree(p80211_wep->data);
> return 2;
> }
> @@ -265,7 +265,7 @@ int skb_p80211_to_ether(struct wlandevice *wlandev, u32 ethconv,
> struct wlan_llc *e_llc;
> struct wlan_snap *e_snap;
>
> - int foo;
> + int decrypt_check;
>
> payload_length = skb->len - WLAN_HDR_A3_LEN - WLAN_CRC_LEN;
> payload_offset = WLAN_HDR_A3_LEN;
> @@ -305,15 +305,15 @@ int skb_p80211_to_ether(struct wlandevice *wlandev, u32 ethconv,
> "WEP frame too short (%u).\n", skb->len);
> return 1;
> }
> - foo = wep_decrypt(wlandev, skb->data + payload_offset + 4,
> - payload_length - 8, -1,
> - skb->data + payload_offset,
> - skb->data + payload_offset +
> - payload_length - 4);
> - if (foo) {
> + decrypt_check = wep_decrypt(wlandev, skb->data + payload_offset + 4,
> + payload_length - 8, -1,
> + skb->data + payload_offset,
> + skb->data + payload_offset +
> + payload_length - 4);
> + if (decrypt_check) {
> /* de-wep failed, drop skb. */
> netdev_dbg(netdev, "Host de-WEP failed, dropping frame (%d).\n",
> - foo);
> + decrypt_check);
> wlandev->rx.decrypt_err++;
> return 2;
> }


2024-03-11 21:34:44

by Felix N. Kimbu

[permalink] [raw]
Subject: Re: [PATCH v2] staging: wlan-ng: p80211conv: fix indentation problems, introduced by previous commit

Thank for you the feedback Philipp, I have checked

and corrected the checkpatch warnings.


Signed-off-by: Felix N. Kimbu <[email protected]>
---
 drivers/staging/wlan-ng/p80211conv.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/wlan-ng/p80211conv.c
b/drivers/staging/wlan-ng/p80211conv.c
index a0413928a843..e48a80df87a6 100644
--- a/drivers/staging/wlan-ng/p80211conv.c
+++ b/drivers/staging/wlan-ng/p80211conv.c
@@ -186,9 +186,9 @@ int skb_ether_to_p80211(struct wlandevice *wlandev,
u32 ethconv,
         if (!p80211_wep->data)
             return -ENOMEM;
         decrypt_check = wep_encrypt(wlandev, skb->data, p80211_wep->data,
-                                      skb->len,
-                                    wlandev->hostwep &
HOSTWEP_DEFAULTKEY_MASK,
-                                    p80211_wep->iv, p80211_wep->icv);
+                        skb->len,
+                        wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK,
+                        p80211_wep->iv, p80211_wep->icv);
         if (decrypt_check) {
             netdev_warn(wlandev->netdev,
                     "Host en-WEP failed, dropping frame (%d).\n",
@@ -306,10 +306,10 @@ int skb_p80211_to_ether(struct wlandevice
*wlandev, u32 ethconv,
             return 1;
         }
         decrypt_check = wep_decrypt(wlandev, skb->data +
payload_offset + 4,
-                                    payload_length - 8, -1,
-                                    skb->data + payload_offset,
-                                    skb->data + payload_offset +
-                                    payload_length - 4);
+                        payload_length - 8, -1,
+                        skb->data + payload_offset,
+                        skb->data + payload_offset +
+                        payload_length - 4);
         if (decrypt_check) {
             /* de-wep failed, drop skb. */
             netdev_dbg(netdev, "Host de-WEP failed, dropping frame
(%d).\n",
--
2.34.1

On 3/11/24 20:31, Philipp Hortmann wrote:
> On 3/11/24 19:07, Felix N. Kimbu wrote:
>> This change renames the local variable foo to decrypt_check in functions
>> skb_ether_to_p80211(...) and skb_p80211_to_ether(...), giving intuitive
>> meaning to the identifier.
>>
>> It also indents the parameters to match the the opening parentheses.
>>
>> Signed-off-by: Felix N. Kimbu <[email protected]>
>
> Hi Felix,
>
> I think the subject names the subsystem "staging" and then the driver
> which is "wlan-ng" the file can follow but you cannot omit the driver
> name.
>
>
> Please check the following checkpatch warnings:
> File Nr: 0    Patch: ../../../Downloads/20240311-[PATCH] staging_
> p80211conv_ Rename local foo to decrypt_check-15036.txt
> WARNING: Possible repeated word: 'the'
> #11:
> It also indents the parameters to match the the opening parentheses.
>
> ERROR: code indent should use tabs where possible
> #41: FILE: drivers/staging/wlan-ng/p80211conv.c:189:
> +^I^I^I^I  ^I^I^I^I^Iskb->len,$
>
> WARNING: please, no space before tabs
> #41: FILE: drivers/staging/wlan-ng/p80211conv.c:189:
> +^I^I^I^I  ^I^I^I^I^Iskb->len,$
>
> CHECK: Alignment should match open parenthesis
> #41: FILE: drivers/staging/wlan-ng/p80211conv.c:189:
> +        decrypt_check = wep_encrypt(wlandev, skb->data,
> p80211_wep->data,
> +                                      skb->len,
>
> WARNING: line length of 115 exceeds 100 columns
> #42: FILE: drivers/staging/wlan-ng/p80211conv.c:190:
> +                                    wlandev->hostwep &
> HOSTWEP_DEFAULTKEY_MASK,
>
> WARNING: line length of 105 exceeds 100 columns
> #43: FILE: drivers/staging/wlan-ng/p80211conv.c:191:
> +                                    p80211_wep->iv, p80211_wep->icv);
>
> CHECK: Alignment should match open parenthesis
> #72: FILE: drivers/staging/wlan-ng/p80211conv.c:309:
> +        decrypt_check = wep_decrypt(wlandev, skb->data +
> payload_offset + 4,
> +                                    payload_length - 8, -1,
>
> total: 1 errors, 4 warnings, 2 checks, 58 lines checked
>
> Thanks for your support.
>
> Bye Philipp
>
>
>> ---
>>   drivers/staging/wlan-ng/p80211conv.c | 30 ++++++++++++++--------------
>>   1 file changed, 15 insertions(+), 15 deletions(-)
>>
>> diff --git a/drivers/staging/wlan-ng/p80211conv.c
>> b/drivers/staging/wlan-ng/p80211conv.c
>> index 8336435eccc2..a0413928a843 100644
>> --- a/drivers/staging/wlan-ng/p80211conv.c
>> +++ b/drivers/staging/wlan-ng/p80211conv.c
>> @@ -93,7 +93,7 @@ int skb_ether_to_p80211(struct wlandevice *wlandev,
>> u32 ethconv,
>>       struct wlan_ethhdr e_hdr;
>>       struct wlan_llc *e_llc;
>>       struct wlan_snap *e_snap;
>> -    int foo;
>> +    int decrypt_check;
>>         memcpy(&e_hdr, skb->data, sizeof(e_hdr));
>>   @@ -185,14 +185,14 @@ int skb_ether_to_p80211(struct wlandevice
>> *wlandev, u32 ethconv,
>>           p80211_wep->data = kmalloc(skb->len, GFP_ATOMIC);
>>           if (!p80211_wep->data)
>>               return -ENOMEM;
>> -        foo = wep_encrypt(wlandev, skb->data, p80211_wep->data,
>> -                  skb->len,
>> -                  wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK,
>> -                  p80211_wep->iv, p80211_wep->icv);
>> -        if (foo) {
>> +        decrypt_check = wep_encrypt(wlandev, skb->data,
>> p80211_wep->data,
>> +                                      skb->len,
>> +                                    wlandev->hostwep &
>> HOSTWEP_DEFAULTKEY_MASK,
>> +                                    p80211_wep->iv, p80211_wep->icv);
>> +        if (decrypt_check) {
>>               netdev_warn(wlandev->netdev,
>>                       "Host en-WEP failed, dropping frame (%d).\n",
>> -                    foo);
>> +                    decrypt_check);
>>               kfree(p80211_wep->data);
>>               return 2;
>>           }
>> @@ -265,7 +265,7 @@ int skb_p80211_to_ether(struct wlandevice
>> *wlandev, u32 ethconv,
>>       struct wlan_llc *e_llc;
>>       struct wlan_snap *e_snap;
>>   -    int foo;
>> +    int decrypt_check;
>>         payload_length = skb->len - WLAN_HDR_A3_LEN - WLAN_CRC_LEN;
>>       payload_offset = WLAN_HDR_A3_LEN;
>> @@ -305,15 +305,15 @@ int skb_p80211_to_ether(struct wlandevice
>> *wlandev, u32 ethconv,
>>                      "WEP frame too short (%u).\n", skb->len);
>>               return 1;
>>           }
>> -        foo = wep_decrypt(wlandev, skb->data + payload_offset + 4,
>> -                  payload_length - 8, -1,
>> -                  skb->data + payload_offset,
>> -                  skb->data + payload_offset +
>> -                  payload_length - 4);
>> -        if (foo) {
>> +        decrypt_check = wep_decrypt(wlandev, skb->data +
>> payload_offset + 4,
>> +                                    payload_length - 8, -1,
>> +                                    skb->data + payload_offset,
>> +                                    skb->data + payload_offset +
>> +                                    payload_length - 4);
>> +        if (decrypt_check) {
>>               /* de-wep failed, drop skb. */
>>               netdev_dbg(netdev, "Host de-WEP failed, dropping frame
>> (%d).\n",
>> -                   foo);
>> +                   decrypt_check);
>>               wlandev->rx.decrypt_err++;
>>               return 2;
>>           }
>

2024-03-11 22:46:48

by Alison Schofield

[permalink] [raw]
Subject: Re: [PATCH] staging: p80211conv: Rename local foo to decrypt_check

On Mon, Mar 11, 2024 at 07:07:55PM +0100, Felix N. Kimbu wrote:
> This change renames the local variable foo to decrypt_check in functions
> skb_ether_to_p80211(...) and skb_p80211_to_ether(...), giving intuitive
> meaning to the identifier.

'rc' is typically used for cases like this. If the name of the function
being called is reasonably intuitive, then 'rc' suffices for the return
value.

>
> It also indents the parameters to match the the opening parentheses.

'Also' signals that this patch is trying to do more than one thing.
One type of 'thing' per patch please.

The commit message prefixes are off. Please see First Patch Tutorial
Section: "Following the Driver commit style"

Patch fails checkpatch. Please see First Patch Tutorial Sections:
"Git post-commit hooks" and "Understand patch best practices"



--snip

2024-03-11 22:52:53

by Alison Schofield

[permalink] [raw]
Subject: Re: [PATCH v2] staging: wlan-ng: p80211conv: fix indentation problems, introduced by previous commit

On Mon, Mar 11, 2024 at 10:34:20PM +0100, Felix N. Kimbu wrote:
> Thank for you the feedback Philipp, I have checked
>
> and corrected the checkpatch warnings.
>

Please follow process for revisioning patches here:
First Patch Tutorial Section: Revising your patches
when you send a v3.

>
> Signed-off-by: Felix N. Kimbu <[email protected]>
> ---
> ?drivers/staging/wlan-ng/p80211conv.c | 14 +++++++-------
> ?1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/staging/wlan-ng/p80211conv.c
> b/drivers/staging/wlan-ng/p80211conv.c
> index a0413928a843..e48a80df87a6 100644
> --- a/drivers/staging/wlan-ng/p80211conv.c
> +++ b/drivers/staging/wlan-ng/p80211conv.c
> @@ -186,9 +186,9 @@ int skb_ether_to_p80211(struct wlandevice *wlandev, u32
> ethconv,
> ???? ??? if (!p80211_wep->data)
> ???? ??? ??? return -ENOMEM;
> ???? ??? decrypt_check = wep_encrypt(wlandev, skb->data, p80211_wep->data,
> -??? ??? ??? ??? ? ??? ??? ??? ??? ??? skb->len,
> -??? ??? ??? ??? ??? ??? ??? ??? ??? wlandev->hostwep &
> HOSTWEP_DEFAULTKEY_MASK,
> -??? ??? ??? ??? ??? ??? ??? ??? ??? p80211_wep->iv, p80211_wep->icv);
> +??? ??? ??? ??? ??? ??? skb->len,
> +??? ??? ??? ??? ??? ??? wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK,
> +??? ??? ??? ??? ??? ??? p80211_wep->iv, p80211_wep->icv);
> ???? ??? if (decrypt_check) {
> ???? ??? ??? netdev_warn(wlandev->netdev,
> ???? ??? ??? ??? ??? "Host en-WEP failed, dropping frame (%d).\n",
> @@ -306,10 +306,10 @@ int skb_p80211_to_ether(struct wlandevice *wlandev,
> u32 ethconv,
> ???? ??? ??? return 1;
> ???? ??? }
> ???? ??? decrypt_check = wep_decrypt(wlandev, skb->data + payload_offset +
> 4,
> -??? ??? ??? ??? ??? ??? ??? ??? ??? payload_length - 8, -1,
> -??? ??? ??? ??? ??? ??? ??? ??? ??? skb->data + payload_offset,
> -??? ??? ??? ??? ??? ??? ??? ??? ??? skb->data + payload_offset +
> -??? ??? ??? ??? ??? ??? ??? ??? ??? payload_length - 4);
> +??? ??? ??? ??? ??? ??? payload_length - 8, -1,
> +??? ??? ??? ??? ??? ??? skb->data + payload_offset,
> +??? ??? ??? ??? ??? ??? skb->data + payload_offset +
> +??? ??? ??? ??? ??? ??? payload_length - 4);
> ???? ??? if (decrypt_check) {
> ???? ??? ??? /* de-wep failed, drop skb. */
> ???? ??? ??? netdev_dbg(netdev, "Host de-WEP failed, dropping frame
> (%d).\n",
> --
> 2.34.1
>
> On 3/11/24 20:31, Philipp Hortmann wrote:
> > On 3/11/24 19:07, Felix N. Kimbu wrote:
> > > This change renames the local variable foo to decrypt_check in functions
> > > skb_ether_to_p80211(...) and skb_p80211_to_ether(...), giving intuitive
> > > meaning to the identifier.
> > >
> > > It also indents the parameters to match the the opening parentheses.
> > >
> > > Signed-off-by: Felix N. Kimbu <[email protected]>
> >
> > Hi Felix,
> >
> > I think the subject names the subsystem "staging" and then the driver
> > which is "wlan-ng" the file can follow but you cannot omit the driver
> > name.
> >
> >
> > Please check the following checkpatch warnings:
> > File Nr: 0??? Patch: ../../../Downloads/20240311-[PATCH] staging_
> > p80211conv_ Rename local foo to decrypt_check-15036.txt
> > WARNING: Possible repeated word: 'the'
> > #11:
> > It also indents the parameters to match the the opening parentheses.
> >
> > ERROR: code indent should use tabs where possible
> > #41: FILE: drivers/staging/wlan-ng/p80211conv.c:189:
> > +^I^I^I^I? ^I^I^I^I^Iskb->len,$
> >
> > WARNING: please, no space before tabs
> > #41: FILE: drivers/staging/wlan-ng/p80211conv.c:189:
> > +^I^I^I^I? ^I^I^I^I^Iskb->len,$
> >
> > CHECK: Alignment should match open parenthesis
> > #41: FILE: drivers/staging/wlan-ng/p80211conv.c:189:
> > +??????? decrypt_check = wep_encrypt(wlandev, skb->data,
> > p80211_wep->data,
> > +????????????????????????????????????? skb->len,
> >
> > WARNING: line length of 115 exceeds 100 columns
> > #42: FILE: drivers/staging/wlan-ng/p80211conv.c:190:
> > +??????????????????????????????????? wlandev->hostwep &
> > HOSTWEP_DEFAULTKEY_MASK,
> >
> > WARNING: line length of 105 exceeds 100 columns
> > #43: FILE: drivers/staging/wlan-ng/p80211conv.c:191:
> > +??????????????????????????????????? p80211_wep->iv, p80211_wep->icv);
> >
> > CHECK: Alignment should match open parenthesis
> > #72: FILE: drivers/staging/wlan-ng/p80211conv.c:309:
> > +??????? decrypt_check = wep_decrypt(wlandev, skb->data + payload_offset
> > + 4,
> > +??????????????????????????????????? payload_length - 8, -1,
> >
> > total: 1 errors, 4 warnings, 2 checks, 58 lines checked
> >
> > Thanks for your support.
> >
> > Bye Philipp
> >
> >
> > > ---
> > > ? drivers/staging/wlan-ng/p80211conv.c | 30 ++++++++++++++--------------
> > > ? 1 file changed, 15 insertions(+), 15 deletions(-)
> > >
> > > diff --git a/drivers/staging/wlan-ng/p80211conv.c
> > > b/drivers/staging/wlan-ng/p80211conv.c
> > > index 8336435eccc2..a0413928a843 100644
> > > --- a/drivers/staging/wlan-ng/p80211conv.c
> > > +++ b/drivers/staging/wlan-ng/p80211conv.c
> > > @@ -93,7 +93,7 @@ int skb_ether_to_p80211(struct wlandevice
> > > *wlandev, u32 ethconv,
> > > ????? struct wlan_ethhdr e_hdr;
> > > ????? struct wlan_llc *e_llc;
> > > ????? struct wlan_snap *e_snap;
> > > -??? int foo;
> > > +??? int decrypt_check;
> > > ? ????? memcpy(&e_hdr, skb->data, sizeof(e_hdr));
> > > ? @@ -185,14 +185,14 @@ int skb_ether_to_p80211(struct wlandevice
> > > *wlandev, u32 ethconv,
> > > ????????? p80211_wep->data = kmalloc(skb->len, GFP_ATOMIC);
> > > ????????? if (!p80211_wep->data)
> > > ????????????? return -ENOMEM;
> > > -??????? foo = wep_encrypt(wlandev, skb->data, p80211_wep->data,
> > > -????????????????? skb->len,
> > > -????????????????? wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK,
> > > -????????????????? p80211_wep->iv, p80211_wep->icv);
> > > -??????? if (foo) {
> > > +??????? decrypt_check = wep_encrypt(wlandev, skb->data,
> > > p80211_wep->data,
> > > +????????????????????????????????????? skb->len,
> > > +??????????????????????????????????? wlandev->hostwep &
> > > HOSTWEP_DEFAULTKEY_MASK,
> > > +??????????????????????????????????? p80211_wep->iv, p80211_wep->icv);
> > > +??????? if (decrypt_check) {
> > > ????????????? netdev_warn(wlandev->netdev,
> > > ????????????????????? "Host en-WEP failed, dropping frame (%d).\n",
> > > -??????????????????? foo);
> > > +??????????????????? decrypt_check);
> > > ????????????? kfree(p80211_wep->data);
> > > ????????????? return 2;
> > > ????????? }
> > > @@ -265,7 +265,7 @@ int skb_p80211_to_ether(struct wlandevice
> > > *wlandev, u32 ethconv,
> > > ????? struct wlan_llc *e_llc;
> > > ????? struct wlan_snap *e_snap;
> > > ? -??? int foo;
> > > +??? int decrypt_check;
> > > ? ????? payload_length = skb->len - WLAN_HDR_A3_LEN - WLAN_CRC_LEN;
> > > ????? payload_offset = WLAN_HDR_A3_LEN;
> > > @@ -305,15 +305,15 @@ int skb_p80211_to_ether(struct wlandevice
> > > *wlandev, u32 ethconv,
> > > ???????????????????? "WEP frame too short (%u).\n", skb->len);
> > > ????????????? return 1;
> > > ????????? }
> > > -??????? foo = wep_decrypt(wlandev, skb->data + payload_offset + 4,
> > > -????????????????? payload_length - 8, -1,
> > > -????????????????? skb->data + payload_offset,
> > > -????????????????? skb->data + payload_offset +
> > > -????????????????? payload_length - 4);
> > > -??????? if (foo) {
> > > +??????? decrypt_check = wep_decrypt(wlandev, skb->data +
> > > payload_offset + 4,
> > > +??????????????????????????????????? payload_length - 8, -1,
> > > +??????????????????????????????????? skb->data + payload_offset,
> > > +??????????????????????????????????? skb->data + payload_offset +
> > > +??????????????????????????????????? payload_length - 4);
> > > +??????? if (decrypt_check) {
> > > ????????????? /* de-wep failed, drop skb. */
> > > ????????????? netdev_dbg(netdev, "Host de-WEP failed, dropping frame
> > > (%d).\n",
> > > -?????????????????? foo);
> > > +?????????????????? decrypt_check);
> > > ????????????? wlandev->rx.decrypt_err++;
> > > ????????????? return 2;
> > > ????????? }
> >
>

2024-03-12 09:01:30

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH] staging: p80211conv: Rename local foo to decrypt_check

On Mon, Mar 11, 2024 at 03:46:29PM -0700, Alison Schofield wrote:
> On Mon, Mar 11, 2024 at 07:07:55PM +0100, Felix N. Kimbu wrote:
> > This change renames the local variable foo to decrypt_check in functions
> > skb_ether_to_p80211(...) and skb_p80211_to_ether(...), giving intuitive
> > meaning to the identifier.
>
> 'rc' is typically used for cases like this. If the name of the function
> being called is reasonably intuitive, then 'rc' suffices for the return
> value.
>
> >
> > It also indents the parameters to match the the opening parentheses.
>
> 'Also' signals that this patch is trying to do more than one thing.
> One type of 'thing' per patch please.
>

The name change did force a re-indent. The v2 re-indent was wrong too
though.

regards,
dan carpenter


2024-03-12 09:03:53

by Dan Carpenter

[permalink] [raw]
Subject: Re: [PATCH] staging: p80211conv: Rename local foo to decrypt_check

On Mon, Mar 11, 2024 at 07:07:55PM +0100, Felix N. Kimbu wrote:
> @@ -185,14 +185,14 @@ int skb_ether_to_p80211(struct wlandevice *wlandev, u32 ethconv,
> p80211_wep->data = kmalloc(skb->len, GFP_ATOMIC);
> if (!p80211_wep->data)
> return -ENOMEM;
> - foo = wep_encrypt(wlandev, skb->data, p80211_wep->data,
> - skb->len,
> - wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK,
> - p80211_wep->iv, p80211_wep->icv);
> - if (foo) {
> + decrypt_check = wep_encrypt(wlandev, skb->data, p80211_wep->data,
> + skb->len,
> + wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK,
> + p80211_wep->iv, p80211_wep->icv);

With the rename the indenting did need to be updated, yes. However it
should have been:

decrypt_check = wep_encrypt(wlandev, skb->data, p80211_wep->data,
skb->len,
wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK,
p80211_wep->iv, p80211_wep->icv);

[tab][tab][tab][tab][tab][space][space][space][space]skb->len,

See my blog for how to resend a patch:
https://staticthinking.wordpress.com/2022/07/27/how-to-send-a-v2-patch/

regards,
dan carpenter


2024-03-12 14:09:56

by Felix N. Kimbu

[permalink] [raw]
Subject: Re: [PATCH] staging: p80211conv: Rename local foo to decrypt_check

On Mon, Mar 11, 2024 at 11:46 PM Alison Schofield
<[email protected]> wrote:
> 'rc' is typically used for cases like this. If the name of the function
> being called is reasonably intuitive, then 'rc' suffices for the return
> value.

Greetings Alison,
Thank you for the feedback, well noted.

> 'Also' signals that this patch is trying to do more than one thing.
> One type of 'thing' per patch please.

Dan has already address this, perhaps, I did not write the message correctly,
suggesting that the patch does more than one thing.

> The commit message prefixes are off. Please see First Patch Tutorial
> Section: "Following the Driver commit style"
>
> Patch fails checkpatch. Please see First Patch Tutorial Sections:
> "Git post-commit hooks" and "Understand patch best practices"

I will definitely fix these, thanks again immensely.
--

2024-03-12 14:16:38

by Felix N. Kimbu

[permalink] [raw]
Subject: Re: [PATCH] staging: p80211conv: Rename local foo to decrypt_check

On Tue, Mar 12, 2024 at 10:03 AM Dan Carpenter <[email protected]> wrote:
>
> With the rename the indenting did need to be updated, yes. However it
> should have been:
>
> decrypt_check = wep_encrypt(wlandev, skb->data, p80211_wep->data,
> skb->len,
> wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK,
> p80211_wep->iv, p80211_wep->icv);
>
> [tab][tab][tab][tab][tab][space][space][space][space]skb->len,
>
> See my blog for how to resend a patch:
> https://staticthinking.wordpress.com/2022/07/27/how-to-send-a-v2-patch/
>
> regards,
> dan carpenter

Thank you for the feedback, Dan, let me correct that.

2024-03-12 14:20:15

by Felix N. Kimbu

[permalink] [raw]
Subject: Re: [PATCH v2] staging: wlan-ng: p80211conv: fix indentation problems, introduced by previous commit

On Mon, Mar 11, 2024 at 11:52 PM Alison Schofield
<[email protected]> wrote:
> Please follow process for revisioning patches here:
> First Patch Tutorial Section: Revising your patches
> when you send a v3.

I appreciate the feedback.
Thank you and best regards