[PATCH v2 3/7] UBI: accept empty string for vid_hdr_offs parameter

Richard Genoud richard.genoud at gmail.com
Mon Aug 20 08:09:17 EDT 2012


as a new parameter (max_beb_per1024) will come in next patches, it's
better to accept empty string value so that we can do:
mtd.ubi=2,,25

Signed-off-by: Richard Genoud <richard.genoud at gmail.com>
---
 drivers/mtd/ubi/build.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index 3c0b91f..cc0a4fa 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -1292,7 +1292,11 @@ static int __init bytes_str_to_int(const char *str)
 	unsigned long result;
 
 	result = simple_strtoul(str, &endp, 0);
-	if (str == endp || result >= INT_MAX) {
+	if (str == endp)
+		/* empty string, assume it's 0 */
+		return 0;
+
+	if (result >= INT_MAX) {
 		printk(KERN_ERR "UBI error: incorrect bytes count: \"%s\"\n",
 		       str);
 		return -EINVAL;
-- 
1.7.2.5




More information about the linux-mtd mailing list