Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Mar 2014 13:55:23 -0700
From:      John-Mark Gurney <jmg@funkthat.com>
To:        Edward Tomasz Napierala <trasz@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r263740 - in head/sys: cam/ctl dev/iscsi
Message-ID:  <20140325205523.GA60889@funkthat.com>
In-Reply-To: <201403251830.s2PIUvIu029793@svn.freebsd.org>
References:  <201403251830.s2PIUvIu029793@svn.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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;

You would get a compile error:
t.c:11: error: expected expression before 'else'

Now it'll compile properly...

Thanks for the fix!

> @@ -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)
>  

-- 
  John-Mark Gurney				Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140325205523.GA60889>