Re: [PATCH 3/3] viafb: use read-only mode parsing

From: Andrew Morton
Date: Wed Sep 09 2009 - 16:40:06 EST


On Mon, 7 Sep 2009 02:24:44 +0000
Florian Tobias Schandinat <FlorianSchandinat@xxxxxx> wrote:

> +static void parse_mode(const char *str, u32 *xres, u32 *yres)
> +{
> + char *ptr;
> +
> + *xres = simple_strtoul(str, &ptr, 10);
> + if (ptr[0] != 'x')
> + goto out_default;
> +
> + *yres = simple_strtoul(&ptr[1], &ptr, 10);
> + if (ptr[0])
> + goto out_default;
> +
> + return;
> +
> +out_default:
> + printk(KERN_WARNING "viafb received invalid mode string: %s\n", str);
> + *xres = 640;
> + *yres = 480;
> +}

One wonders if we could use sscanf here?

The second simple_strtoul() could use strict_strtoul(), but that's not
obviously superior IMO.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/