* [PATCH] stating: otus: fix compile warning and some style issues
@ 2010-08-07 23:52 Roberto Rodriguez Alkala
2010-08-08 15:17 ` walter harms
0 siblings, 1 reply; 2+ messages in thread
From: Roberto Rodriguez Alkala @ 2010-08-07 23:52 UTC (permalink / raw)
To: Greg Kroah-Hartman, Joe Perches, devel, linux-kernel,
kernel-janitors
In today linux-next I got a compile warning in staging/otus driver.
This patch solves the issue and also improves the coding style.
Signed-off-by: Roberto Rodriguez Alcala <rralcala@gmail.com>
---
drivers/staging/otus/80211core/ratectrl.c | 26 +++++++++-----------------
1 files changed, 9 insertions(+), 17 deletions(-)
diff --git a/drivers/staging/otus/80211core/ratectrl.c b/drivers/staging/otus/80211core/ratectrl.c
index a1abe2f..283b2b5 100644
--- a/drivers/staging/otus/80211core/ratectrl.c
+++ b/drivers/staging/otus/80211core/ratectrl.c
@@ -422,23 +422,15 @@ u8_t zfRateCtrlRateDiff(struct zsRcCell* rcCell, u8_t retryRate)
u16_t i;
/* Find retryRate in operationRateSet[] */
- for (i=0; i<rcCell->operationRateCount; i++)
- {
- if (retryRate = rcCell->operationRateSet[i])
- {
- if (i < rcCell->currentRateIndex)
- {
- return ((rcCell->currentRateIndex - i)+1)>>1;
- }
- else if (i = rcCell->currentRateIndex = 0)
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
+ for (i = 0; i < rcCell->operationRateCount; i++) {
+ if (retryRate = rcCell->operationRateSet[i]) {
+ if (i < rcCell->currentRateIndex)
+ return ((rcCell->currentRateIndex - i)+1)>>1;
+ else if (i = rcCell->currentRateIndex && i = 0)
+ return 1;
+ else
+ return 0;
+ }
}
/* TODO : retry rate not in operation rate set */
zm_msg1_tx(ZM_LV_0, "Not in operation rate set:", retryRate);
--
1.7.0.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] stating: otus: fix compile warning and some style issues
2010-08-07 23:52 [PATCH] stating: otus: fix compile warning and some style issues Roberto Rodriguez Alkala
@ 2010-08-08 15:17 ` walter harms
0 siblings, 0 replies; 2+ messages in thread
From: walter harms @ 2010-08-08 15:17 UTC (permalink / raw)
To: Roberto Rodriguez Alkala
Cc: Greg Kroah-Hartman, Joe Perches, devel, linux-kernel,
kernel-janitors
Roberto Rodriguez Alkala schrieb:
> In today linux-next I got a compile warning in staging/otus driver.
> This patch solves the issue and also improves the coding style.
>
> Signed-off-by: Roberto Rodriguez Alcala <rralcala@gmail.com>
> ---
> drivers/staging/otus/80211core/ratectrl.c | 26 +++++++++-----------------
> 1 files changed, 9 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/staging/otus/80211core/ratectrl.c b/drivers/staging/otus/80211core/ratectrl.c
> index a1abe2f..283b2b5 100644
> --- a/drivers/staging/otus/80211core/ratectrl.c
> +++ b/drivers/staging/otus/80211core/ratectrl.c
> @@ -422,23 +422,15 @@ u8_t zfRateCtrlRateDiff(struct zsRcCell* rcCell, u8_t retryRate)
> u16_t i;
>
> /* Find retryRate in operationRateSet[] */
> - for (i=0; i<rcCell->operationRateCount; i++)
> - {
> - if (retryRate = rcCell->operationRateSet[i])
> - {
> - if (i < rcCell->currentRateIndex)
> - {
> - return ((rcCell->currentRateIndex - i)+1)>>1;
> - }
> - else if (i = rcCell->currentRateIndex = 0)
> - {
> - return 1;
> - }
> - else
> - {
> - return 0;
> - }
> - }
> + for (i = 0; i < rcCell->operationRateCount; i++) {
> + if (retryRate = rcCell->operationRateSet[i]) {
> + if (i < rcCell->currentRateIndex)
> + return ((rcCell->currentRateIndex - i)+1)>>1;
> + else if (i = rcCell->currentRateIndex && i = 0)
> + return 1;
> + else
> + return 0;
> + }
> }
> /* TODO : retry rate not in operation rate set */
> zm_msg1_tx(ZM_LV_0, "Not in operation rate set:", retryRate);
mmh, it is a matter of taste but to improve readablity
i would make the special case i=0 first and let the loop
start with i=1. /* untested code below, assuming rcCell->currentRateIndex>=0 */
if ( retryRate = rcCell->operationRateSet[0] && rcCell->currentRateIndex= 0 )
return 1;
for (i = 1; i < rcCell->operationRateCount; i++) {
if (i < rcCell->currentRateIndex)
return ((rcCell->currentRateIndex - i)+1)>>1;
else
return 0;
}
just my 2 cents,
re,
wh
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-08-08 15:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-07 23:52 [PATCH] stating: otus: fix compile warning and some style issues Roberto Rodriguez Alkala
2010-08-08 15:17 ` walter harms
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).