Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754152AbZAKThk (ORCPT ); Sun, 11 Jan 2009 14:37:40 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752366AbZAKTg2 (ORCPT ); Sun, 11 Jan 2009 14:36:28 -0500 Received: from cantor2.suse.de ([195.135.220.15]:39326 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751825AbZAKTgZ (ORCPT ); Sun, 11 Jan 2009 14:36:25 -0500 Message-Id: <20b788045b73e81ace2498eae42220e64547d6d2.1231695451.git.kkeil@suse.de> In-Reply-To: References: Subject: [PATCH 4/7] drivers/isdn/hardware/mISDN: move a dereference below a NULL test From: Karsten Keil Date: Sun, 11 Jan 2009 16:24:38 +0100 To: Linus Torvalds Cc: LKML , Karsten Keil , Julia Lawall Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1540 Lines: 61 From: Julia Lawall Date: Fri, 9 Jan 2009 12:22:53 -0800 In each case, if the NULL test is necessary, then the dereference should be moved below the NULL test. The semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // @@ type T; expression E; identifier i,fld; statement S; @@ - T i = E->fld; + T i; ... when != E when != i if (E == NULL) S + i = E->fld; // Signed-off-by: Julia Lawall Signed-off-by: Andrew Morton Signed-off-by: Karsten Keil --- drivers/isdn/hardware/mISDN/hfcmulti.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/drivers/isdn/hardware/mISDN/hfcmulti.c b/drivers/isdn/hardware/mISDN/hfcmulti.c index 97f4708..595ba8e 100644 --- a/drivers/isdn/hardware/mISDN/hfcmulti.c +++ b/drivers/isdn/hardware/mISDN/hfcmulti.c @@ -3615,7 +3615,7 @@ hfcm_bctrl(struct mISDNchannel *ch, u_int cmd, void *arg) static void ph_state_change(struct dchannel *dch) { - struct hfc_multi *hc = dch->hw; + struct hfc_multi *hc; int ch, i; if (!dch) { @@ -3623,6 +3623,7 @@ ph_state_change(struct dchannel *dch) __func__); return; } + hc = dch->hw; ch = dch->slot; if (hc->type == 1) { -- 1.5.6.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/