From: Kulikov Vasiliy <segooon@gmail.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 11/16] trivial: use ARRAY_SIZE
Date: Tue, 29 Jun 2010 10:31:33 +0000 [thread overview]
Message-ID: <20100629103133.GA28841@shinshilla> (raw)
In-Reply-To: <1277726125-24765-1-git-send-email-segooon@gmail.com>
On Tue, Jun 29, 2010 at 11:31 +0200, walter harms wrote:
> >> 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 = ®DomainPairs[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.
> >
> > Either of those suggestions sounds fine to me, but it sounds
> > like it should be in a separate patch.
> >
> >> re,
> >> wh
> >>
> >> for (i=0; i<ARRAY_SIZE(regDomainPairs);i++ )
> >> if (regDomainPairs[i].regDmnEnum = regionCode)
> >> { regPair = ®DomainPairs[i]; break ; }
> >>
> >> if (!regPair) {
> >> zm_debug_msg1("Failed to find reg domain pair ", regionCode);
> >> return FALSE;
> >> }
> >>
> >>
>
> Hi Kulikov Vasiliy,
> can you make that patch also, i have simply no time (and no actual kernel)
> feel free to choose a methode you like.
Hi,
We cannot trivially create array element with .regDmnEnum = 0 because one
element already has got this value:
static REG_DMN_PAIR_MAPPING regDomainPairs[] = {
{NO_ENUMRD, FCC2, DEBUG_REG_DMN, NO_REQ, NO_REQ, PSCAN_DEFER, 0 },
enum EnumRd {
NO_ENUMRD = 0x00,
And I don't think that creating another constant with meaning 'element after the last' from
the set 'any u16 except already used' is a good idea. If this value is added to the array
in future we must change this magic constant too. And current implementation just works :)
next prev parent reply other threads:[~2010-06-29 10:31 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
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 [this message]
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=20100629103133.GA28841@shinshilla \
--to=segooon@gmail.com \
--cc=kernel-janitors@vger.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.