From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37270) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wlnf5-0006ui-R3 for qemu-devel@nongnu.org; Sat, 17 May 2014 19:05:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wlnew-00048A-Mu for qemu-devel@nongnu.org; Sat, 17 May 2014 19:05:03 -0400 Received: from mail-wi0-x235.google.com ([2a00:1450:400c:c05::235]:40284) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wlnew-00047S-GI for qemu-devel@nongnu.org; Sat, 17 May 2014 19:04:54 -0400 Received: by mail-wi0-f181.google.com with SMTP id n15so2532389wiw.8 for ; Sat, 17 May 2014 16:04:53 -0700 (PDT) From: =?UTF-8?q?Marc=20Mar=C3=AD?= Date: Sun, 18 May 2014 01:03:43 +0200 Message-Id: <1400367823-32610-17-git-send-email-marc.mari.barcelo@gmail.com> In-Reply-To: <1400367823-32610-1-git-send-email-marc.mari.barcelo@gmail.com> References: <1400367823-32610-1-git-send-email-marc.mari.barcelo@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH v3 16/16] common: Convert debug printfs to QEMU_DPRINTF List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Marc=20Mar=C3=AD?= , Stefan Hajnoczi , Peter Crosthwaite , =?UTF-8?q?Andreas=20F=C3=A4rber?= Modify debug macros to have the same format through the codebase and use regular ifs instead of ifdef. Signed-off-by: Marc MarĂ­ --- migration-rdma.c | 31 +++++++++++++++++-------------- page_cache.c | 11 +++++++---- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/migration-rdma.c b/migration-rdma.c index eeb4302..606ee7c 100644 --- a/migration-rdma.c +++ b/migration-rdma.c @@ -32,36 +32,39 @@ //#define DEBUG_RDMA_REALLY_VERBOSE #ifdef DEBUG_RDMA -#define DPRINTF(fmt, ...) \ - do { printf("rdma: " fmt, ## __VA_ARGS__); } while (0) +#define DEBUG_RDMA_ENABLED 1 #else -#define DPRINTF(fmt, ...) \ - do { } while (0) +#define DEBUG_RDMA_ENABLED 0 #endif +#define DPRINTF(fmt, ...) \ + QEMU_DPRINTF(DEBUG_RDMA_ENABLED, "rdma", fmt, ## __VA_ARGS__) + #ifdef DEBUG_RDMA_VERBOSE -#define DDPRINTF(fmt, ...) \ - do { printf("rdma: " fmt, ## __VA_ARGS__); } while (0) +#define DEBUG_RDMA_VERBOSE_ENABLED 1 #else -#define DDPRINTF(fmt, ...) \ - do { } while (0) +#define DEBUG_RDMA_VERBOSE_ENABLED 0 #endif +#define DDPRINTF(fmt, ...) \ + QEMU_DPRINTF(DEBUG_RDMA_VERBOSE_ENABLED, "rdma", fmt, ## __VA_ARGS__) + #ifdef DEBUG_RDMA_REALLY_VERBOSE -#define DDDPRINTF(fmt, ...) \ - do { printf("rdma: " fmt, ## __VA_ARGS__); } while (0) +#define DEBUG_RDMA_REALLY_VERBOSE_ENABLED 1 #else -#define DDDPRINTF(fmt, ...) \ - do { } while (0) +#define DEBUG_RDMA_REALLY_VERBOSE_ENABLED 0 #endif +#define DDDPRINTF(fmt, ...) \ + QEMU_DPRINTF(DEBUG_RDMA_REALLY_VERBOSE_ENABLED, "rdma", fmt, ## __VA_ARGS__) + /* * Print and error on both the Monitor and the Log file. */ #define ERROR(errp, fmt, ...) \ do { \ - fprintf(stderr, "RDMA ERROR: " fmt "\n", ## __VA_ARGS__); \ - if (errp && (*(errp) == NULL)) { \ + QEMU_DPRINTF(1, "RDMA ERROR", fmt"\n", ## __VA_ARGS__); \ + if (errp && !*errp) { \ error_setg(errp, "RDMA ERROR: " fmt, ## __VA_ARGS__); \ } \ } while (0) diff --git a/page_cache.c b/page_cache.c index b033681..be206a4 100644 --- a/page_cache.c +++ b/page_cache.c @@ -25,14 +25,17 @@ #include "qemu-common.h" #include "migration/page_cache.h" +//#define DEBUG_CACHE 1 + #ifdef DEBUG_CACHE -#define DPRINTF(fmt, ...) \ - do { fprintf(stdout, "cache: " fmt, ## __VA_ARGS__); } while (0) +#define DEBUG_CACHE_ENABLED 1 #else -#define DPRINTF(fmt, ...) \ - do { } while (0) +#define DEBUG_CACHE_ENABLED 0 #endif +#define DPRINTF(fmt, ...) \ + QEMU_DPRINTF(DEBUG_CACHE_ENABLED, "cache", fmt, ## __VA_ARGS__) + typedef struct CacheItem CacheItem; struct CacheItem { -- 1.7.10.4