All of lore.kernel.org
 help / color / mirror / Atom feed
From: walter harms <wharms@bfs.de>
To: Kulikov Vasiliy <segooon@gmail.com>
Cc: trivial@kernel.org,
	Kernel Janitors <kernel-janitors@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@suse.de>,
	Simon Horman <horms@verge.net.au>,
	Andrea Gelmini <andrea.gelmini@gelma.net>,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 11/16] trivial: use ARRAY_SIZE
Date: Mon, 28 Jun 2010 13:22:49 +0000	[thread overview]
Message-ID: <4C28A229.10503@bfs.de> (raw)
In-Reply-To: <4C28989E.9010300@bfs.de>



walter harms schrieb:
> 
> Kulikov Vasiliy schrieb:
>> Change sizeof(x) / sizeof(*x) to ARRAY_SIZE(x).
>>
>> Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
>> ---
>>  drivers/staging/otus/hal/hpreg.c |   17 +++++++----------
>>  1 files changed, 7 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/staging/otus/hal/hpreg.c b/drivers/staging/otus/hal/hpreg.c
>> index da3b774..9b04653 100644
>> --- a/drivers/staging/otus/hal/hpreg.c
>> +++ b/drivers/staging/otus/hal/hpreg.c
>> @@ -29,9 +29,6 @@
>>  #include "hpreg.h"
>>  #include "hpusb.h"
>>  
>> -/* used throughout this file... */
>> -#define	N(a)	(sizeof(a) / sizeof(a[0]))
>> -
>>  #define HAL_MODE_11A_TURBO	HAL_MODE_108A
>>  #define HAL_MODE_11G_TURBO	HAL_MODE_108G
>>  
>> @@ -1557,7 +1554,7 @@ u8_t GetWmRD(u16_t regionCode, u16_t channelFlag, REG_DOMAIN *rd)
>>  	u64_t flags = NO_REQ;
>>  	REG_DMN_PAIR_MAPPING *regPair = NULL;
>>  
>> -	for (i = 0, found = 0; (i < N(regDomainPairs)) && (!found); i++) {
>> +	for (i = 0, found = 0; (i < ARRAY_SIZE(regDomainPairs)) && (!found); i++) {
>>  		if (regDomainPairs[i].regDmnEnum = regionCode) {
>>  			regPair = &regDomainPairs[i];
>>  			found = 1;
> 
> 
> 
> This looks odd, i do not see the rest of the code but perhaps a break would help
> to eleminate the "found" ??
> 
> just my two cents,
>  wh
> 
1554 u8_t GetWmRD(u16_t regionCode, u16_t channelFlag, REG_DOMAIN *rd)
1555 {
1556         s16_t i, found, regDmn;
1557         u64_t flags=NO_REQ;
1558         REG_DMN_PAIR_MAPPING *regPair=NULL;
1559
1560         for (i=0, found=0; (i<N(regDomainPairs))&&(!found); i++)
1561         {
1562                 if (regDomainPairs[i].regDmnEnum = regionCode)
1563                 {
1564                         regPair = &regDomainPairs[i];
1565                         found = 1;
1566                 }
1567         }
1568         if (!found)
1569         {
1570                 zm_debug_msg1("Failed to find reg domain pair ", regionCode);
1571                 return FALSE;
1572         }


This is would stop at the first hit and work without found.
Otherwise someone could add an {NULL} at the end of the array
und use a while () that would eliminate the need for ARRAY_SIZE also.

re,
 wh

for (i=0; i<ARRAY_SIZE(regDomainPairs);i++ )
	if (regDomainPairs[i].regDmnEnum = regionCode)
                    { regPair = &regDomainPairs[i]; break ; }

if (!regPair) {
        zm_debug_msg1("Failed to find reg domain pair ", regionCode);
        return FALSE;
}




WARNING: multiple messages have this Message-ID (diff)
From: walter harms <wharms@bfs.de>
To: Kulikov Vasiliy <segooon@gmail.com>
Cc: trivial@kernel.org,
	Kernel Janitors <kernel-janitors@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@suse.de>,
	Simon Horman <horms@verge.net.au>,
	Andrea Gelmini <andrea.gelmini@gelma.net>,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 11/16] trivial: use ARRAY_SIZE
Date: Mon, 28 Jun 2010 15:22:49 +0200	[thread overview]
Message-ID: <4C28A229.10503@bfs.de> (raw)
In-Reply-To: <4C28989E.9010300@bfs.de>



walter harms schrieb:
> 
> Kulikov Vasiliy schrieb:
>> Change sizeof(x) / sizeof(*x) to ARRAY_SIZE(x).
>>
>> Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
>> ---
>>  drivers/staging/otus/hal/hpreg.c |   17 +++++++----------
>>  1 files changed, 7 insertions(+), 10 deletions(-)
>>
>> diff --git a/drivers/staging/otus/hal/hpreg.c b/drivers/staging/otus/hal/hpreg.c
>> index da3b774..9b04653 100644
>> --- a/drivers/staging/otus/hal/hpreg.c
>> +++ b/drivers/staging/otus/hal/hpreg.c
>> @@ -29,9 +29,6 @@
>>  #include "hpreg.h"
>>  #include "hpusb.h"
>>  
>> -/* used throughout this file... */
>> -#define	N(a)	(sizeof(a) / sizeof(a[0]))
>> -
>>  #define HAL_MODE_11A_TURBO	HAL_MODE_108A
>>  #define HAL_MODE_11G_TURBO	HAL_MODE_108G
>>  
>> @@ -1557,7 +1554,7 @@ u8_t GetWmRD(u16_t regionCode, u16_t channelFlag, REG_DOMAIN *rd)
>>  	u64_t flags = NO_REQ;
>>  	REG_DMN_PAIR_MAPPING *regPair = NULL;
>>  
>> -	for (i = 0, found = 0; (i < N(regDomainPairs)) && (!found); i++) {
>> +	for (i = 0, found = 0; (i < ARRAY_SIZE(regDomainPairs)) && (!found); i++) {
>>  		if (regDomainPairs[i].regDmnEnum == regionCode) {
>>  			regPair = &regDomainPairs[i];
>>  			found = 1;
> 
> 
> 
> This looks odd, i do not see the rest of the code but perhaps a break would help
> to eleminate the "found" ??
> 
> just my two cents,
>  wh
> 
1554 u8_t GetWmRD(u16_t regionCode, u16_t channelFlag, REG_DOMAIN *rd)
1555 {
1556         s16_t i, found, regDmn;
1557         u64_t flags=NO_REQ;
1558         REG_DMN_PAIR_MAPPING *regPair=NULL;
1559
1560         for (i=0, found=0; (i<N(regDomainPairs))&&(!found); i++)
1561         {
1562                 if (regDomainPairs[i].regDmnEnum == regionCode)
1563                 {
1564                         regPair = &regDomainPairs[i];
1565                         found = 1;
1566                 }
1567         }
1568         if (!found)
1569         {
1570                 zm_debug_msg1("Failed to find reg domain pair ", regionCode);
1571                 return FALSE;
1572         }


This is would stop at the first hit and work without found.
Otherwise someone could add an {NULL} at the end of the array
und use a while () that would eliminate the need for ARRAY_SIZE also.

re,
 wh

for (i=0; i<ARRAY_SIZE(regDomainPairs);i++ )
	if (regDomainPairs[i].regDmnEnum == regionCode)
                    { regPair = &regDomainPairs[i]; break ; }

if (!regPair) {
        zm_debug_msg1("Failed to find reg domain pair ", regionCode);
        return FALSE;
}




  reply	other threads:[~2010-06-28 13:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-28 11:55 [PATCH 11/16] trivial: use ARRAY_SIZE Kulikov Vasiliy
2010-06-28 11:55 ` Kulikov Vasiliy
2010-06-28 12:42 ` walter harms
2010-06-28 12:42   ` walter harms
2010-06-28 13:22   ` walter harms [this message]
2010-06-28 13:22     ` walter harms
2010-06-29  0:58     ` Simon Horman
2010-06-29  0:58       ` Simon Horman
2010-06-29  1:00 ` Simon Horman
2010-06-29  1:00   ` Simon Horman
2010-06-29  9:31 ` walter harms
2010-06-29 10:31 ` Kulikov Vasiliy
2010-06-29 11:09 ` walter harms

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4C28A229.10503@bfs.de \
    --to=wharms@bfs.de \
    --cc=andrea.gelmini@gelma.net \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@suse.de \
    --cc=horms@verge.net.au \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=segooon@gmail.com \
    --cc=trivial@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.