From patchwork Mon Jul 13 12:38:46 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ameya Palande X-Patchwork-Id: 35370 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 n6DCcmUI016628 for ; Mon, 13 Jul 2009 12:38:48 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755536AbZGMMir (ORCPT ); Mon, 13 Jul 2009 08:38:47 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755586AbZGMMir (ORCPT ); Mon, 13 Jul 2009 08:38:47 -0400 Received: from smtp.nokia.com ([192.100.122.230]:17022 "EHLO mgw-mx03.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755574AbZGMMiq (ORCPT ); Mon, 13 Jul 2009 08:38:46 -0400 Received: from esebh105.NOE.Nokia.com (esebh105.ntc.nokia.com [172.21.138.211]) by mgw-mx03.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id n6DCcKk0007108; Mon, 13 Jul 2009 15:38:36 +0300 Received: from esebh102.NOE.Nokia.com ([172.21.138.183]) by esebh105.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 13 Jul 2009 15:38:41 +0300 Received: from mgw-sa02.ext.nokia.com ([147.243.1.48]) by esebh102.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Mon, 13 Jul 2009 15:38:40 +0300 Received: from localhost.localdomain (esdhcp04082.research.nokia.com [172.21.40.82]) by mgw-sa02.ext.nokia.com (Switch-3.2.6/Switch-3.2.6) with ESMTP id n6DCcd8p012027; Mon, 13 Jul 2009 15:38:39 +0300 From: Ameya Palande To: x0095840@ti.com Cc: linux-omap@vger.kernel.org, h-kanigeri2@ti.com, ext-phil.2.carmody@nokia.com Subject: [PATCHv2 1/4] DSPBRIDGE: Fix macros that break when inside an if/else Date: Mon, 13 Jul 2009 15:38:46 +0300 Message-Id: <1247488726-14960-1-git-send-email-ameya.palande@nokia.com> X-Mailer: git-send-email 1.6.2.4 In-Reply-To: <496565EC904933469F292DDA3F1663E602A30E140D@dlee06.ent.ti.com> References: <496565EC904933469F292DDA3F1663E602A30E140D@dlee06.ent.ti.com> X-OriginalArrivalTime: 13 Jul 2009 12:38:40.0988 (UTC) FILETIME=[DA0089C0:01CA03B6] 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..da0467c 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 {