Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753716AbZJYQhy (ORCPT ); Sun, 25 Oct 2009 12:37:54 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753359AbZJYQhx (ORCPT ); Sun, 25 Oct 2009 12:37:53 -0400 Received: from mail-vw0-f184.google.com ([209.85.212.184]:42980 "EHLO mail-vw0-f184.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752595AbZJYQhx convert rfc822-to-8bit (ORCPT ); Sun, 25 Oct 2009 12:37:53 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=TQp3kAI/TB2EsSlTO/qw9pg+MjCvcTXXwJtIM4b2JpTkA/uNbR0Ot2O5Nz3MGu6a6c iRFD3nud/9ZRkboOzkrvuASbtadyo+rsT9Z93zz+gddmBr76Zov4DaHH7HjreUOZRjXt GOvdu4VBqUmXJ8FM0QXJcvdwH8x1nYLCDnZZY= MIME-Version: 1.0 In-Reply-To: <20091025162019.GA10898@khazad-dum.debian.net> References: <20091025162019.GA10898@khazad-dum.debian.net> Date: Sun, 25 Oct 2009 14:37:57 -0200 Message-ID: Subject: Re: [PATCH 2/2] serial: cascade needless conditionals From: =?ISO-8859-1?Q?Andr=E9_Goddard_Rosa?= To: Henrique de Moraes Holschuh Cc: gregkh@suse.de, alan@linux.intel.com, Andrew Morton , adobriyan@gmail.com, linux list Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1050 Lines: 31 Hi, Henrique! 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? Thanks, Andr? -- 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/