Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: mtdswap: make array 'name' static const, shrinks object size

Don't populate the read-only array 'name' on the stack but instead
make it static and constify it. Makes the object code smaller by 35
bytes:

Before:
text data bss dec hex filename
26304 4444 352 31100 797c drivers/mtd/mtdswap.o

After:
text data bss dec hex filename
26205 4508 352 31065 7959 drivers/mtd/mtdswap.o

(gcc version 7.2.0 x86_64)

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>

authored by

Colin Ian King and committed by
Boris Brezillon
bf657105 4fbd8d19

+3 -2
+3 -2
drivers/mtd/mtdswap.c
··· 1223 1223 unsigned int max[MTDSWAP_TREE_CNT]; 1224 1224 unsigned int i, cw = 0, cwp = 0, cwecount = 0, bb_cnt, mapped, pages; 1225 1225 uint64_t use_size; 1226 - char *name[] = {"clean", "used", "low", "high", "dirty", "bitflip", 1227 - "failing"}; 1226 + static const char * const name[] = { 1227 + "clean", "used", "low", "high", "dirty", "bitflip", "failing" 1228 + }; 1228 1229 1229 1230 mutex_lock(&d->mbd_dev->lock); 1230 1231