From: Dan Carpenter <dan.carpenter@oracle.com>
To: Johnny Kim <johnny.kim@atmel.com>
Cc: Tony Cho <tony.cho@atmel.com>,
devel@driverdev.osuosl.org, rachel.kim@atmel.com,
chris.park@atmel.com, gregkh@linuxfoundation.org,
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:12:24 +0300 [thread overview]
Message-ID: <20150818091224.GM5558@mwanda> (raw)
In-Reply-To: <55D2A23D.2080209@atmel.com>
On Tue, Aug 18, 2015 at 12:10:53PM +0900, Johnny Kim wrote:
> 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.
I thought we had created "id" here in this patch so we don't have to
pass function pointers through a u32 value (which can't fit a 64 bit
pointer). What do you mean it is a "real ID value"? Is it there in
the hardware spec?
Anyway, this code is buggy and messy. Please find a different way to
write it.
regards,
dan carpenter
next prev parent reply other threads:[~2015-08-18 9:12 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
2015-08-18 9:12 ` Dan Carpenter [this message]
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=20150818091224.GM5558@mwanda \
--to=dan.carpenter@oracle.com \
--cc=chris.park@atmel.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=johnny.kim@atmel.com \
--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 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.