Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753221AbZJYSjj (ORCPT ); Sun, 25 Oct 2009 14:39:39 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751946AbZJYSjj (ORCPT ); Sun, 25 Oct 2009 14:39:39 -0400 Received: from out2.smtp.messagingengine.com ([66.111.4.26]:55576 "EHLO out2.smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751094AbZJYSji (ORCPT ); Sun, 25 Oct 2009 14:39:38 -0400 X-Sasl-enc: mlrTDtcbhJTFIPEK9HIu168aE0608YKkmmvzBjDo+zv6 1256495982 Date: Sun, 25 Oct 2009 16:39:39 -0200 From: Henrique de Moraes Holschuh To: =?iso-8859-1?Q?Andr=E9?= Goddard Rosa Cc: gregkh@suse.de, alan@linux.intel.com, Andrew Morton , adobriyan@gmail.com, linux list Subject: Re: [PATCH 2/2] serial: cascade needless conditionals Message-ID: <20091025183939.GB10898@khazad-dum.debian.net> References: <20091025162019.GA10898@khazad-dum.debian.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-GPG-Fingerprint: 1024D/1CDB0FE3 5422 5C61 F6B7 06FB 7E04 3738 EE25 DE3F 1CDB 0FE3 User-Agent: Mutt/1.5.20 (2009-06-14) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1395 Lines: 34 On Sun, 25 Oct 2009, Andr? Goddard Rosa wrote: > On 10/25/09, Henrique de Moraes Holschuh wrote: > > 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. > > Do you mind explaining why? Notice that it's not (var & flag), it's =='. > Can flags be equal more than one flag at the same time? No, I obviously am going through coffee withdrawal :( Sorry about this. -- "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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/