From patchwork Tue Jul 7 15:02:04 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ameya Palande X-Patchwork-Id: 34459 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n67F2aMg027828 for ; Tue, 7 Jul 2009 15:02:36 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757473AbZGGPCQ (ORCPT ); Tue, 7 Jul 2009 11:02:16 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757606AbZGGPCQ (ORCPT ); Tue, 7 Jul 2009 11:02:16 -0400 Received: from smtp.nokia.com ([192.100.122.230]:61406 "EHLO mgw-mx03.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757473AbZGGPCP (ORCPT ); Tue, 7 Jul 2009 11:02:15 -0400 Received: from vaebh105.NOE.Nokia.com (vaebh105.europe.nokia.com [10.160.244.31]) by mgw-mx03.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id n67F1kiu005289; Tue, 7 Jul 2009 18:02:04 +0300 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by vaebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Tue, 7 Jul 2009 18:02:08 +0300 Received: from mgw-sa02.ext.nokia.com ([147.243.1.48]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Tue, 7 Jul 2009 18:02:08 +0300 Received: from localhost.localdomain (esdhcp04183.research.nokia.com [172.21.41.83]) by mgw-sa02.ext.nokia.com (Switch-3.2.6/Switch-3.2.6) with ESMTP id n67F26IT018256; Tue, 7 Jul 2009 18:02:06 +0300 From: Ameya Palande To: linux-omap@vger.kernel.org Cc: x0095840@ti.com, h-kanigeri2@ti.com, ext-phil.2.carmody@nokia.com Subject: [PATCH 1/4] DSPBRIDGE: Fix macros that break when inside an if/else Date: Tue, 7 Jul 2009 18:02:04 +0300 Message-Id: <1246978928-7139-1-git-send-email-ameya.palande@nokia.com> X-Mailer: git-send-email 1.6.2.4 X-OriginalArrivalTime: 07 Jul 2009 15:02:08.0114 (UTC) FILETIME=[E5C53D20:01C9FF13] X-Nokia-AV: Clean Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Phil Carmody cp_{to,fm}_usr break if between an if and an else (with no {}). http://www.faqs.org/faqs/C-faq/abridged/ 10.4: What's the best way to write a multi-statement macro? A: #define Func() do {stmt1; stmt2; ... } while(0) /* (no trailing ;) */ Signed-off-by: Phil Carmody --- drivers/dsp/bridge/pmgr/wcd.c | 42 ++++++++++++++++++++++------------------ 1 files changed, 23 insertions(+), 19 deletions(-) diff --git a/drivers/dsp/bridge/pmgr/wcd.c b/drivers/dsp/bridge/pmgr/wcd.c index 86812c6..aaf3019 100644 --- a/drivers/dsp/bridge/pmgr/wcd.c +++ b/drivers/dsp/bridge/pmgr/wcd.c @@ -147,25 +147,29 @@ /* Following two macros should ideally have do{}while(0) */ -#define cp_fm_usr(dest, src, status, elements) \ - if (DSP_SUCCEEDED(status)) {\ - if (unlikely(src == NULL) || \ - unlikely(copy_from_user(dest, src, elements * sizeof(*(dest))))) { \ - GT_1trace(WCD_debugMask, GT_7CLASS, \ - "copy_from_user failed, src=0x%x\n", src); \ - status = DSP_EPOINTER ; \ - } \ - } - -#define cp_to_usr(dest, src, status, elements) \ - if (DSP_SUCCEEDED(status)) {\ - if (unlikely(dest == NULL) || \ - unlikely(copy_to_user(dest, src, elements * sizeof(*(src))))) { \ - GT_1trace(WCD_debugMask, GT_7CLASS, \ - "copy_to_user failed, dest=0x%x\n", dest); \ - status = DSP_EPOINTER ;\ - } \ - } +#define cp_fm_usr(dest, src, status, elements) \ + do { \ + if (DSP_SUCCEEDED(status)) { \ + if (unlikely((src) == NULL) || \ + unlikely(copy_from_user(dest, src, (elements) * sizeof(*(dest))))) { \ + GT_1trace(WCD_debugMask, GT_7CLASS, \ + "copy_from_user failed, src=0x%x\n", src); \ + (status) = DSP_EPOINTER ; \ + } \ + } \ + } while (0) + +#define cp_to_usr(dest, src, status, elements) \ + do { \ + if (DSP_SUCCEEDED(status)) { \ + if (unlikely((dest) == NULL) || \ + unlikely(copy_to_user(dest, src, (elements) * sizeof(*(src))))) { \ + GT_1trace(WCD_debugMask, GT_7CLASS, \ + "copy_to_user failed, dest=0x%x\n", dest); \ + (status) = DSP_EPOINTER ; \ + } \ + } \ + } while (0) /* Device IOCtl function pointer */ struct WCD_Cmd {