Skip to content

Commit

Permalink
tools/mm: -Werror fixes in page-types/slabinfo
Browse files Browse the repository at this point in the history
commit ece5897 upstream.

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]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
wwladikw authored and gregkh committed Nov 8, 2024
1 parent edd1f90 commit 9523a02
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 5 additions & 4 deletions tools/mm/page-types.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <time.h>
#include <setjmp.h>
#include <signal.h>
#include <inttypes.h>
#include <sys/types.h>
#include <sys/errno.h>
#include <sys/fcntl.h>
Expand Down Expand Up @@ -392,9 +393,9 @@ static void show_page_range(unsigned long voffset, unsigned long offset,
if (opt_file)
printf("%lx\t", voff);
if (opt_list_cgroup)
printf("@%llu\t", (unsigned long long)cgroup0);
printf("@%" PRIu64 "\t", cgroup0);
if (opt_list_mapcnt)
printf("%lu\t", mapcnt0);
printf("%" PRIu64 "\t", mapcnt0);
printf("%lx\t%lx\t%s\n",
index, count, page_flag_name(flags0));
}
Expand All @@ -420,9 +421,9 @@ static void show_page(unsigned long voffset, unsigned long offset,
if (opt_file)
printf("%lx\t", voffset);
if (opt_list_cgroup)
printf("@%llu\t", (unsigned long long)cgroup);
printf("@%" PRIu64 "\t", cgroup)
if (opt_list_mapcnt)
printf("%lu\t", mapcnt);
printf("%" PRIu64 "\t", mapcnt);

printf("%lx\t%s\n", offset, page_flag_name(flags));
}
Expand Down
4 changes: 3 additions & 1 deletion tools/mm/slabinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,9 @@ static void read_slab_dir(void)
slab->cpu_partial_free = get_obj("cpu_partial_free");
slab->alloc_node_mismatch = get_obj("alloc_node_mismatch");
slab->deactivate_bypass = get_obj("deactivate_bypass");
chdir("..");
if (chdir(".."))
fatal("Unable to chdir from slab ../%s\n",
slab->name);
if (slab->name[0] == ':')
alias_targets++;
slab++;
Expand Down

0 comments on commit 9523a02

Please sign in to comment.