Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751317AbWCZMaf (ORCPT ); Sun, 26 Mar 2006 07:30:35 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751318AbWCZMae (ORCPT ); Sun, 26 Mar 2006 07:30:34 -0500 Received: from smtpout.mac.com ([17.250.248.70]:58092 "EHLO smtpout.mac.com") by vger.kernel.org with ESMTP id S1751317AbWCZMae convert rfc822-to-8bit (ORCPT ); Sun, 26 Mar 2006 07:30:34 -0500 In-Reply-To: References: <20060321082327.B653275@wobbly.melbourne.sgi.com> <20060321084619.E653275@wobbly.melbourne.sgi.com> Mime-Version: 1.0 (Apple Message framework v746.3) Content-Type: text/plain; charset=ISO-8859-1; delsp=yes; format=flowed Message-Id: <0BE1D87A-29F0-4633-86FA-57AE5C846C33@mac.com> Cc: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT From: Kyle Moffett Subject: Re: Parenthesize macros in xfs Date: Sun, 26 Mar 2006 07:30:24 -0500 To: =?ISO-8859-1?Q?M=E5ns_Rullg=E5rd?= X-Mailer: Apple Mail (2.746.3) Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 891 Lines: 36 On Mar 26, 2006, at 07:19:14, M?ns Rullg?rd wrote: > A double semicolon can cause all sorts of hard to debug problems. > Consider this: > > #define foo() bar(); > /* ... */ > if(x) > foo(); > else > baz(); > > This will expand to syntactically invalid code because of the extra > semicolon. More generically, the code "do { [...] } while(0)" can _always_ be substituted for the code "function_returning_void()" without changing the meaning of the surrounding code. Look at the following examples: for (i = 0; i < 10; i++) { macro(); } for (i = 0; i < 10; i++) if (i > 5) macro1(); else macro2(); Cheers, Kyle Moffett - 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/