From: Saurabh Sengar <saurabh.truth@gmail.com>
To: computersforpeace@gmail.com, joe@perches.com
Cc: andy.shevchenko@gmail.com, joern@lazybastard.org,
dwmw2@infradead.org, linux-mtd@lists.infradead.org,
linux-kernel@vger.kernel.org,
Saurabh Sengar <saurabh.truth@gmail.com>
Subject: [PATCH] mtd: phram: error handling
Date: Wed, 11 Nov 2015 00:57:55 +0530 [thread overview]
Message-ID: <1447183675-4840-1-git-send-email-saurabh.truth@gmail.com> (raw)
In-Reply-To: <20151110190343.GR12143@google.com>
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 <computersforpeace@gmail.com>
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Saurabh Sengar <saurabh.truth@gmail.com>
---
>> I think -EINVAL makes more sense than 1. That
>> could be a subsequent patch, I suppose.
>That means you have to trace all the callers
>to verify that converting 1 to -22 is acceptable.
>Maybe Saurabh wants to do that.
I have checked that function is called only by init and module param,
and I understand in both the cases -EINVAL is a valid return type.
Sorry, I am not able to test the driver, sending the patch as asked above.
Also sorry for the noise I created in first report
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..e39fe5c 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 -EINVAL;
+ }
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 -EINVAL;
+ }
- if (!token[2])
- parse_err("not enough arguments\n");
+ if (!token[2]) {
+ pr_err("not enough arguments\n");
+ return -EINVAL;
+ }
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 -EINVAL;
}
ret = parse_num64(&len, token[2]);
if (ret) {
kfree(name);
- parse_err("illegal device length\n");
+ pr_err("invalid device length\n");
+ return -EINVAL;
}
ret = register_device(name, start, len);
--
1.9.1
next prev parent reply other threads:[~2015-11-10 19:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-08 8:47 Saurabh Sengar
2015-11-08 21:23 ` Andy Shevchenko
2015-11-09 6:23 ` [PATCH v2] " Saurabh Sengar
2015-11-10 18:20 ` Brian Norris
2015-11-10 18:33 ` [PATCH] " Joe Perches
2015-11-10 18:39 ` Brian Norris
2015-11-10 18:45 ` Joe Perches
2015-11-10 19:03 ` Brian Norris
2015-11-10 19:27 ` Saurabh Sengar [this message]
2015-11-10 19:41 ` Brian Norris
2015-11-11 8:23 ` Saurabh Sengar
2015-11-11 19:44 ` Brian Norris
2015-11-12 6:23 ` Saurabh Sengar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1447183675-4840-1-git-send-email-saurabh.truth@gmail.com \
--to=saurabh.truth@gmail.com \
--cc=andy.shevchenko@gmail.com \
--cc=computersforpeace@gmail.com \
--cc=dwmw2@infradead.org \
--cc=joe@perches.com \
--cc=joern@lazybastard.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome