Skip to contentSkip to conversation

ltp: Fix ltp-pan crash on 32bit arches using 64bit time_t

PATCH New Khem Raj 1 participant 1 message Dec 21, 2020

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH 1/1 ltp: Fix ltp-pan crash on 32bit arches using 64bit time_t

ltp-pan crashes on riscv32/musl due to shorter width assigned to time_t in printf format

---
 ...an-Use-long-long-int-to-print-time_t.patch | 33 +++++++++++++++++++
 meta/recipes-extended/ltp/ltp_20200930.bb     |  1 +
 2 files changed, 34 insertions(+)
 create mode 100644 meta/recipes-extended/ltp/ltp/0001-ltp-pan-Use-long-long-int-to-print-time_t.patch
meta/recipes-extended/ltp/ltp/0001-ltp-pan-Use-long-long-int-to-print-time_t.patch new file +33 -0
new file mode 100644
index 0000000000..381ac417ca
@@ -0,0 +1,33 @@
+From 6c2085badea7b461245837c452a0d3d8a8c2afff Mon Sep 17 00:00:00 2001
+From: Khem Raj <[email protected]>
+Date: Sun, 20 Dec 2020 22:09:28 -0800
+Subject: [PATCH] ltp-pan: Use long long int to print time_t
+
+Some newer 32bit architectures ( e.g. riscv32 ) uses 64bit time_t so
+using %ld is not sufficient to print time_t, this also fixes a crash in
+ltp-pan on riscv32
+
+Upstream-Status: Submitted [https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/]
+Signed-off-by: Khem Raj <[email protected]>
+---
+ pan/ltp-pan.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/pan/ltp-pan.c b/pan/ltp-pan.c
+index 8b9fbe5594..54b7cb8f26 100644
+--- a/pan/ltp-pan.c
++++ b/pan/ltp-pan.c
+@@ -1389,8 +1389,8 @@ static void write_test_start(struct tag_pgrp *running, int no_kmsg)
+ 	if (!strcmp(reporttype, "rts")) {
+ 
+ 		printf
+-		    ("%s\ntag=%s stime=%ld\ncmdline=\"%s\"\ncontacts=\"%s\"\nanalysis=%s\n%s\n",
+-		     "<<<test_start>>>", running->cmd->name, running->mystime,
++		    ("%s\ntag=%s stime=%lld\ncmdline=\"%s\"\ncontacts=\"%s\"\nanalysis=%s\n%s\n",
++		     "<<<test_start>>>", running->cmd->name, (long long)running->mystime,
+ 		     running->cmd->cmdline, "", "exit", "<<<test_output>>>");
+ 	}
+ 	fflush(stdout);
+-- 
+2.29.2
+
meta/recipes-extended/ltp/ltp_20200930.bb +1 -0
index 7acf15b360..e3c49fbf53 100644
@@ -34,6 +34,7 @@ SRC_URI = "git://github.com/linux-test-project/ltp.git \
            file://0007-Fix-test_proc_kill-hanging.patch \
            file://0001-Add-more-musl-exclusions.patch \
            file://0001-Remove-OOM-tests-from-runtest-mm.patch \
+           file://0001-ltp-pan-Use-long-long-int-to-print-time_t.patch \
            "
 
 S = "${WORKDIR}/git"
Signature · 1 line
2.29.2