From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38875) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWIcj-0000vB-5D for qemu-devel@nongnu.org; Mon, 31 Aug 2015 02:31:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZWIcf-0000NI-VK for qemu-devel@nongnu.org; Mon, 31 Aug 2015 02:31:21 -0400 Received: from mga02.intel.com ([134.134.136.20]:8739) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZWIcf-0000Mz-Ok for qemu-devel@nongnu.org; Mon, 31 Aug 2015 02:31:17 -0400 References: <1439563931-12352-1-git-send-email-guangrong.xiao@linux.intel.com> <1439563931-12352-14-git-send-email-guangrong.xiao@linux.intel.com> <20150825161628.GF8344@stefanha-thinkpad.redhat.com> <55DD97F9.5050003@linux.intel.com> <20150828115955.GN4917@stefanha-thinkpad.redhat.com> From: Xiao Guangrong Message-ID: <55E3F351.5040903@linux.intel.com> Date: Mon, 31 Aug 2015 14:25:21 +0800 MIME-Version: 1.0 In-Reply-To: <20150828115955.GN4917@stefanha-thinkpad.redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v2 13/18] nvdimm: build namespace config data List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: ehabkost@redhat.com, kvm@vger.kernel.org, mst@redhat.com, gleb@kernel.org, Stefan Hajnoczi , mtosatti@redhat.com, qemu-devel@nongnu.org, pbonzini@redhat.com, imammedo@redhat.com, rth@twiddle.net On 08/28/2015 07:59 PM, Stefan Hajnoczi wrote: > On Wed, Aug 26, 2015 at 06:42:01PM +0800, Xiao Guangrong wrote: >> >> >> On 08/26/2015 12:16 AM, Stefan Hajnoczi wrote: >>> On Fri, Aug 14, 2015 at 10:52:06PM +0800, Xiao Guangrong wrote: >>>> +#ifdef NVDIMM_DEBUG >>>> +#define nvdebug(fmt, ...) fprintf(stderr, "nvdimm: " fmt, ## __VA_ARGS__) >>>> +#else >>>> +#define nvdebug(...) >>>> +#endif >>> >>> The following allows the compiler to check format strings and syntax >>> check the argument expressions: >>> >>> #define NVDIMM_DEBUG 0 /* set to 1 for debug output */ >>> #define nvdebug(fmt, ...) \ >>> if (NVDIMM_DEBUG) { \ >>> fprintf(stderr, "nvdimm: " fmt, ## __VA_ARGS__); \ >>> } >>> >>> This approach avoids bitrot (e.g. debug format string arguments have >>> become outdated). >>> >> >> Really good tips, thanks for your sharing. > > I forgot the do { ... } while (0) in the macro to make nvdebug("hello > world"); work like a normal C statement. > Got it, will keep it in my mind.