Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752133AbbKJSdN (ORCPT ); Tue, 10 Nov 2015 13:33:13 -0500 Received: from smtprelay0230.hostedemail.com ([216.40.44.230]:42683 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751535AbbKJSdL (ORCPT ); Tue, 10 Nov 2015 13:33:11 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 89,8.8,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::,RULES_HIT:41:69:355:379:541:800:960:966:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:2828:3138:3139:3140:3141:3142:3353:3865:3870:3873:3874:4250:4385:4419:5007:6119:6261:7514:9592:10014:10021:10400:10848:11026:11232:11658:11914:12296:12517:12519:12555:12679:13208:13229:13972:14394:14659:21067:21080:30003:30029:30054,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:1:0,LFtime:10,LUA_SUMMARY:none X-HE-Tag: scent59_387a923482023 X-Filterd-Recvd-Size: 3170 Message-ID: <1447180387.2701.68.camel@perches.com> Subject: [PATCH] mtd: phram: error handling From: Joe Perches To: Brian Norris , Saurabh Sengar Cc: andy.shevchenko@gmail.com, joern@lazybastard.org, dwmw2@infradead.org, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Date: Tue, 10 Nov 2015 10:33:07 -0800 In-Reply-To: <20151110182047.GP12143@google.com> References: <1447050198-20562-1-git-send-email-saurabh.truth@gmail.com> <20151110182047.GP12143@google.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.16.5-1ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2325 Lines: 90 Expand parse_err macro with hidden flow in-place. Remove the now unused parse_err macro. Miscellanea: o Use invalid not illegal for error messages Noticed-by: Brian Norris Signed-off-by: Joe Perches --- > Did you notice that > there's a "return" statement embedded in the parse_err() macro? So there > was no bug in the first place. drivers/mtd/devices/phram.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c index 8b66e52..d93b85e 100644 --- a/drivers/mtd/devices/phram.c +++ b/drivers/mtd/devices/phram.c @@ -199,11 +199,6 @@ static inline void kill_final_newline(char *str) } -#define parse_err(fmt, args...) do { \ - pr_err(fmt , ## args); \ - return 1; \ -} while (0) - #ifndef MODULE static int phram_init_called; /* @@ -226,8 +221,10 @@ static int phram_setup(const char *val) uint64_t len; int i, ret; - if (strnlen(val, sizeof(buf)) >= sizeof(buf)) - parse_err("parameter too long\n"); + if (strnlen(val, sizeof(buf)) >= sizeof(buf)) { + pr_err("parameter too long\n"); + return 1; + } strcpy(str, val); kill_final_newline(str); @@ -235,11 +232,15 @@ static int phram_setup(const char *val) for (i = 0; i < 3; i++) token[i] = strsep(&str, ","); - if (str) - parse_err("too many arguments\n"); + if (str) { + pr_err("too many arguments\n"); + return 1; + } - if (!token[2]) - parse_err("not enough arguments\n"); + if (!token[2]) { + pr_err("not enough arguments\n"); + return 1; + } ret = parse_name(&name, token[0]); if (ret) @@ -248,13 +249,15 @@ static int phram_setup(const char *val) ret = parse_num64(&start, token[1]); if (ret) { kfree(name); - parse_err("illegal start address\n"); + pr_err("invalid start address\n"); + return 1; } ret = parse_num64(&len, token[2]); if (ret) { kfree(name); - parse_err("illegal device length\n"); + pr_err("invalid device length\n"); + return 1; } ret = register_device(name, start, len); -- 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/