From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58921) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xyebz-0000Do-Eb for qemu-devel@nongnu.org; Wed, 10 Dec 2014 05:35:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xyebm-0007fS-7H for qemu-devel@nongnu.org; Wed, 10 Dec 2014 05:35:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39378) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xyebl-0007c0-Vy for qemu-devel@nongnu.org; Wed, 10 Dec 2014 05:35:02 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sBAAZ1aT007239 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 10 Dec 2014 05:35:01 -0500 From: Kevin Wolf Date: Wed, 10 Dec 2014 11:33:46 +0100 Message-Id: <1418207679-32260-21-git-send-email-kwolf@redhat.com> In-Reply-To: <1418207679-32260-1-git-send-email-kwolf@redhat.com> References: <1418207679-32260-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 20/73] ahci: avoid #ifdef DEBUG_AHCI bitrot List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com From: Stefan Hajnoczi Debug code using #ifdef is susceptible to bitrot because the compiler never checks the debug code. This is easy to avoid, change the DPRINTF() macro to use if (DEBUG_AHCI) and always give it a 0 or 1 value. This also allows us to drop an #ifdef DEBUG_AHCI in ahci_start_dma() since the compiler can now see the local variable is used. The motivation for this change is a recent DEBUG_AHCI build failure due to an outdated DPRINTF() format string. From now on the compiler will catch these errors. Cc: John Snow Signed-off-by: Stefan Hajnoczi Reviewed-by: John Snow Message-id: 1415874281-7371-2-git-send-email-stefanha@redhat.com Signed-off-by: Kevin Wolf --- hw/ide/ahci.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c index 94f28e6..9cfa82b 100644 --- a/hw/ide/ahci.c +++ b/hw/ide/ahci.c @@ -34,15 +34,15 @@ #include #include -/* #define DEBUG_AHCI */ +#define DEBUG_AHCI 0 -#ifdef DEBUG_AHCI #define DPRINTF(port, fmt, ...) \ -do { fprintf(stderr, "ahci: %s: [%d] ", __FUNCTION__, port); \ - fprintf(stderr, fmt, ## __VA_ARGS__); } while (0) -#else -#define DPRINTF(port, fmt, ...) do {} while(0) -#endif +do { \ + if (DEBUG_AHCI) { \ + fprintf(stderr, "ahci: %s: [%d] ", __func__, port); \ + fprintf(stderr, fmt, ## __VA_ARGS__); \ + } \ +} while (0) static void check_cmd(AHCIState *s, int port); static int handle_cmd(AHCIState *s,int port,int slot); @@ -551,7 +551,7 @@ static void ahci_reset_port(AHCIState *s, int port) static void debug_print_fis(uint8_t *fis, int cmd_len) { -#ifdef DEBUG_AHCI +#if DEBUG_AHCI int i; fprintf(stderr, "fis:"); @@ -1154,9 +1154,7 @@ out: static void ahci_start_dma(IDEDMA *dma, IDEState *s, BlockCompletionFunc *dma_cb) { -#ifdef DEBUG_AHCI AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma); -#endif DPRINTF(ad->port_no, "\n"); s->io_buffer_offset = 0; dma_cb(s, 0); -- 1.8.3.1