From patchwork Thu Aug 12 07:53:52 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 61535 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 62B4BB70DA for ; Thu, 12 Aug 2010 17:56:28 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1OjScG-0004R0-Oq; Thu, 12 Aug 2010 07:54:20 +0000 Received: from mail-ww0-f49.google.com ([74.125.82.49]) by bombadil.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1OjScE-0004QM-OD for linux-mtd@lists.infradead.org; Thu, 12 Aug 2010 07:54:19 +0000 Received: by wwi17 with SMTP id 17so1156951wwi.18 for ; Thu, 12 Aug 2010 00:54:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:mime-version:content-type:content-disposition:user-agent; bh=H8RgsPyxwQ+NTaK5eGF/7AKExXGJS7/ezoYVEJisu04=; b=LZAqMd2bWWEomQQXYixN0LfosnFpNvG5+wO8TlLZrkbqFlNjLJw9lceZzk2Guqka4I ir3czwBhigMe5cRQOFc2zE4z1Pk19wxWCFfOuvN1zSgCTyt0ytym8j+IrLnsEDO5o1aK 7/jNMTRRVcNMcXTJhTGM6a4sedefCwUYGhNYU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=Y3BYYmhdYOdyLCXaqo0i65E8jlvkAMFH8Z+M1r0xI0ue3c4+dCuEB+nhh+sXnFN++p 0qMqDXO5h9P8w+1EsXnmJ18W1HQ7hI1kzmfWb0dBH0NTLcFVtwr11HTZdLvstdF048MG SDREhRjhwBm4gJZSkf1e0ncYEHJrfp3HpYXvU= Received: by 10.227.130.203 with SMTP id u11mr17289397wbs.220.1281599656757; Thu, 12 Aug 2010 00:54:16 -0700 (PDT) Received: from bicker ([205.177.176.130]) by mx.google.com with ESMTPS id a1sm960363wbb.8.2010.08.12.00.54.01 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 12 Aug 2010 00:54:16 -0700 (PDT) Date: Thu, 12 Aug 2010 09:53:52 +0200 From: Dan Carpenter To: David Woodhouse Subject: [patch 1/2] mtd/m25p80: retlen is never NULL Message-ID: <20100812075352.GN645@bicker> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20100812_035418_883412_B3EA19DF X-CRM114-Status: GOOD ( 16.81 ) X-Spam-Score: 4.0 (++++) X-Spam-Report: SpamAssassin version 3.3.1 on bombadil.infradead.org summary: Content analysis details: (4.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 1.2 RCVD_IN_BL_SPAMCOP_NET RBL: Received via a relay in bl.spamcop.net [Blocked - see ] 0.6 RCVD_IN_SORBS_WEB RBL: SORBS: sender is an abusable web server [205.177.176.130 listed in dnsbl.sorbs.net] 0.0 FREEMAIL_FROM Sender email is freemail (error27[at]gmail.com) 2.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (error27[at]gmail.com) -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Artem Bityutskiy , Mike Frysinger , Anton Vorontsov , kernel-janitors@vger.kernel.org, Gabor Juhos , linux-mtd@lists.infradead.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This is just a cleanup, it doesn't fix any bugs. These functions all check retlen inconsistently and it generates a warning in Smatch (http://smatch.sf.net). If retlen were ever NULL it would cause an oops and the code has been this way since 2006 so someone would have complained. Also I looked at other places that implemented the mtd read and write functions and they dereference retlen without checking. I removed the checks. Signed-off-by: Dan Carpenter diff --git a/drivers/mtd/devices/m25p80.c b/drivers/mtd/devices/m25p80.c index f90941a..83c9086 100644 --- a/drivers/mtd/devices/m25p80.c +++ b/drivers/mtd/devices/m25p80.c @@ -347,8 +347,7 @@ static int m25p80_read(struct mtd_info *mtd, loff_t from, size_t len, spi_message_add_tail(&t[1], &m); /* Byte count starts at zero. */ - if (retlen) - *retlen = 0; + *retlen = 0; mutex_lock(&flash->lock); @@ -394,8 +393,7 @@ static int m25p80_write(struct mtd_info *mtd, loff_t to, size_t len, dev_name(&flash->spi->dev), __func__, "to", (u32)to, len); - if (retlen) - *retlen = 0; + *retlen = 0; /* sanity checks */ if (!len) @@ -466,8 +464,7 @@ static int m25p80_write(struct mtd_info *mtd, loff_t to, size_t len, spi_sync(flash->spi, &m); - if (retlen) - *retlen += m.actual_length - m25p_cmdsz(flash); + *retlen += m.actual_length - m25p_cmdsz(flash); } } @@ -485,8 +482,7 @@ static int sst_write(struct mtd_info *mtd, loff_t to, size_t len, size_t actual; int cmd_sz, ret; - if (retlen) - *retlen = 0; + *retlen = 0; /* sanity checks */ if (!len)