From owner-freebsd-usb@FreeBSD.ORG Thu Aug 17 22:55:19 2006 Return-Path: X-Original-To: usb@freebsd.org Delivered-To: freebsd-usb@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E76AD16A4DD for ; Thu, 17 Aug 2006 22:55:19 +0000 (UTC) (envelope-from prvs=julian=377da0077@elischer.org) Received: from a50.ironport.com (a50.ironport.com [63.251.108.112]) by mx1.FreeBSD.org (Postfix) with ESMTP id 88A7243D46 for ; Thu, 17 Aug 2006 22:55:19 +0000 (GMT) (envelope-from prvs=julian=377da0077@elischer.org) Received: from unknown (HELO [10.251.18.229]) ([10.251.18.229]) by a50.ironport.com with ESMTP; 17 Aug 2006 15:55:19 -0700 Message-ID: <44E4F3D6.9040808@elischer.org> Date: Thu, 17 Aug 2006 15:55:18 -0700 From: Julian Elischer User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.13) Gecko/20060414 X-Accept-Language: en-us, en MIME-Version: 1.0 To: John-Mark Gurney References: <35069.85.132.32.38.1155816624.squirrel@85.132.32.38> <20060817223716.GW99774@funkthat.com> In-Reply-To: <20060817223716.GW99774@funkthat.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Cc: usb@freebsd.org, Tofig Suleymanov Subject: Re: USB_ATTACH_SETUP macros question X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Aug 2006 22:55:20 -0000 John-Mark Gurney wrote: >Tofig Suleymanov wrote this message on Thu, Aug 17, 2006 at 17:10 +0500: > > >>is there anybody to explain why do we have infinite loop inside of >>USB_ATTACH_SETUP macros inside of usb_port.h ? How does his loop gets >>escaped when we use it in some usb driver ? >> >>#define USB_ATTACH_SETUP \ >> do { \ >> sc->sc_dev = self; \ >> device_set_desc_copy(self, devinfo); \ >> device_printf(self, "%s\n", devinfo); \ >> } while (0); >> >> > >The real bug here is the extra ; after the while(0) part... because >if you use it as such: > if (case) > USB_ATTACH_SETUP; > else > somethingelse; > >you will get a compile error due to the double semicolon... > > yes style(9) specifies this form of macro should NOT have the semicolon. >In cases like this, it is also common to have parens after the macro >name so that it looks like a function, and not a simple expresion. > > yes