2023-04-01 19:01:42

by Khadija Kamran

[permalink] [raw]
Subject: [PATCH 0/5] staging: rtl8192e: fix checkpatch issues in rtllib_crypt_ccmp.c

Fix several issues reported by checkpatch in rtllib_crypt_ccmp.c file.

Khadija Kamran (5):
staging: rtl8192e: remove extra blank lines in rtllib_crypt_ccmp.c
staging: rtl8192e: fix alignment to match open parenthesis
staging: rtl8192e: avoid camel-case <dot11RSNAStatsCCMPFormatErrors>
staging: rtl8192e: avoid camel-case <dot11RSNAStatsCCMPReplays>
staging: rtl8192e: avoid camel-case <dot11RSNAStatsCCMPDecryptErrors>

drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 33 +++++++-------------
1 file changed, 12 insertions(+), 21 deletions(-)

--
2.34.1


2023-04-01 19:02:09

by Khadija Kamran

[permalink] [raw]
Subject: [PATCH 3/5] staging: rtl8192e: avoid camel-case <dot11RSNAStatsCCMPFormatErrors>

Linux kernel coding-style does not suggest mixed-case names. This issue
is reported by checkpatch.

Fix variable name by changing it from camel-case to lower-case. In order
to describe the variable name better, add a comment above it.

Suggested-by: Deepak R Varma <[email protected]>
Signed-off-by: Khadija Kamran <[email protected]>
---
drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
index 8d3067a6ccca..e8a3bc94efdc 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
@@ -34,7 +34,8 @@ struct rtllib_ccmp_data {
u8 tx_pn[CCMP_PN_LEN];
u8 rx_pn[CCMP_PN_LEN];

- u32 dot11RSNAStatsCCMPFormatErrors;
+ /* .11 RSNA stats for CCMP */
+ u32 ccmp_format_errors;
u32 dot11RSNAStatsCCMPReplays;
u32 dot11RSNAStatsCCMPDecryptErrors;

@@ -226,7 +227,7 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
u8 pn[6];

if (skb->len < hdr_len + CCMP_HDR_LEN + CCMP_MIC_LEN) {
- key->dot11RSNAStatsCCMPFormatErrors++;
+ key->ccmp_format_errors++;
return -1;
}

@@ -238,7 +239,7 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
pr_debug("CCMP: received packet without ExtIV flag from %pM\n",
hdr->addr2);
}
- key->dot11RSNAStatsCCMPFormatErrors++;
+ key->ccmp_format_errors++;
return -2;
}
keyidx >>= 6;
@@ -374,7 +375,7 @@ static void rtllib_ccmp_print_stats(struct seq_file *m, void *priv)
"key[%d] alg=CCMP key_set=%d tx_pn=%pM rx_pn=%pM format_errors=%d replays=%d decrypt_errors=%d\n",
ccmp->key_idx, ccmp->key_set,
ccmp->tx_pn, ccmp->rx_pn,
- ccmp->dot11RSNAStatsCCMPFormatErrors,
+ ccmp->ccmp_format_errors,
ccmp->dot11RSNAStatsCCMPReplays,
ccmp->dot11RSNAStatsCCMPDecryptErrors);
}
--
2.34.1

2023-04-01 19:02:15

by Khadija Kamran

[permalink] [raw]
Subject: [PATCH 2/5] staging: rtl8192e: fix alignment to match open parenthesis

Fix alignemnt to match opening parenthesis as suggested by Linux kernel
coding-style. This issue is reported by checkpatch.

Signed-off-by: Khadija Kamran <[email protected]>
---
drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
index eb7b6deb2ca7..8d3067a6ccca 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
@@ -332,7 +332,7 @@ static int rtllib_ccmp_set_key(void *key, int len, u8 *seq, void *priv)
data->rx_pn[5] = seq[0];
}
if (crypto_aead_setauthsize(data->tfm, CCMP_MIC_LEN) ||
- crypto_aead_setkey(data->tfm, data->key, CCMP_TK_LEN))
+ crypto_aead_setkey(data->tfm, data->key, CCMP_TK_LEN))
return -1;
} else if (len == 0) {
data->key_set = 0;
--
2.34.1

2023-04-01 19:02:15

by Khadija Kamran

[permalink] [raw]
Subject: [PATCH 1/5] staging: rtl8192e: remove extra blank lines in rtllib_crypt_ccmp.c

Remove extra blank lines as suggested by the Linux kernel coding-style.
These issues were reported by checkpatch.

"CHECK: Please don't use multiple blank lines"

Signed-off-by: Khadija Kamran <[email protected]>
---
drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 10 ----------
1 file changed, 10 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
index a8d22da8bc9a..eb7b6deb2ca7 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
@@ -74,7 +74,6 @@ static void *rtllib_ccmp_init(int key_idx)
return NULL;
}

-
static void rtllib_ccmp_deinit(void *priv)
{
struct rtllib_ccmp_data *_priv = priv;
@@ -84,7 +83,6 @@ static void rtllib_ccmp_deinit(void *priv)
kfree(priv);
}

