From: Johnny Kim <johnny.kim@atmel.com>
To: Dan Carpenter <dan.carpenter@oracle.com>, Tony Cho <tony.cho@atmel.com>
Cc: <gregkh@linuxfoundation.org>, <devel@driverdev.osuosl.org>,
<rachel.kim@atmel.com>, <chris.park@atmel.com>,
<linux-wireless@vger.kernel.org>, <jude.lee@atmel.com>,
<leo.kim@atmel.com>
Subject: Re: [PATCH 5/5] staging: wilc1000: use id value as argument
Date: Tue, 18 Aug 2015 12:10:53 +0900 [thread overview]
Message-ID: <55D2A23D.2080209@atmel.com> (raw)
In-Reply-To: <20150813144907.GA4484@mwanda>
Hello Dan.
On 2015년 08월 13일 23:49, Dan Carpenter wrote:
> On Thu, Aug 13, 2015 at 01:41:23PM +0900, Tony Cho wrote:
>> +static u32 get_id_from_handler(tstrWILC_WFIDrv *handler)
>> +{
>> + u32 id;
>> +
>> + if (!handler)
>> + return 0;
>> +
>> + for (id = 0; id < NUM_CONCURRENT_IFC; id++) {
>> + if (wfidrv_list[id] == handler) {
>> + id += 1;
>> + break;
>> + }
>> + }
>> +
>> + if (id > NUM_CONCURRENT_IFC)
>> + return 0;
>> + else
>> + return id;
>> +}
>> +
> This still has an off by one bug. Just use zero offset arrays
> throughout.
>
> static int get_id_from_handler(tstrWILC_WFIDrv *handler)
> {
> int id;
>
> if (!handler)
> return -ENOBUFS;
>
> for (id = 0; id < NUM_CONCURRENT_IFC; id++) {
> if (wfidrv_list[id] == handler)
> return id;
> }
>
> return -ENOBUFS;
> }
Thanks for your review. The return value of this function has from 0 till 2.
1 and 2 value is real ID value. only 0 value is reserved to remove a
registered id.
But I also think that error handling should be added about the
overflowed value
as your opinion.
>> +static tstrWILC_WFIDrv *get_handler_from_id(u32 id)
>> +{
>> + if (id > 0 && id <= NUM_CONCURRENT_IFC)
>> + return wfidrv_list[id - 1];
>> + else
>> + return NULL;
>> +}
> static tstrWILC_WFIDrv *get_handler_from_id(int id)
> {
> if (id < 0 || id >= NUM_CONCURRENT_IFC)
> return NULL;
> return wfidrv_list[id];
> }
>
> regards,
> dan carpenter
>
Regards.
Johnny Kim.
next prev parent reply other threads:[~2015-08-18 3:11 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-13 4:41 [PATCH 0/5] staging: wilc1000: 64bit build patch Tony Cho
2015-08-13 4:41 ` [PATCH 1/5] staging: wilc1000: replace WILC_WFIDrvHandle by tstrWILC_WFIDrv Tony Cho
2015-08-13 4:41 ` [PATCH 2/5] staging: wilc1000: change void pointer type to real type Tony Cho
2015-08-14 6:26 ` Sudip Mukherjee
2015-08-15 2:01 ` Greg KH
2015-08-13 4:41 ` [PATCH 3/5] staging: wilc1000: clarify the argument type Tony Cho
2015-08-13 4:41 ` [PATCH 4/5] staging: wilc1000: use the real data type Tony Cho
2015-08-15 2:04 ` Greg KH
2015-08-13 4:41 ` [PATCH 5/5] staging: wilc1000: use id value as argument Tony Cho
2015-08-13 14:49 ` Dan Carpenter
2015-08-18 3:10 ` Johnny Kim [this message]
2015-08-18 9:12 ` Dan Carpenter
2015-08-19 7:58 ` Johnny Kim
2015-08-19 10:05 ` Dan Carpenter
-- strict thread matches above, loose matches on Subject: below --
2015-08-10 5:58 [PATCH 0/5] 64 bit build patch Tony Cho
2015-08-10 5:58 ` [PATCH 5/5] staging: wilc1000: use id value as argument Tony Cho
2015-08-10 6:47 ` Julian Calaby
2015-08-10 7:53 ` Johnny Kim
2015-08-10 10:44 ` Dan Carpenter
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=55D2A23D.2080209@atmel.com \
--to=johnny.kim@atmel.com \
--cc=chris.park@atmel.com \
--cc=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=jude.lee@atmel.com \
--cc=leo.kim@atmel.com \
--cc=linux-wireless@vger.kernel.org \
--cc=rachel.kim@atmel.com \
--cc=tony.cho@atmel.com \
/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 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).