From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xiao Guangrong Subject: Re: [Qemu-devel] [PATCH v2 13/18] nvdimm: build namespace config data Date: Mon, 31 Aug 2015 14:25:21 +0800 Message-ID: <55E3F351.5040903@linux.intel.com> 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> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: Stefan Hajnoczi , pbonzini@redhat.com, imammedo@redhat.com, ehabkost@redhat.com, kvm@vger.kernel.org, mst@redhat.com, gleb@kernel.org, mtosatti@redhat.com, qemu-devel@nongnu.org, rth@twiddle.net To: Stefan Hajnoczi Return-path: Received: from mga11.intel.com ([192.55.52.93]:53809 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751862AbbHaGbR (ORCPT ); Mon, 31 Aug 2015 02:31:17 -0400 In-Reply-To: <20150828115955.GN4917@stefanha-thinkpad.redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 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.