public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] staging: keucr: Use memcpy() instad of custom StringCopy() and some style cleanups
@ 2010-12-31 19:28 Javier Martinez Canillas
  2011-01-01 23:41 ` [PATCH 2/2] staging: keucr: Use memcpy() instad of custom Gábor Stefanik
  2011-01-02  5:34 ` Dan Carpenter
  0 siblings, 2 replies; 3+ messages in thread
From: Javier Martinez Canillas @ 2010-12-31 19:28 UTC (permalink / raw)
  To: kernel-janitors


Signed-off-by: Javier Martinez Canillas <martinez.javier@gmail.com>
---
 drivers/staging/keucr/smilecc.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/keucr/smilecc.c b/drivers/staging/keucr/smilecc.c
index daf322a..f9e515d 100644
--- a/drivers/staging/keucr/smilecc.c
+++ b/drivers/staging/keucr/smilecc.c
@@ -182,13 +182,15 @@ BYTE *buf;
 BYTE *redundant_ecc;
 BYTE *calculate_ecc;
 {
-    DWORD err;
-
-    err=correct_data(buf,redundant_ecc,*(calculate_ecc+1),*(calculate_ecc),*(calculate_ecc+2));
-    if (err=1) StringCopy(calculate_ecc,redundant_ecc,3);
-        if (err=0 || err=1 || err=2)
-            return(0);
-    return(-1);
+	DWORD err;
+	err = correct_data(buf, redundant_ecc, *(calculate_ecc+1),
+			   *(calculate_ecc), *(calculate_ecc+2));
+	if (err = 1)
+		memcpy(calculate_ecc, redundant_ecc, 3);
+
+	if (err = 0 || err = 1 || err = 2)
+		return 0;
+	return -1;
 }
 
 void _Calculate_D_SwECC(buf,ecc)
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] staging: keucr: Use memcpy() instad of custom
  2010-12-31 19:28 [PATCH 2/2] staging: keucr: Use memcpy() instad of custom StringCopy() and some style cleanups Javier Martinez Canillas
@ 2011-01-01 23:41 ` Gábor Stefanik
  2011-01-02  5:34 ` Dan Carpenter
  1 sibling, 0 replies; 3+ messages in thread
From: Gábor Stefanik @ 2011-01-01 23:41 UTC (permalink / raw)
  To: kernel-janitors

On Fri, Dec 31, 2010 at 8:28 PM, Javier Martinez Canillas
<martinez.javier@gmail.com> wrote:
>
> Signed-off-by: Javier Martinez Canillas <martinez.javier@gmail.com>
> ---
>  drivers/staging/keucr/smilecc.c |   16 +++++++++-------
>  1 files changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/staging/keucr/smilecc.c b/drivers/staging/keucr/smilecc.c
> index daf322a..f9e515d 100644
> --- a/drivers/staging/keucr/smilecc.c
> +++ b/drivers/staging/keucr/smilecc.c
> @@ -182,13 +182,15 @@ BYTE *buf;
>  BYTE *redundant_ecc;
>  BYTE *calculate_ecc;
>  {
> -    DWORD err;
> -
> -    err=correct_data(buf,redundant_ecc,*(calculate_ecc+1),*(calculate_ecc),*(calculate_ecc+2));
> -    if (err=1) StringCopy(calculate_ecc,redundant_ecc,3);
> -        if (err=0 || err=1 || err=2)
> -            return(0);
> -    return(-1);
> +       DWORD err;
> +       err = correct_data(buf, redundant_ecc, *(calculate_ecc+1),
> +                          *(calculate_ecc), *(calculate_ecc+2));

Any reason why you didn't unify these 2 lines? Like this: DWORD err correct_data(...);

> +       if (err = 1)
> +               memcpy(calculate_ecc, redundant_ecc, 3);
> +
> +       if (err = 0 || err = 1 || err = 2)
> +               return 0;
> +       return -1;
>  }
>
>  void _Calculate_D_SwECC(buf,ecc)
> --
> 1.7.0.4
>
> _______________________________________________
> devel mailing list
> devel@linuxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/devel
>



-- 
Vista: [V]iruses, [I]ntruders, [S]pyware, [T]rojans and [A]dware. :-)
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 2/2] staging: keucr: Use memcpy() instad of custom
  2010-12-31 19:28 [PATCH 2/2] staging: keucr: Use memcpy() instad of custom StringCopy() and some style cleanups Javier Martinez Canillas
  2011-01-01 23:41 ` [PATCH 2/2] staging: keucr: Use memcpy() instad of custom Gábor Stefanik
@ 2011-01-02  5:34 ` Dan Carpenter
  1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2011-01-02  5:34 UTC (permalink / raw)
  To: kernel-janitors

On Sun, Jan 02, 2011 at 12:41:33AM +0100, Gábor Stefanik wrote:
> On Fri, Dec 31, 2010 at 8:28 PM, Javier Martinez Canillas
> <martinez.javier@gmail.com> wrote:
> > +       DWORD err;
> > +       err = correct_data(buf, redundant_ecc, *(calculate_ecc+1),
> > +                          *(calculate_ecc), *(calculate_ecc+2));
> 
> Any reason why you didn't unify these 2 lines? Like this: DWORD err > correct_data(...);
> 

These kind of things aren't described in CodingStyle so they're up to
whoever writes the code to decide.  Or if the maintainer is a
micromanager the maintainer can decide.

But personally I much prefer to put anything complicated on separate
lines.  No one reads the initializers.  In my work with Smatch I see a
lot of bugs like this:

	int x = foo->bar;

	if (!foo)
		return -EINVAL;

It's astounding how many.  The famous tun.c security bug was one of
these.

But there should  have been a blank line between the initializers and
the code.  Otherwise people will think the code is initiliazation and
ignore it.  That is in CodingStyle I think.  We can fix that when we get
rid of the DWORD data type in a later patch (don't resend).

regards,
dan carpenter

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-01-02  5:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-31 19:28 [PATCH 2/2] staging: keucr: Use memcpy() instad of custom StringCopy() and some style cleanups Javier Martinez Canillas
2011-01-01 23:41 ` [PATCH 2/2] staging: keucr: Use memcpy() instad of custom Gábor Stefanik
2011-01-02  5:34 ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox