Received: from mail.onstor.com ([66.201.51.107]) by onstor-exch02.onstor.net with Microsoft SMTPSVC(6.0.3790.3959);
	 Fri, 29 Aug 2008 02:17:25 -0700
Received: from dalesmta2-1.messageone.com ([129.41.169.249]) by mail.onstor.com with Microsoft SMTPSVC(6.0.3790.3959);
	 Fri, 29 Aug 2008 02:17:24 -0700
Received: from ftp.linux-mips.org (ftp.linux-mips.org [213.58.128.207])
	by dalesmta2-1.messageone.com (8.13.8/8.13.8) with ESMTP id m7T9HMbm012055
	for <andy.sharp@onstor.com>; Fri, 29 Aug 2008 04:17:23 -0500
Received: from localhost.localdomain ([127.0.0.1]:6058 "EHLO
	ftp.linux-mips.org") by ftp.linux-mips.org with ESMTP
	id S20027096AbYH2JQv (ORCPT <rfc822;andy.sharp@onstor.com>);
	Fri, 29 Aug 2008 10:16:51 +0100
Received: with ECARTIS (v1.0.0; list linux-mips); Fri, 29 Aug 2008 10:16:34 +0100 (BST)
Received: from mgw1.diku.dk ([130.225.96.91]:149 "EHLO mgw1.diku.dk")
	by ftp.linux-mips.org with ESMTP id S20026997AbYH2JQc (ORCPT
	<rfc822;linux-mips@linux-mips.org>); Fri, 29 Aug 2008 10:16:32 +0100
Received: from localhost (localhost [127.0.0.1])
	by mgw1.diku.dk (Postfix) with ESMTP id 7BD7552C324;
	Fri, 29 Aug 2008 11:16:30 +0200 (CEST)
X-Virus-Scanned: amavisd-new at diku.dk
Received: from mgw1.diku.dk ([127.0.0.1])
	by localhost (mgw1.diku.dk [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id 2g7FE9JnUioA; Fri, 29 Aug 2008 11:16:29 +0200 (CEST)
Received: from nhugin.diku.dk (nhugin.diku.dk [130.225.96.140])
	by mgw1.diku.dk (Postfix) with ESMTP id 26E3652C309;
	Fri, 29 Aug 2008 11:16:29 +0200 (CEST)
Received: from imap.diku.dk (imap.diku.dk [130.225.96.139])
	by nhugin.diku.dk (Postfix) with ESMTP
	id C625B6DF893; Fri, 29 Aug 2008 11:13:41 +0200 (CEST)
Received: from mobil-140.diku.dk (fw-mobil.diku.dk [130.225.96.28])
	by imap.diku.dk (Postfix) with ESMTP id 0A96161DCD;
	Fri, 29 Aug 2008 11:16:29 +0200 (CEST)
From: Julien Brunel <brunel@diku.dk>
To: dedekind@infradead.org, linux-mips@linux-mips.org,
        linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] fs/ubifs: Use an IS_ERR test rather than a NULL test
Date: 	Fri, 29 Aug 2008 11:08:32 +0200
User-Agent: KMail/1.9.9
MIME-Version: 1.0
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Message-Id: <200808291108.32958.brunel@diku.dk>
X-archive-position: 20387
X-ecartis-version: Ecartis v1.0.0
Sender: linux-mips-bounce@linux-mips.org
Errors-to: linux-mips-bounce@linux-mips.org
X-original-sender: brunel@diku.dk
Precedence: bulk
X-list: 	linux-mips
X-MessageOne-Virus-Version: vendor=fsecure engine=4.65.7161:2.4.4,1.2.40,4.0.164 definitions=2008-08-29_08:2008-08-28,2008-08-29,2008-08-29 signatures=0
X-MessageOne-Virus-Scanned: Clean
X-MessageOne-Envelope-Sender: linux-mips-bounce@linux-mips.org
X-MessageOne-Spam-Details: rule=m773emszm_notspam policy=m773emszm score=0 spamscore=0 ipscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx engine=3.1.0-0805090000 definitions=main-0808290012
X-MessageOne-Spam-Score: 0
X-MessageOne-Spam-Bar: 
Return-Path: linux-mips-bounce@linux-mips.org
X-OriginalArrivalTime: 29 Aug 2008 09:17:24.0734 (UTC) FILETIME=[0CA1E9E0:01C909B8]

From: Julien Brunel <brunel@diku.dk>

In case of error, the function kthread_create returns an ERR pointer,
but never returns a NULL pointer. So a NULL test that comes before an
IS_ERR test should be deleted.

The semantic match that finds this problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@match_bad_null_test@
expression x, E;
statement S1,S2;
@@
x = kthread_create(...)
... when != x = E
* if (x == NULL) 
S1 else S2
// </smpl>

Signed-off-by:  Julien Brunel <brunel@diku.dk>
Signed-off-by:  Julia Lawall <julia@diku.dk>

---
 fs/ubifs/super.c |    4 ----
 1 file changed, 4 deletions(-)

diff -u -p a/fs/ubifs/super.c b/fs/ubifs/super.c
--- a/fs/ubifs/super.c
+++ b/fs/ubifs/super.c
@@ -1027,8 +1027,6 @@ static int mount_ubifs(struct ubifs_info
 		sprintf(c->bgt_name, BGT_NAME_PATTERN, c->vi.ubi_num,
 			c->vi.vol_id);
 		c->bgt = kthread_create(ubifs_bg_thread, c, c->bgt_name);
-		if (!c->bgt)
-			c->bgt = ERR_PTR(-EINVAL);
 		if (IS_ERR(c->bgt)) {
 			err = PTR_ERR(c->bgt);
 			c->bgt = NULL;
@@ -1340,8 +1338,6 @@ static int ubifs_remount_rw(struct ubifs
 
 	/* Create background thread */
 	c->bgt = kthread_create(ubifs_bg_thread, c, c->bgt_name);
-	if (!c->bgt)
-		c->bgt = ERR_PTR(-EINVAL);
 	if (IS_ERR(c->bgt)) {
 		err = PTR_ERR(c->bgt);
 		c->bgt = NULL;

