[ofw] [PATCH] remove useless variable initialization
Smith, Stan
stan.smith at intel.com
Wed Sep 1 09:28:09 PDT 2010
Uri Habusha wrote:
> Hi Stan,
>
> I don't understand what is the problem with the variable
> initialization. I think it's safer and more code robust to set a
> default value to variable.
>
> I know it is theological argument, so I prefer to leave it to the
> developer decision, if the code is valid.
Extra instructions executed for no purpose as the results are never used and over-written in the next statement. Additionally extra code space consumed by useless instructions - granted it is not that much.
All in all, it's sloppy coding.
stan.
>
> Uri
>
> -----Original Message-----
> From: ofw-bounces at lists.openfabrics.org
> [mailto:ofw-bounces at lists.openfabrics.org] On Behalf Of Smith, Stan
> Sent: Tuesday, August 31, 2010 8:08 PM
> To: Tzachi Dar
> Cc: ofw at lists.openfabrics.org
> Subject: [ofw] [PATCH] remove useless variable initialization
>
>
> Remove useless variable initialization.
>
> signed-off-by: stan smith (stan.smith at intel.com)
>
> --- a/inc/kernel/shutter.h Tue Aug 31 10:03:12 2010
> +++ b/inc/kernel/shutter.h Tue Aug 31 09:53:34 2010
> @@ -51,7 +51,7 @@
>
> static inline void shutter_sub(shutter_t * p_shutter,long Val)
> {
> - long res = 0;
> + long res;
> ASSERT(Val < 0);
> res = InterlockedExchangeAdd( &p_shutter->cnt,Val );
> if ((res+Val) == -MAX_OPERATIONS)
> @@ -61,7 +61,7 @@
> // if RC == true, one can proceed
> static inline BOOLEAN shutter_add(shutter_t * p_shutter,long Val)
> {
> - long res = 0;
> + long res;
> ASSERT(Val > 0);
> res = InterlockedExchangeAdd(&p_shutter->cnt,Val);
> ASSERT(res <= MAX_OPERATIONS);
> @@ -93,7 +93,7 @@
>
> static inline void shutter_shut(shutter_t * p_shutter)
> {
> - long res = 0;
> + long res;
> //
> // ASSERT not calling shu twice.
> //
> _______________________________________________
> ofw mailing list
> ofw at lists.openfabrics.org
> http://lists.openfabrics.org/cgi-bin/mailman/listinfo/ofw
More information about the ofw
mailing list