-
static int ccmp_init_iv_and_aad(struct rtllib_hdr_4addr *hdr,
u8 *pn, u8 *iv, u8 *aad)
{
@@ -150,8 +148,6 @@ static int ccmp_init_iv_and_aad(struct rtllib_hdr_4addr *hdr,
return aad_len;
}

-
-
static int rtllib_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
{
struct rtllib_ccmp_data *key = priv;
@@ -220,7 +216,6 @@ static int rtllib_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
return 0;
}

-
static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
{
struct rtllib_ccmp_data *key = priv;
@@ -315,7 +310,6 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
return keyidx;
}

-
static int rtllib_ccmp_set_key(void *key, int len, u8 *seq, void *priv)
{
struct rtllib_ccmp_data *data = priv;
@@ -349,7 +343,6 @@ static int rtllib_ccmp_set_key(void *key, int len, u8 *seq, void *priv)
return 0;
}

-
static int rtllib_ccmp_get_key(void *key, int len, u8 *seq, void *priv)
{
struct rtllib_ccmp_data *data = priv;
@@ -373,7 +366,6 @@ static int rtllib_ccmp_get_key(void *key, int len, u8 *seq, void *priv)
return CCMP_TK_LEN;
}

-
static void rtllib_ccmp_print_stats(struct seq_file *m, void *priv)
{
struct rtllib_ccmp_data *ccmp = priv;
@@ -403,13 +395,11 @@ static struct lib80211_crypto_ops rtllib_crypt_ccmp = {
.owner = THIS_MODULE,
};

-
static int __init rtllib_crypto_ccmp_init(void)
{
return lib80211_register_crypto_ops(&rtllib_crypt_ccmp);
}

-
static void __exit rtllib_crypto_ccmp_exit(void)
{
lib80211_unregister_crypto_ops(&rtllib_crypt_ccmp);
--
2.34.1

2023-04-01 19:02:15

by Khadija Kamran

[permalink] [raw]
Subject: [PATCH 4/5] staging: rtl8192e: avoid camel-case <dot11RSNAStatsCCMPReplays>

Linux kernel coding-style suggests to not use mixed-case names. Fix
checkpatch issue by changing the variable name from camel-case to
lower-case.

Suggested-by: Deepak R Varma <[email protected]>
Signed-off-by: Khadija Kamran <[email protected]>
---
drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
index e8a3bc94efdc..1783a2eaae66 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
@@ -36,7 +36,7 @@ struct rtllib_ccmp_data {

/* .11 RSNA stats for CCMP */
u32 ccmp_format_errors;
- u32 dot11RSNAStatsCCMPReplays;
+ u32 ccmp_replays;
u32 dot11RSNAStatsCCMPDecryptErrors;

int key_idx;
@@ -264,7 +264,7 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
pn[5] = pos[0];
pos += 8;
if (memcmp(pn, key->rx_pn, CCMP_PN_LEN) <= 0) {
- key->dot11RSNAStatsCCMPReplays++;
+ key->ccmp_replays++;
return -4;
}
if (!tcb_desc->bHwSec) {
@@ -376,7 +376,7 @@ static void rtllib_ccmp_print_stats(struct seq_file *m, void *priv)
ccmp->key_idx, ccmp->key_set,
ccmp->tx_pn, ccmp->rx_pn,
ccmp->ccmp_format_errors,
- ccmp->dot11RSNAStatsCCMPReplays,
+ ccmp->ccmp_replays,
ccmp->dot11RSNAStatsCCMPDecryptErrors);
}

--
2.34.1

2023-04-01 21:29:38

by Philipp Hortmann

[permalink] [raw]
Subject: Re: [PATCH 3/5] staging: rtl8192e: avoid camel-case <dot11RSNAStatsCCMPFormatErrors>

On 4/1/23 20:58, Khadija Kamran wrote:
> Linux kernel coding-style does not suggest mixed-case names. This issue
> is reported by checkpatch.
>
> Fix variable name by changing it from camel-case to lower-case. In order
> to describe the variable name better, add a comment above it.
>

I think you are changing from camel case to snake case.

> Suggested-by: Deepak R Varma <[email protected]>
> Signed-off-by: Khadija Kamran <[email protected]>
> ---
> drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
> index 8d3067a6ccca..e8a3bc94efdc 100644
> --- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
> +++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
> @@ -34,7 +34,8 @@ struct rtllib_ccmp_data {
> u8 tx_pn[CCMP_PN_LEN];
> u8 rx_pn[CCMP_PN_LEN];
>
> - u32 dot11RSNAStatsCCMPFormatErrors;
> + /* .11 RSNA stats for CCMP */
> + u32 ccmp_format_errors;
> u32 dot11RSNAStatsCCMPReplays;
> u32 dot11RSNAStatsCCMPDecryptErrors;


Is it obvious that CCMPFormatErrors is a part of dot11RSNAStats? OK. You
added a comment. Often for me the issue is that the comment is only
valid to one line or to more?

I would prefer something like: dot11rsna_stats_ccmp_format_err
This is keeping the information the author gave variable and I would
understand better and see it in every place.

>
> @@ -226,7 +227,7 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
> u8 pn[6];
>
> if (skb->len < hdr_len + CCMP_HDR_LEN + CCMP_MIC_LEN) {
> - key->dot11RSNAStatsCCMPFormatErrors++;
> + key->ccmp_format_errors++;
> return -1;
> }
>
> @@ -238,7 +239,7 @@ static int rtllib_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
> pr_debug("CCMP: received packet without ExtIV flag from %pM\n",
> hdr->addr2);
> }
> - key->dot11RSNAStatsCCMPFormatErrors++;
> + key->ccmp_format_errors++;
> return -2;
> }
> keyidx >>= 6;
> @@ -374,7 +375,7 @@ static void rtllib_ccmp_print_stats(struct seq_file *m, void *priv)
> "key[%d] alg=CCMP key_set=%d tx_pn=%pM rx_pn=%pM format_errors=%d replays=%d decrypt_errors=%d\n",
> ccmp->key_idx, ccmp->key_set,
> ccmp->tx_pn, ccmp->rx_pn,
> - ccmp->dot11RSNAStatsCCMPFormatErrors,
> + ccmp->ccmp_format_errors,
> ccmp->dot11RSNAStatsCCMPReplays,
> ccmp->dot11RSNAStatsCCMPDecryptErrors);
> }