From: Dan Carpenter <dan.carpenter@oracle.com>
To: Tony Cho <tony.cho@atmel.com>
Cc: gregkh@linuxfoundation.org, devel@driverdev.osuosl.org,
rachel.kim@atmel.com, chris.park@atmel.com,
austin.shin@atmel.com, linux-wireless@vger.kernel.org,
johnny.kim@atmel.com, Nicolas.FERRE@atmel.com,
jude.lee@atmel.com, leo.kim@atmel.com
Subject: Re: [PATCH 5/5] staging: wilc1000: use id value as argument
Date: Mon, 10 Aug 2015 13:44:12 +0300 [thread overview]
Message-ID: <20150810104412.GL5180@mwanda> (raw)
In-Reply-To: <1439186304-3480-6-git-send-email-tony.cho@atmel.com>
On Mon, Aug 10, 2015 at 02:58:24PM +0900, Tony Cho wrote:
> +static u32 add_handler_in_list(tstrWILC_WFIDrv *handler)
I am suspicous of code which uses u32 for something where the hardware
doesn't specify unsigned 32 bits. Why not just return "int"?
> +{
> + u32 id;
It looks like we have a case of u32 disease. Prefer int over u32 unless
there is a reason for it.
> +
> + if (!handler)
> + return 0;
Don't add NULL checks unless it makes sense. How are we supposed to
recover from this if handler is NULL?
> +
> + for (id = 0; id < NUM_CONCURRENT_IFC; id++) {
> + if (!wfidrv_list[id]) {
> + wfidrv_list[id++] = handler;
Ugh... I don't like the ++ here. Just use a zero offset array or we
are going to have off by one bugs.
> + break;
> + }
> + }
> +
> + if (id > NUM_CONCURRENT_IFC)
> + return 0;
Well, that didn't take long, it's three lines later and we already have
hit our first off by one bug. This check can never be true. Of course,
no one checks the return value either...
> +
> + return id;
> +}
I guess I would be fine with this patch if you changed it to use a zero
offset array, ints instead of u32s and added some error handling.
regards,
dan carpenter
next prev parent reply other threads:[~2015-08-10 10:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-10 5:58 [PATCH 0/5] 64 bit build patch Tony Cho
2015-08-10 5:58 ` [PATCH 1/5] staging: wilc1000: replace WILC_WFIDrvHandle by tstrWILC_WFIDrv Tony Cho
2015-08-10 5:58 ` [PATCH 2/5] staging: wilc1000: change void pointer type to real type Tony Cho
2015-08-10 5:58 ` [PATCH 3/5] staging: wilc1000: clarify the argument type Tony Cho
2015-08-10 5:58 ` [PATCH 4/5] staging: wilc1000: use the real data type 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 [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-08-13 4:41 [PATCH 0/5] staging: wilc1000: 64bit build patch Tony Cho
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
2015-08-19 7:58 ` Johnny Kim
2015-08-19 10:05 ` 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=20150810104412.GL5180@mwanda \
--to=dan.carpenter@oracle.com \
--cc=Nicolas.FERRE@atmel.com \
--cc=austin.shin@atmel.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 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).