Fix the warnings in the 32-bit platform
Subsystems (2)
cover Fix the warnings in the 32-bit platform
This series fix two incompatible type warnings when building perf in the 32-bit platform.
Ben Zong-You Xie (2):
perf daemon: Fix the warning about time_t
perf riscv: Fix the warning due to the incompatible type
tools/perf/arch/riscv/util/header.c | 2 +- tools/perf/builtin-daemon.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-)
Signature · 7 lines
2.34.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
PATCH 1/2 perf daemon: Fix the warning about time_t
In the 32-bit platform, the size of time_t is still 64 bits. Thus, use PRIu64 to resolve the format problem.
--- tools/perf/builtin-daemon.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
tools/perf/builtin-daemon.c +5 -4
@@ -23,6 +23,7 @@#include <sys/signalfd.h> #include <sys/wait.h> #include <poll.h> +#include <inttypes.h> #include "builtin.h" #include "perf.h" #include "debug.h"
@@ -688,7 +689,7 @@ static int cmd_session_list(struct daemon *daemon, union cmd *cmd, FILE *out)/* lock */ csv_sep, daemon->base, "lock"); -fprintf (out,"%c%lu" , +fprintf (out,"%c%" PRIu64"" ,/* session up time */ csv_sep, (curr - daemon->start) /60 );
@@ -700,7 +701,7 @@ static int cmd_session_list(struct daemon *daemon, union cmd *cmd, FILE *out) daemon->base, SESSION_OUTPUT);fprintf (out," lock: %s/lock\n" , daemon->base); -fprintf (out," up: %lu minutes\n" , +fprintf (out," up: %" PRIu64" minutes\n" , (curr - daemon->start) /60 ); } }
@@ -727,7 +728,7 @@ static int cmd_session_list(struct daemon *daemon, union cmd *cmd, FILE *out)/* session ack */ csv_sep, session->base, SESSION_ACK); -fprintf (out,"%c%lu" , +fprintf (out,"%c%" PRIu64"" ,/* session up time */ csv_sep, (curr - session->start) /60 );
@@ -745,7 +746,7 @@ static int cmd_session_list(struct daemon *daemon, union cmd *cmd, FILE *out) session->base, SESSION_CONTROL);fprintf (out," ack: %s/%s\n" , session->base,SESSION_ACK ); -fprintf (out," up: %lu minutes\n" , +fprintf (out," up: %" PRIu64" minutes\n" , (curr - session->start) /60 ); } }
Signature · 7 lines
2.34.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Palmer Dabbelt
maintainerRe: [PATCH 1/2] perf daemon: Fix the warning about time_t
Quoted 48 lines · On Tue, 05 Mar 2024 04:05:00 PST (-0800), [email protected] wrote:
In the 32-bit platform, the size of
time_tis still 64 bits. Thus, use PRIu64 to resolve the format problem.Signed-off-by Ben Zong-You Xie <[email protected]>--- tools/perf/builtin-daemon.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)tools/perf/builtin-daemon.c +4
-3@@ -23,6 +23,7 @@#include <sys/signalfd.h> #include <sys/wait.h> #include <poll.h> +#include <inttypes.h> #include "builtin.h" #include "perf.h" #include "debug.h" @@ -688,7 +689,7 @@ static int cmd_session_list(struct daemon *daemon, union cmd *cmd, FILE *out)/* lock */ csv_sep, daemon->base, "lock"); -fprintf (out,"%c%lu" , +fprintf (out,"%c%" PRIu64"" ,/* session up time */ csv_sep, (curr - daemon->start) /60 );@@ -700,7 +701,7 @@ static int cmd_session_list(struct daemon *daemon, union cmd *cmd, FILE *out) daemon->base, SESSION_OUTPUT);fprintf (out," lock: %s/lock\n" , daemon->base); -fprintf (out," up: %lu minutes\n" , +fprintf (out," up: %" PRIu64" minutes\n" , (curr - daemon->start) /60 ); } }@@ -727,7 +728,7 @@ static int cmd_session_list(struct daemon *daemon, union cmd *cmd, FILE *out)/* session ack */ csv_sep, session->base, SESSION_ACK); -fprintf (out,"%c%lu" , +fprintf (out,"%c%" PRIu64"" ,/* session up time */ csv_sep, (curr - session->start) /60 );
tools/perf/builtin-daemon.c static int cmd_session_list(struct daemon *daemon, union cmd *cmd, FILE *out) · line 752
Quoted 8 lines
tools/perf/builtin-daemon.c +1
-1@@ -745,7 +746,7 @@ static int cmd_session_list(struct daemon *daemon, union cmd *cmd, FILE *out) session->base, SESSION_CONTROL);fprintf (out," ack: %s/%s\n" , session->base,SESSION_ACK ); -fprintf (out," up: %lu minutes\n" , +fprintf (out," up: %" PRIu64" minutes\n" , (curr - session->start) /60 ); } }
Sorry I missed this earlier, but IIUC this one is actually incorrect: on most 32-bit platforms time_t is 32 bits, it was later extended to 64 bits. RISC-V is special because the work to make time_t 64-bit had started when we submitted the port, so we just jumped straight to the legacy-free uABI (after some headaches).
So IIUC this would introduce a warning for some other targets. Either way I shouldn't have picked it up as it's not a RISC-V patch (this is a generic perf file), so I'm going to drop it from fixes.
Sorry for the confusion!
PATCH 2/2 perf riscv: Fix the warning due to the incompatible type
In reply to Ben Zong-You XieIn the 32-bit platform, the second argument of getline is expectd to be 'size_t *'(aka 'unsigned int *'), but line_sz is of type 'unsigned long *'. Therefore, declare line_sz as size_t.
--- tools/perf/arch/riscv/util/header.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/arch/riscv/util/header.c +1 -1
@@ -41,7 +41,7 @@ static char *_get_cpuid(void)char *mimpid =NULL ;char *cpuid =NULL ;int read; -unsigned long line_sz; +size_t line_sz;FILE *cpuinfo; cpuinfo =fopen (CPUINFO ,"r" );
Signature · 7 lines
2.34.1 _______________________________________________ linux-riscv mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-riscv
Hi Ben,
Quoted 11 lines · Ben Zong-You Xie
This series fix two incompatible type warnings when building perf in the 32-bit platform.
Ben Zong-You Xie (2):
perf daemon: Fix the warning abouttime_t
perf riscv: Fix the warning due to the incompatible typetools/perf/arch/riscv/util/header.c | 2 +- tools/perf/builtin-daemon.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-)
For the series, you can add:
To me this should go into -fixes, but which tree? perf or riscv?
Thanks,
Alex