[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <878ud4if9z.fsf@rasmusvillemoes.dk>
Date: Mon, 04 May 2015 16:33:12 +0200
From: Rasmus Villemoes <linux@...musvillemoes.dk>
To: Alexey Dobriyan <adobriyan@...il.com>
Cc: akpm@...ux-foundation.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 06/10] parse_integer: convert mm/
On Sat, May 02 2015, Alexey Dobriyan <adobriyan@...il.com> wrote:
> Convert mm/ directory away from deprecated simple_strto*() interface.
>
> One thing to note about parse_integer() and seemingly useless casts --
> range of accepted values depends on result type.
>
> int val;
> parse_integer(s, 0, &val);
>
> will accept negative integers, while
>
> int val;
> parse_integer(s, 0, (unsigned int *)&val);
>
> will accept only 0 and positive integers.
... and then silently write a negative value to val if the parsed
integer happens to be larger than INT_MAX.
Again, I think passing cast expressions to parse_integer should be
verboten.
In these particular cases:
* memtest_pattern should just be unsigned int - it's only ever used as
such anyway, and it represents a count.
* hashdist should be a boolean, but even in its current form, there's no
reason to not just use parse_integer as-is. If people like to set it
by passing -42 just let them.
Rasmus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists