lib/string_helpers.c: constify static arrays
authorMathias Krause <minipli@googlemail.com>
Wed, 6 Aug 2014 23:09:31 +0000 (16:09 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 7 Aug 2014 01:01:25 +0000 (18:01 -0700)
Complement commit 68aecfb97978 ("lib/string_helpers.c: make arrays
static") by making the arrays const -- not only pointing to const
strings.  This moves them out of the data section to the r/o data
section:

   text    data     bss     dec     hex filename
   1150     176       0    1326     52e lib/string_helpers.old.o
   1326       0       0    1326     52e lib/string_helpers.new.o

Signed-off-by: Mathias Krause <minipli@googlemail.com>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
lib/string_helpers.c

index ed5c1454dd6288aacf85e4ee7db5e2e3ee947627..29033f319aea1f8f48e85374884f657a130519a4 100644 (file)
 int string_get_size(u64 size, const enum string_size_units units,
                    char *buf, int len)
 {
-       static const char *units_10[] = { "B", "kB", "MB", "GB", "TB", "PB",
-                                  "EB", "ZB", "YB", NULL};
-       static const char *units_2[] = {"B", "KiB", "MiB", "GiB", "TiB", "PiB",
-                                "EiB", "ZiB", "YiB", NULL };
-       static const char **units_str[] = {
-               [STRING_UNITS_10] =  units_10,
+       static const char *const units_10[] = {
+               "B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB", NULL
+       };
+       static const char *const units_2[] = {
+               "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB",
+               NULL
+       };
+       static const char *const *const units_str[] = {
+               [STRING_UNITS_10] = units_10,
                [STRING_UNITS_2] = units_2,
        };
        static const unsigned int divisor[] = {