From patchwork Thu May 2 21:18:51 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 241103 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 6E9DF2C00D1 for ; Fri, 3 May 2013 07:20:03 +1000 (EST) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UY0uh-00029N-2P; Thu, 02 May 2013 21:19:39 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UY0uf-0002Mw-3L; Thu, 02 May 2013 21:19:37 +0000 Received: from mail-pb0-x22d.google.com ([2607:f8b0:400e:c01::22d]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UY0uc-0002MP-DP for linux-mtd@lists.infradead.org; Thu, 02 May 2013 21:19:35 +0000 Received: by mail-pb0-f45.google.com with SMTP id ro12so557694pbb.4 for ; Thu, 02 May 2013 14:19:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer; bh=2EoBcsV6Hac4a6vn9dMVUDxp/dHf/6EqtbTqr1HsB/A=; b=cxipq/zuInlCrpyFNh9ikExBavptpRhvFAgtylyEG4LTRSIHf2adX07XTWcvt7Dp4c fAz92kNeqYSgErsbAlm8zPYhhg3qM57lXskUwLRRjhe3oizFcAeGpqkRY1upFhTpLIEc pFP32Wl/voRZNy93OrA69mgZgP+ssm6CmNqJ5nKqgh0ykLzrE9wbiyD55AuSBHG/+ZKx 9+vTmPW1XrW7IDnuMSlPZkziQBNDlaoY28PUgqOPJ7kkdZZ+t/rVPsOKZXX8SbWXJKUi TUP14vr1s+mHUnLKCBAj3Za7X/w/awO90skz0AFRFN8UVQjVnX6OupgOMoemI+MaObHG tKhg== X-Received: by 10.66.228.233 with SMTP id sl9mr11650463pac.38.1367529551375; Thu, 02 May 2013 14:19:11 -0700 (PDT) Received: from ld-irv-0074.broadcom.com (5520-maca-inet1-outside.broadcom.com. [216.31.211.11]) by mx.google.com with ESMTPSA id v5sm8707917pbz.4.2013.05.02.14.19.09 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 02 May 2013 14:19:10 -0700 (PDT) From: Brian Norris To: Artem Bityutskiy Subject: [PATCH] mtd: tests: don't print error messages when out-of-memory Date: Thu, 2 May 2013 14:18:51 -0700 Message-Id: <1367529531-17254-1-git-send-email-computersforpeace@gmail.com> X-Mailer: git-send-email 1.8.2.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130502_171934_629614_98F54B9B X-CRM114-Status: GOOD ( 11.05 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (computersforpeace[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -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: Brian Norris , linux-mtd@lists.infradead.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org These strings are now unnecessary and discouraged in the kernel. The kernel will have plenty of big scary messages if kmalloc fails. These now only serve to bloat the module. Signed-off-by: Brian Norris --- drivers/mtd/tests/mtd_oobtest.c | 12 +++--------- drivers/mtd/tests/mtd_pagetest.c | 20 +++++--------------- drivers/mtd/tests/mtd_readtest.c | 12 +++--------- drivers/mtd/tests/mtd_speedtest.c | 8 ++------ drivers/mtd/tests/mtd_stresstest.c | 8 ++------ drivers/mtd/tests/mtd_subpagetest.c | 12 +++--------- 6 files changed, 18 insertions(+), 54 deletions(-) diff --git a/drivers/mtd/tests/mtd_oobtest.c b/drivers/mtd/tests/mtd_oobtest.c index 3e24b37..ab81e9a 100644 --- a/drivers/mtd/tests/mtd_oobtest.c +++ b/drivers/mtd/tests/mtd_oobtest.c @@ -320,10 +320,8 @@ static int scan_for_bad_eraseblocks(void) int i, bad = 0; bbt = kmalloc(ebcnt, GFP_KERNEL); - if (!bbt) { - pr_err("error: cannot allocate memory\n"); + if (!bbt) return -ENOMEM; - } pr_info("scanning for bad eraseblocks\n"); for (i = 0; i < ebcnt; ++i) { @@ -380,15 +378,11 @@ static int __init mtd_oobtest_init(void) err = -ENOMEM; readbuf = kmalloc(mtd->erasesize, GFP_KERNEL); - if (!readbuf) { - pr_err("error: cannot allocate memory\n"); + if (!readbuf) goto out; - } writebuf = kmalloc(mtd->erasesize, GFP_KERNEL); - if (!writebuf) { - pr_err("error: cannot allocate memory\n"); + if (!writebuf) goto out; - } err = scan_for_bad_eraseblocks(); if (err) diff --git a/drivers/mtd/tests/mtd_pagetest.c b/drivers/mtd/tests/mtd_pagetest.c index 0c1140b..acd991f 100644 --- a/drivers/mtd/tests/mtd_pagetest.c +++ b/drivers/mtd/tests/mtd_pagetest.c @@ -191,10 +191,8 @@ static int crosstest(void) pr_info("crosstest\n"); pp1 = kmalloc(pgsize * 4, GFP_KERNEL); - if (!pp1) { - pr_err("error: cannot allocate memory\n"); + if (!pp1) return -ENOMEM; - } pp2 = pp1 + pgsize; pp3 = pp2 + pgsize; pp4 = pp3 + pgsize; @@ -456,10 +454,8 @@ static int scan_for_bad_eraseblocks(void) int i, bad = 0; bbt = kzalloc(ebcnt, GFP_KERNEL); - if (!bbt) { - pr_err("error: cannot allocate memory\n"); + if (!bbt) return -ENOMEM; - } pr_info("scanning for bad eraseblocks\n"); for (i = 0; i < ebcnt; ++i) { @@ -516,20 +512,14 @@ static int __init mtd_pagetest_init(void) err = -ENOMEM; bufsize = pgsize * 2; writebuf = kmalloc(mtd->erasesize, GFP_KERNEL); - if (!writebuf) { - pr_err("error: cannot allocate memory\n"); + if (!writebuf) goto out; - } twopages = kmalloc(bufsize, GFP_KERNEL); - if (!twopages) { - pr_err("error: cannot allocate memory\n"); + if (!twopages) goto out; - } boundary = kmalloc(bufsize, GFP_KERNEL); - if (!boundary) { - pr_err("error: cannot allocate memory\n"); + if (!boundary) goto out; - } err = scan_for_bad_eraseblocks(); if (err) diff --git a/drivers/mtd/tests/mtd_readtest.c b/drivers/mtd/tests/mtd_readtest.c index 266de04..2cdd0c4 100644 --- a/drivers/mtd/tests/mtd_readtest.c +++ b/drivers/mtd/tests/mtd_readtest.c @@ -143,10 +143,8 @@ static int scan_for_bad_eraseblocks(void) int i, bad = 0; bbt = kzalloc(ebcnt, GFP_KERNEL); - if (!bbt) { - pr_err("error: cannot allocate memory\n"); + if (!bbt) return -ENOMEM; - } if (!mtd_can_have_bb(mtd)) return 0; @@ -204,15 +202,11 @@ static int __init mtd_readtest_init(void) err = -ENOMEM; iobuf = kmalloc(mtd->erasesize, GFP_KERNEL); - if (!iobuf) { - pr_err("error: cannot allocate memory\n"); + if (!iobuf) goto out; - } iobuf1 = kmalloc(mtd->erasesize, GFP_KERNEL); - if (!iobuf1) { - pr_err("error: cannot allocate memory\n"); + if (!iobuf1) goto out; - } err = scan_for_bad_eraseblocks(); if (err) diff --git a/drivers/mtd/tests/mtd_speedtest.c b/drivers/mtd/tests/mtd_speedtest.c index a6ce9c1..20b63d1 100644 --- a/drivers/mtd/tests/mtd_speedtest.c +++ b/drivers/mtd/tests/mtd_speedtest.c @@ -313,10 +313,8 @@ static int scan_for_bad_eraseblocks(void) int i, bad = 0; bbt = kzalloc(ebcnt, GFP_KERNEL); - if (!bbt) { - pr_err("error: cannot allocate memory\n"); + if (!bbt) return -ENOMEM; - } if (!mtd_can_have_bb(mtd)) goto out; @@ -384,10 +382,8 @@ static int __init mtd_speedtest_init(void) err = -ENOMEM; iobuf = kmalloc(mtd->erasesize, GFP_KERNEL); - if (!iobuf) { - pr_err("error: cannot allocate memory\n"); + if (!iobuf) goto out; - } prandom_bytes(iobuf, mtd->erasesize); diff --git a/drivers/mtd/tests/mtd_stresstest.c b/drivers/mtd/tests/mtd_stresstest.c index 787f539..3a95e61 100644 --- a/drivers/mtd/tests/mtd_stresstest.c +++ b/drivers/mtd/tests/mtd_stresstest.c @@ -202,10 +202,8 @@ static int scan_for_bad_eraseblocks(void) int i, bad = 0; bbt = kzalloc(ebcnt, GFP_KERNEL); - if (!bbt) { - pr_err("error: cannot allocate memory\n"); + if (!bbt) return -ENOMEM; - } if (!mtd_can_have_bb(mtd)) return 0; @@ -276,10 +274,8 @@ static int __init mtd_stresstest_init(void) readbuf = vmalloc(bufsize); writebuf = vmalloc(bufsize); offsets = kmalloc(ebcnt * sizeof(int), GFP_KERNEL); - if (!readbuf || !writebuf || !offsets) { - pr_err("error: cannot allocate memory\n"); + if (!readbuf || !writebuf || !offsets) goto out; - } for (i = 0; i < ebcnt; i++) offsets[i] = mtd->erasesize; prandom_bytes(writebuf, bufsize); diff --git a/drivers/mtd/tests/mtd_subpagetest.c b/drivers/mtd/tests/mtd_subpagetest.c index aade56f..e41a04f 100644 --- a/drivers/mtd/tests/mtd_subpagetest.c +++ b/drivers/mtd/tests/mtd_subpagetest.c @@ -333,10 +333,8 @@ static int scan_for_bad_eraseblocks(void) int i, bad = 0; bbt = kzalloc(ebcnt, GFP_KERNEL); - if (!bbt) { - pr_err("error: cannot allocate memory\n"); + if (!bbt) return -ENOMEM; - } pr_info("scanning for bad eraseblocks\n"); for (i = 0; i < ebcnt; ++i) { @@ -393,15 +391,11 @@ static int __init mtd_subpagetest_init(void) err = -ENOMEM; bufsize = subpgsize * 32; writebuf = kmalloc(bufsize, GFP_KERNEL); - if (!writebuf) { - pr_info("error: cannot allocate memory\n"); + if (!writebuf) goto out; - } readbuf = kmalloc(bufsize, GFP_KERNEL); - if (!readbuf) { - pr_info("error: cannot allocate memory\n"); + if (!readbuf) goto out; - } err = scan_for_bad_eraseblocks(); if (err)