From patchwork Fri Jan 9 20:23:09 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 17584 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id A6178DE499 for ; Sat, 10 Jan 2009 07:23:55 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754882AbZAIUXq (ORCPT ); Fri, 9 Jan 2009 15:23:46 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754845AbZAIUXq (ORCPT ); Fri, 9 Jan 2009 15:23:46 -0500 Received: from smtp1.linux-foundation.org ([140.211.169.13]:50309 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754846AbZAIUXp (ORCPT ); Fri, 9 Jan 2009 15:23:45 -0500 Received: from imap1.linux-foundation.org (imap1.linux-foundation.org [140.211.169.55]) by smtp1.linux-foundation.org (8.14.2/8.13.5/Debian-3ubuntu1.1) with ESMTP id n09KN9kf022117 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 9 Jan 2009 12:23:10 -0800 Received: from localhost.localdomain (localhost [127.0.0.1]) by imap1.linux-foundation.org (8.13.5.20060308/8.13.5/Debian-3ubuntu1.1) with ESMTP id n09KN91a020170; Fri, 9 Jan 2009 12:23:09 -0800 Message-Id: <200901092023.n09KN91a020170@imap1.linux-foundation.org> Subject: [patch 2/4] drivers/net/hamradio/6pack.c: move a dereference below a NULL test To: davem@davemloft.net Cc: netdev@vger.kernel.org, akpm@linux-foundation.org, julia@diku.dk From: akpm@linux-foundation.org Date: Fri, 09 Jan 2009 12:23:09 -0800 X-Spam-Status: No, hits=-3.411 required=5 tests=AWL, BAYES_00, OSDL_HEADER_SUBJECT_BRACKETED X-Spam-Checker-Version: SpamAssassin 3.2.4-osdl_revision__1.47__ X-MIMEDefang-Filter: lf$Revision: 1.188 $ X-Scanned-By: MIMEDefang 2.63 on 140.211.169.13 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Julia Lawall 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 --- drivers/net/hamradio/6pack.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff -puN drivers/net/hamradio/6pack.c~drivers-net-hamradio-6packc-move-a-dereference-below-a-null-test drivers/net/hamradio/6pack.c --- a/drivers/net/hamradio/6pack.c~drivers-net-hamradio-6packc-move-a-dereference-below-a-null-test +++ a/drivers/net/hamradio/6pack.c @@ -717,11 +717,12 @@ static int sixpack_ioctl(struct tty_stru unsigned int cmd, unsigned long arg) { struct sixpack *sp = sp_get(tty); - struct net_device *dev = sp->dev; + struct net_device *dev; unsigned int tmp, err; if (!sp) return -ENXIO; + dev = sp->dev; switch(cmd) { case SIOCGIFNAME: