[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20091025162019.GA10898@khazad-dum.debian.net>
Date:	Sun, 25 Oct 2009 14:20:19 -0200
From:	Henrique de Moraes Holschuh <hmh@....eng.br>
To:	André Goddard Rosa <andre.goddard@...il.com>
Cc:	gregkh@...e.de, alan@...ux.intel.com,
	Andrew Morton <akpm@...ux-foundation.org>, adobriyan@...il.com,
	linux list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] serial: cascade needless conditionals
On Sun, 25 Oct 2009, André Goddard Rosa wrote:
>  	if (flags == UPF_SPD_HI)
>  		altbaud = 57600;
> -	if (flags == UPF_SPD_VHI)
> +	else if (flags == UPF_SPD_VHI)
>  		altbaud = 115200;
> -	if (flags == UPF_SPD_SHI)
> +	else if (flags == UPF_SPD_SHI)
>  		altbaud = 230400;
> -	if (flags == UPF_SPD_WARP)
> +	else if (flags == UPF_SPD_WARP)
>  		altbaud = 460800;
This changes code behaviour if more than one bit is set (which might never
happen for all I know...).  You should invert the order of the tests if you
want to make sure it is side-effect-free. 
-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique Holschuh
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Powered by blists - more mailing lists
 
