Skip to content

Commit c666d44

Browse files
Matthew Wilcox (Oracle)pmladek
authored andcommitted
test_printf: Make pft array const
Instead of assigning ptf[i].value, leave the values in the on-stack array and then we can make the array const. Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Reviewed-by: Yafang Shao <[email protected]> Reviewed-by: Petr Mladek <[email protected]> Reviewed-by: Anshuman Khandual <[email protected]> Signed-off-by: Petr Mladek <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 6880fa6 commit c666d44

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

lib/test_printf.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -586,22 +586,21 @@ struct page_flags_test {
586586
int width;
587587
int shift;
588588
int mask;
589-
unsigned long value;
590589
const char *fmt;
591590
const char *name;
592591
};
593592

594-
static struct page_flags_test pft[] = {
593+
static const struct page_flags_test pft[] = {
595594
{SECTIONS_WIDTH, SECTIONS_PGSHIFT, SECTIONS_MASK,
596-
0, "%d", "section"},
595+
"%d", "section"},
597596
{NODES_WIDTH, NODES_PGSHIFT, NODES_MASK,
598-
0, "%d", "node"},
597+
"%d", "node"},
599598
{ZONES_WIDTH, ZONES_PGSHIFT, ZONES_MASK,
600-
0, "%d", "zone"},
599+
"%d", "zone"},
601600
{LAST_CPUPID_WIDTH, LAST_CPUPID_PGSHIFT, LAST_CPUPID_MASK,
602-
0, "%#x", "lastcpupid"},
601+
"%#x", "lastcpupid"},
603602
{KASAN_TAG_WIDTH, KASAN_TAG_PGSHIFT, KASAN_TAG_MASK,
604-
0, "%#x", "kasantag"},
603+
"%#x", "kasantag"},
605604
};
606605

607606
static void __init
@@ -627,10 +626,6 @@ page_flags_test(int section, int node, int zone, int last_cpupid,
627626
#endif
628627
}
629628

630-
/* Set the test value */
631-
for (i = 0; i < ARRAY_SIZE(pft); i++)
632-
pft[i].value = values[i];
633-
634629
for (i = 0; i < ARRAY_SIZE(pft); i++) {
635630
if (!pft[i].width)
636631
continue;
@@ -640,11 +635,11 @@ page_flags_test(int section, int node, int zone, int last_cpupid,
640635
size = strlen(cmp_buf);
641636
}
642637

643-
page_flags |= (pft[i].value & pft[i].mask) << pft[i].shift;
638+
page_flags |= (values[i] & pft[i].mask) << pft[i].shift;
644639
snprintf(cmp_buf + size, BUF_SIZE - size, "%s=", pft[i].name);
645640
size = strlen(cmp_buf);
646641
snprintf(cmp_buf + size, BUF_SIZE - size, pft[i].fmt,
647-
pft[i].value & pft[i].mask);
642+
values[i] & pft[i].mask);
648643
size = strlen(cmp_buf);
649644
append = true;
650645
}

0 commit comments

Comments
 (0)