* [PATCH] Staging: rtl8188eu: core: rtw_security: tidy up crc32_init()
@ 2019-08-06 12:28 ` Merwin Trever Ferrao
0 siblings, 0 replies; 4+ messages in thread
From: Merwin Trever Ferrao @ 2019-08-06 12:28 UTC (permalink / raw)
To: Larry.Finger, gregkh, dan.carpenter; +Cc: devel, linux-kernel, merwintf
This code generates checkpatch warning:
WARNING: else is not generally useful after a break or return
Moving the declaration to the top of the function we can pull the
code back one tab and it makes it more readable.
Signed-off-by: Merwin Trever Ferrao <merwintf@gmail.com>
---
drivers/staging/rtl8188eu/core/rtw_security.c | 41 +++++++++----------
1 file changed, 20 insertions(+), 21 deletions(-)
diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c
index 2f90f60f1681..435c0fbec54a 100644
--- a/drivers/staging/rtl8188eu/core/rtw_security.c
+++ b/drivers/staging/rtl8188eu/core/rtw_security.c
@@ -87,29 +87,28 @@ static u8 crc32_reverseBit(u8 data)
static void crc32_init(void)
{
- if (bcrc32initialized == 1) {
+ int i, j;
+ u32 c;
+ u8 *p = (u8 *)&c, *p1;
+ u8 k;
+
+ if (bcrc32initialized == 1)
return;
- } else {
- int i, j;
- u32 c;
- u8 *p = (u8 *)&c, *p1;
- u8 k;
-
- c = 0x12340000;
-
- for (i = 0; i < 256; ++i) {
- k = crc32_reverseBit((u8)i);
- for (c = ((u32)k) << 24, j = 8; j > 0; --j)
- c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1);
- p1 = (u8 *)&crc32_table[i];
-
- p1[0] = crc32_reverseBit(p[3]);
- p1[1] = crc32_reverseBit(p[2]);
- p1[2] = crc32_reverseBit(p[1]);
- p1[3] = crc32_reverseBit(p[0]);
- }
- bcrc32initialized = 1;
+
+ c = 0x12340000;
+
+ for (i = 0; i < 256; ++i) {
+ k = crc32_reverseBit((u8)i);
+ for (c = ((u32)k) << 24, j = 8; j > 0; --j)
+ c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1);
+ p1 = (u8 *)&crc32_table[i];
+
+ p1[0] = crc32_reverseBit(p[3]);
+ p1[1] = crc32_reverseBit(p[2]);
+ p1[2] = crc32_reverseBit(p[1]);
+ p1[3] = crc32_reverseBit(p[0]);
}
+ bcrc32initialized = 1;
}
static __le32 getcrc32(u8 *buf, int len)
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] Staging: rtl8188eu: core: rtw_security: tidy up crc32_init()
@ 2019-08-06 12:28 ` Merwin Trever Ferrao
0 siblings, 0 replies; 4+ messages in thread
From: Merwin Trever Ferrao @ 2019-08-06 12:28 UTC (permalink / raw)
This code generates checkpatch warning:
WARNING: else is not generally useful after a break or return
Moving the declaration to the top of the function we can pull the
code back one tab and it makes it more readable.
Signed-off-by: Merwin Trever Ferrao <merwintf at gmail.com>
---
drivers/staging/rtl8188eu/core/rtw_security.c | 41 +++++++++----------
1 file changed, 20 insertions(+), 21 deletions(-)
diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c
index 2f90f60f1681..435c0fbec54a 100644
--- a/drivers/staging/rtl8188eu/core/rtw_security.c
+++ b/drivers/staging/rtl8188eu/core/rtw_security.c
@@ -87,29 +87,28 @@ static u8 crc32_reverseBit(u8 data)
static void crc32_init(void)
{
- if (bcrc32initialized == 1) {
+ int i, j;
+ u32 c;
+ u8 *p = (u8 *)&c, *p1;
+ u8 k;
+
+ if (bcrc32initialized == 1)
return;
- } else {
- int i, j;
- u32 c;
- u8 *p = (u8 *)&c, *p1;
- u8 k;
-
- c = 0x12340000;
-
- for (i = 0; i < 256; ++i) {
- k = crc32_reverseBit((u8)i);
- for (c = ((u32)k) << 24, j = 8; j > 0; --j)
- c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1);
- p1 = (u8 *)&crc32_table[i];
-
- p1[0] = crc32_reverseBit(p[3]);
- p1[1] = crc32_reverseBit(p[2]);
- p1[2] = crc32_reverseBit(p[1]);
- p1[3] = crc32_reverseBit(p[0]);
- }
- bcrc32initialized = 1;
+
+ c = 0x12340000;
+
+ for (i = 0; i < 256; ++i) {
+ k = crc32_reverseBit((u8)i);
+ for (c = ((u32)k) << 24, j = 8; j > 0; --j)
+ c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1);
+ p1 = (u8 *)&crc32_table[i];
+
+ p1[0] = crc32_reverseBit(p[3]);
+ p1[1] = crc32_reverseBit(p[2]);
+ p1[2] = crc32_reverseBit(p[1]);
+ p1[3] = crc32_reverseBit(p[0]);
}
+ bcrc32initialized = 1;
}
static __le32 getcrc32(u8 *buf, int len)
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Staging: rtl8188eu: core: rtw_security: tidy up crc32_init()
2019-08-06 12:28 ` Merwin Trever Ferrao
@ 2019-08-06 12:48 ` Dan Carpenter
-1 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2019-08-06 12:48 UTC (permalink / raw)
To: Merwin Trever Ferrao; +Cc: Larry.Finger, gregkh, devel, linux-kernel
Looks good.
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH] Staging: rtl8188eu: core: rtw_security: tidy up crc32_init()
@ 2019-08-06 12:48 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2019-08-06 12:48 UTC (permalink / raw)
Looks good.
Reviewed-by: Dan Carpenter <dan.carpenter at oracle.com>
regards,
dan carpenter
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-08-06 12:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-06 12:28 [PATCH] Staging: rtl8188eu: core: rtw_security: tidy up crc32_init() Merwin Trever Ferrao
2019-08-06 12:28 ` Merwin Trever Ferrao
2019-08-06 12:48 ` Dan Carpenter
2019-08-06 12:48 ` Dan Carpenter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.