Re: [PATCH] vsprintf.c: remove stack variable ksym from

From: Paulo Marques
Date: Mon Mar 15 2010 - 11:34:23 EST


Joe Perches wrote:
> On Sat, 2010-03-13 at 09:44 -0800, Joe Perches wrote:
>> On Sat, 2010-03-13 at 07:35 -0800, Linus Torvalds wrote:
>>> On Fri, 12 Mar 2010, Andrew Morton wrote:
>>>> nice.
>>> But the kallsyms_lookup()/sprint_symbol() functions don't take a
>>> length parameter, so we have to do the worst-case thing (which itself has
>>> tons of unnecessary padding).
>> Perhaps a new snprint_symbol function with the
>> other kallsyms... functions changed as necessary.
>
> Perhaps something like this:

Just one minor nit:

[...]
>
> - *result = '\0';
> + if (size)
> + *result = '\0';

This test seems to be here to handle the "size == 0" case, but

>[...]
> +const char *kallsyms_lookup_n(unsigned long addr,
> + unsigned long *symbolsize,
> + unsigned long *offset,
> + char **modname, char *namebuf, size_t size)
> +{
> + if (size)
> + namebuf[size - 1] = 0;
> + namebuf[0] = 0;

here we seem to write the namebuf[0] even if "size == 0". So maybe both
assignments in this function should be inside the "if (size)" test.

Other than that, the patch looks good:

Reviewed-by: Paulo Marques <pmarques@xxxxxxxxxxxx>

--
Paulo Marques - www.grupopie.com

"As far as we know, our computer has never had an undetected error."
Weisert
--
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/