From: Joe Perches <joe@perches.com>
To: kernel-janitors@vger.kernel.org
Subject: Re: [PATCH 1/2] staging: keucr: Use memcmp() instaed of custom
Date: Fri, 31 Dec 2010 20:26:00 +0000 [thread overview]
Message-ID: <1293827160.4058.17.camel@Joe-Laptop> (raw)
In-Reply-To: <1293823712-6273-2-git-send-email-martinez.javier@gmail.com>
On Fri, 2010-12-31 at 20:28 +0100, Javier Martinez Canillas wrote:
> Signed-off-by: Javier Martinez Canillas <martinez.javier@gmail.com>
Hi Javier.
> diff --git a/drivers/staging/keucr/smilsub.c b/drivers/staging/keucr/smilsub.c
[]
> int Check_D_ReadError(BYTE *redundant)
> {
> - // Driver 䣰 ECC Check
> - return(SUCCESS);
> - if (!StringCmp((char *)(redundant+0x0D),(char *)EccBuf,3))
> - if (!StringCmp((char *)(redundant+0x08),(char *)(EccBuf+0x03),3))
> - return(SUCCESS);
> + /* Driver ECC Check */
> + return SUCCESS;
> + if (!memcmp(redundant+0x0D, EccBuf, 3))
> + if (!memcmp(redundant+0x08, EccBuf+0x03, 3))
> + return SUCCESS;
Generally, it's better to have success at the end
of a function and either a goto error or return
error for error conditions.
Something like:
if (!(!memcmp(redundant+0x0D, EccBuf, 3) &&
!memcmp(redundant+0x08, EccBuf+0x03, 3)))
return ERROR;
return SUCCESS;
> int Check_D_Correct(BYTE *buf,BYTE *redundant)
> {
> - // Driver 䣰 ECC Check
> - return(SUCCESS);
> - if (StringCmp((char *)(redundant+0x0D),(char *)EccBuf,3))
> - if (_Correct_D_SwECC(buf,redundant+0x0D,EccBuf))
> - return(ERROR);
> -
> - buf+=0x100;
> - if (StringCmp((char *)(redundant+0x08),(char *)(EccBuf+0x03),3))
> - if (_Correct_D_SwECC(buf,redundant+0x08,EccBuf+0x03))
> - return(ERROR);
> -
> - return(SUCCESS);
> + /* Driver ECC Check */
> + return SUCCESS;
> + if (memcmp(redundant+0x0D, EccBuf, 3))
> + if (_Correct_D_SwECC(buf, redundant+0x0D, EccBuf))
> + return ERROR;
You might as well take out useless code after returns
instead of just changing function names.
If you keep it you should reformat it.
if (memcmp(redundant+0x0D, EccBuf, 3) &&
_Correct_D_SwECC(buf, redundant+0x0D, EccBuf))
return ERROR;
etc...
next prev parent reply other threads:[~2010-12-31 20:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-31 19:28 [PATCH 1/2] staging: keucr: Use memcmp() instaed of custom StringCmp() and some style cleanups Javier Martinez Canillas
2010-12-31 20:26 ` Joe Perches [this message]
2011-01-01 9:00 ` [PATCH 1/2] staging: keucr: Use memcmp() instaed of custom 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=1293827160.4058.17.camel@Joe-Laptop \
--to=joe@perches.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox