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

Shmulik Ladkani shmulik.ladkani at gmail.com
Mon Aug 20 08:52:10 EDT 2012


Hi Richard,

On Mon, 20 Aug 2012 14:09:17 +0200 Richard Genoud <richard.genoud at gmail.com> wrote:
> @@ -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;

This will allow "ubi=2,#" (or any non numeric character after the
comma), setting a zero vid_hdr_offs instead of erroring.

How about adding:

+	if (!*str)
+		/* empty string, assume it's 0 */
+		return 0;

Before the original (keep it):

 	result = simple_strtoul(str, &endp, 0);
	if (str == endp || result >= INT_MAX) {

Can you test this works in all cases?

Regards,
Shmulik



More information about the linux-mtd mailing list