* [PATCH] staging: rtl8712: aggregate conditional statements
@ 2024-03-17 18:06 Ayush Tiwari
2024-03-18 7:46 ` Dan Carpenter
0 siblings, 1 reply; 2+ messages in thread
From: Ayush Tiwari @ 2024-03-17 18:06 UTC (permalink / raw)
To: Larry.Finger, florian.c.schilhabel, gregkh, linux-kernel, linux-staging
Cc: outreachy
Aggregate the two conditional statements into one conditional
statement to reduce code length and simplify the code structure.
Signed-off-by: Ayush Tiwari <ayushtiw0110@gmail.com>
---
drivers/staging/rtl8712/ieee80211.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/staging/rtl8712/ieee80211.c b/drivers/staging/rtl8712/ieee80211.c
index 7d8f1a29d18a..3b7a72bb6fc7 100644
--- a/drivers/staging/rtl8712/ieee80211.c
+++ b/drivers/staging/rtl8712/ieee80211.c
@@ -147,9 +147,7 @@ static uint r8712_get_rateset_len(u8 *rateset)
uint i = 0;
while (1) {
- if ((rateset[i]) == 0)
- break;
- if (i > 12)
+ if ((rateset[i] == 0) || (i > 12))
break;
i++;
}
--
2.40.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] staging: rtl8712: aggregate conditional statements
2024-03-17 18:06 [PATCH] staging: rtl8712: aggregate conditional statements Ayush Tiwari
@ 2024-03-18 7:46 ` Dan Carpenter
0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2024-03-18 7:46 UTC (permalink / raw)
To: Ayush Tiwari
Cc: Larry.Finger, florian.c.schilhabel, gregkh, linux-kernel,
linux-staging, outreachy
On Sun, Mar 17, 2024 at 11:36:17PM +0530, Ayush Tiwari wrote:
> Aggregate the two conditional statements into one conditional
> statement to reduce code length and simplify the code structure.
>
> Signed-off-by: Ayush Tiwari <ayushtiw0110@gmail.com>
I'm not a fan of this sort of thing. The new code is fine but the
original code was fine. If you were going to be taking over the
maintainership of the rtl8712 driver, then you could do whatever you
want. But if you're just sending drive by patches, then it's just leave
the original code as is. You might be right. But it's not worth
debating or even thinking about for more than a second or two.
Someone was complaining about my code recently where I tend to break
things up into separate if statements and they were like "You could
combine them all on one line", and I'm like, "Yeah. It was that way to
begin with but I was fixing some issues and I deliberately separated it
out for readability." So that's one life hack which that if you don't
like someone's code style, just find some mistakes and re-write it.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-03-18 7:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-17 18:06 [PATCH] staging: rtl8712: aggregate conditional statements Ayush Tiwari
2024-03-18 7:46 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®