Skip to content

Commit ece5897

Browse files
wwladikwakpm00
authored andcommitted
tools/mm: -Werror fixes in page-types/slabinfo
Commit e6d2c43 ("tools/mm: allow users to provide additional cflags/ldflags") passes now CFLAGS to Makefile. With this, build systems with default -Werror enabled found: slabinfo.c:1300:25: error: ignoring return value of 'chdir' declared with attribute 'warn_unused_result' [-Werror=unused-result]                          chdir("..");                          ^~~~~~~~~~~ page-types.c:397:35: error: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'uint64_t' {aka 'long long unsigned int'} [-Werror=format=]                          printf("%lu\t", mapcnt0);                                  ~~^     ~~~~~~~ .. Fix page-types by using PRIu64 for uint64_t prints and check in slabinfo for return code on chdir(".."). Link: https://lkml.kernel.org/r/[email protected] Fixes: e6d2c43 ("tools/mm: allow users to provide additional cflags/ldflags") Signed-off-by: Wladislav Wiebe <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: Herton R. Krzesinski <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 5168a68 commit ece5897

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

tools/mm/page-types.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <time.h>
2323
#include <setjmp.h>
2424
#include <signal.h>
25+
#include <inttypes.h>
2526
#include <sys/types.h>
2627
#include <sys/errno.h>
2728
#include <sys/fcntl.h>
@@ -391,9 +392,9 @@ static void show_page_range(unsigned long voffset, unsigned long offset,
391392
if (opt_file)
392393
printf("%lx\t", voff);
393394
if (opt_list_cgroup)
394-
printf("@%llu\t", (unsigned long long)cgroup0);
395+
printf("@%" PRIu64 "\t", cgroup0);
395396
if (opt_list_mapcnt)
396-
printf("%lu\t", mapcnt0);
397+
printf("%" PRIu64 "\t", mapcnt0);
397398
printf("%lx\t%lx\t%s\n",
398399
index, count, page_flag_name(flags0));
399400
}
@@ -419,9 +420,9 @@ static void show_page(unsigned long voffset, unsigned long offset,
419420
if (opt_file)
420421
printf("%lx\t", voffset);
421422
if (opt_list_cgroup)
422-
printf("@%llu\t", (unsigned long long)cgroup);
423+
printf("@%" PRIu64 "\t", cgroup)
423424
if (opt_list_mapcnt)
424-
printf("%lu\t", mapcnt);
425+
printf("%" PRIu64 "\t", mapcnt);
425426

426427
printf("%lx\t%s\n", offset, page_flag_name(flags));
427428
}

tools/mm/slabinfo.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,9 @@ static void read_slab_dir(void)
12971297
slab->cpu_partial_free = get_obj("cpu_partial_free");
12981298
slab->alloc_node_mismatch = get_obj("alloc_node_mismatch");
12991299
slab->deactivate_bypass = get_obj("deactivate_bypass");
1300-
chdir("..");
1300+
if (chdir(".."))
1301+
fatal("Unable to chdir from slab ../%s\n",
1302+
slab->name);
13011303
if (slab->name[0] == ':')
13021304
alias_targets++;
13031305
slab++;

0 commit comments

Comments
 (0)