Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1266711
| From | Joe Perches <joe@perches.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] mtd: phram: error handling |
| Date | 2015-11-10 19:40 +0100 |
| Message-ID | <qtlZM-d8-19@gated-at.bofh.it> (permalink) |
| References | <qsFHc-5tw-7@gated-at.bofh.it> <qsO7M-2Ku-1@gated-at.bofh.it> <qtlQ5-9M-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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>
---
> 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/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] mtd: phram: error handling Saurabh Sengar <saurabh.truth@gmail.com> - 2015-11-08 09:50 +0100
Re: [PATCH] mtd: phram: error handling Andy Shevchenko <andy.shevchenko@gmail.com> - 2015-11-08 22:30 +0100
[PATCH v2] mtd: phram: error handling Saurabh Sengar <saurabh.truth@gmail.com> - 2015-11-09 07:30 +0100
Re: [PATCH v2] mtd: phram: error handling Brian Norris <computersforpeace@gmail.com> - 2015-11-10 19:30 +0100
[PATCH] mtd: phram: error handling Joe Perches <joe@perches.com> - 2015-11-10 19:40 +0100
Re: [PATCH] mtd: phram: error handling Joe Perches <joe@perches.com> - 2015-11-10 19:50 +0100
Re: [PATCH] mtd: phram: error handling Brian Norris <computersforpeace@gmail.com> - 2015-11-10 20:10 +0100
[PATCH] mtd: phram: error handling Saurabh Sengar <saurabh.truth@gmail.com> - 2015-11-10 20:30 +0100
Re: [PATCH] mtd: phram: error handling Brian Norris <computersforpeace@gmail.com> - 2015-11-10 20:50 +0100
[PATCH] mtd: phram: error handling Saurabh Sengar <saurabh.truth@gmail.com> - 2015-11-11 09:30 +0100
Re: [PATCH] mtd: phram: error handling Brian Norris <computersforpeace@gmail.com> - 2015-11-11 20:50 +0100
[PATCH] mtd: phram: error handling Saurabh Sengar <saurabh.truth@gmail.com> - 2015-11-12 07:30 +0100
Re: [PATCH] mtd: phram: error handling Brian Norris <computersforpeace@gmail.com> - 2015-11-10 19:50 +0100
csiph-web