Re: [PATCH] memcg: Use scnprintf instead of sprintf

From: Andreas Schwab
Date: Thu Apr 19 2012 - 04:26:14 EST


Andrew Morton <akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@xxxxxxxxxxxxxxxx>
writes:

> diff -puN lib/string_helpers.c~lib-string_helpersc-make-arrays-static lib/string_helpers.c
> --- a/lib/string_helpers.c~lib-string_helpersc-make-arrays-static
> +++ a/lib/string_helpers.c
> @@ -23,15 +23,15 @@
> int string_get_size(u64 size, const enum string_size_units units,
> char *buf, int len)
> {
> - const char *units_10[] = { "B", "kB", "MB", "GB", "TB", "PB",
> + static const char *units_10[] = { "B", "kB", "MB", "GB", "TB", "PB",
> "EB", "ZB", "YB", NULL};
> - const char *units_2[] = {"B", "KiB", "MiB", "GiB", "TiB", "PiB",
> + static const char *units_2[] = {"B", "KiB", "MiB", "GiB", "TiB", "PiB",
> "EiB", "ZiB", "YiB", NULL };
> - const char **units_str[] = {
> + static const char **units_str[] = {
> [STRING_UNITS_10] = units_10,
> [STRING_UNITS_2] = units_2,
> };

You could even make them const, I think.

Andreas.

--
Andreas Schwab, schwab@xxxxxxxxxxxxxx
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
--
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/