From owner-svn-src-all@FreeBSD.ORG Wed Mar 26 03:20:35 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 47A471E5; Wed, 26 Mar 2014 03:20:35 +0000 (UTC) Received: from mail108.syd.optusnet.com.au (mail108.syd.optusnet.com.au [211.29.132.59]) by mx1.freebsd.org (Postfix) with ESMTP id 085A1D6C; Wed, 26 Mar 2014 03:20:34 +0000 (UTC) Received: from c122-106-147-133.carlnfd1.nsw.optusnet.com.au (c122-106-147-133.carlnfd1.nsw.optusnet.com.au [122.106.147.133]) by mail108.syd.optusnet.com.au (Postfix) with ESMTPS id 86B5D1A5534; Wed, 26 Mar 2014 13:58:58 +1100 (EST) Date: Wed, 26 Mar 2014 13:58:57 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: John-Mark Gurney Subject: Re: svn commit: r263740 - in head/sys: cam/ctl dev/iscsi In-Reply-To: <20140325205523.GA60889@funkthat.com> Message-ID: <20140326134456.V1525@besplex.bde.org> References: <201403251830.s2PIUvIu029793@svn.freebsd.org> <20140325205523.GA60889@funkthat.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=PqKqMW83 c=1 sm=1 tr=0 a=7NqvjVvQucbO2RlWB8PEog==:117 a=PO7r1zJSAAAA:8 a=mhVUI_e9FtMA:10 a=kj9zAlcOel0A:10 a=JzwRw_2MAAAA:8 a=6I5d2MoRAAAA:8 a=rDVvgjhvMZaOE9O5LnMA:9 a=CjuIK1q_8ugA:10 Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Edward Tomasz Napierala X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 26 Mar 2014 03:20:35 -0000 On Tue, 25 Mar 2014, John-Mark Gurney wrote: > Edward Tomasz Napierala wrote this message on Tue, Mar 25, 2014 at 18:30 +0000: >> Author: trasz >> Date: Tue Mar 25 18:30:57 2014 >> New Revision: 263740 >> URL: http://svnweb.freebsd.org/changeset/base/263740 >> >> Log: >> Use a less unusual syntax in debug printfs. > > Just for reference, this is partly a bug fix... > > if { xxx } while (0) > > is two statements, and if you tried to use the macros as such: > if (something) > MACRO(param) > else > somethingelse; It seems to be entirely this bug fix, except for massive churning of the indentation. >> @@ -98,29 +98,38 @@ SYSCTL_INT(_kern_cam_ctl_iscsi, OID_AUTO >> &maxcmdsn_delta, 256, "Number of commands the initiator can send " >> "without confirmation"); >> >> -#define CFISCSI_DEBUG(X, ...) \ >> - if (debug > 1) { \ >> - printf("%s: " X "\n", __func__, ## __VA_ARGS__);\ >> +#define CFISCSI_DEBUG(X, ...) \ >> + do { \ >> + if (debug > 1) { \ >> + printf("%s: " X "\n", \ >> + __func__, ## __VA_ARGS__); \ >> + } \ >> } while (0) >> Normal style is as in sys/queue.h. It doesn't make the code less readable by pushing the non-do-while parts of it to the right, and didn't churn the indentation when adding do-while. Normal style is also used for the more directly related KASSERT()... BTW, KASSERT() is still dumbed down to work K&R compilers that don't support __VA_ARGS__. This is hard to fix since its collateral bad syntax is used in thousands of callers. Automatic printing of the function names was intentionally left out of KASSERT(), so that callers could omit it if they wanted, but this has resulted in lots of ugly syntax and source code bloat in callers. Here the ugly syntax is hidden in the macro, and the bloat is mostly at runtime. Bruce