* [PATCH] tools/mm: -Werror fixes in page-types/slabinfo
@ 2024-10-22 17:21 Wladislav Wiebe
2024-10-23 23:51 ` Andrew Morton
0 siblings, 1 reply; 3+ messages in thread
From: Wladislav Wiebe @ 2024-10-22 17:21 UTC (permalink / raw)
To: akpm, linux-mm; +Cc: linux-kernel, wladislav.kw
Commit e6d2c436ff693 ("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("..").
Signed-off-by: Wladislav Wiebe <wladislav.kw@gmail.com>
---
tools/mm/page-types.c | 9 +++++----
tools/mm/slabinfo.c | 3 ++-
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/tools/mm/page-types.c b/tools/mm/page-types.c
index 8d5595b6c59f8..69f00eab1b8c7 100644
--- a/tools/mm/page-types.c
+++ b/tools/mm/page-types.c
@@ -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>
@@ -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));
}
@@ -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));
}
diff --git a/tools/mm/slabinfo.c b/tools/mm/slabinfo.c
index cfaeaea71042e..643fd9558e09a 100644
--- a/tools/mm/slabinfo.c
+++ b/tools/mm/slabinfo.c
@@ -1297,7 +1297,8 @@ 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++;
--
2.39.3.dirty
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tools/mm: -Werror fixes in page-types/slabinfo
2024-10-22 17:21 [PATCH] tools/mm: -Werror fixes in page-types/slabinfo Wladislav Wiebe
@ 2024-10-23 23:51 ` Andrew Morton
2024-10-24 9:48 ` Wladislav Wiebe
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2024-10-23 23:51 UTC (permalink / raw)
To: Wladislav Wiebe; +Cc: linux-mm, linux-kernel, Vlastimil Babka
On Tue, 22 Oct 2024 19:21:13 +0200 Wladislav Wiebe <wladislav.kw@gmail.com> wrote:
> Commit e6d2c436ff693 ("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("..").
>
Thanks.
Your email client messed this up in strange ways, so I basically typed
it in again. I added the Fixes: target and a cc:stable.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tools/mm: -Werror fixes in page-types/slabinfo
2024-10-23 23:51 ` Andrew Morton
@ 2024-10-24 9:48 ` Wladislav Wiebe
0 siblings, 0 replies; 3+ messages in thread
From: Wladislav Wiebe @ 2024-10-24 9:48 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-mm, linux-kernel, Vlastimil Babka
On 24/10/2024 01:51, Andrew Morton wrote:
> On Tue, 22 Oct 2024 19:21:13 +0200 Wladislav Wiebe <wladislav.kw@gmail.com> wrote:
>
>> Commit e6d2c436ff693 ("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("..").
>>
> Thanks.
>
> Your email client messed this up in strange ways, so I basically typed
> it in again. I added the Fixes: target and a cc:stable.
thanks for the feedback, seems something went wrong after updating my mail client, I will fix it.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-10-24 9:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-22 17:21 [PATCH] tools/mm: -Werror fixes in page-types/slabinfo Wladislav Wiebe
2024-10-23 23:51 ` Andrew Morton
2024-10-24 9:48 ` Wladislav Wiebe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox