From 0465c0fd230391c7d09db6e6e1a325f6ae4169c5 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Thu, 23 Jan 2025 11:20:21 +0000 Subject: [PATCH] core-thrash: replace %jx sscanf with 32/64 bit portable version icc complains because of %jx being used with off_t, off_t may be smaller than a intmax_t type, so cater for different sizes. Signed-off-by: Colin Ian King --- core-thrash.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/core-thrash.c b/core-thrash.c index 34847ac16..1b412b6c0 100644 --- a/core-thrash.c +++ b/core-thrash.c @@ -176,12 +176,28 @@ static int stress_pagein_proc(const pid_t pid) * Look for field 0060b000-0060c000 r--p 0000b000 08:01 1901726 */ while (thrash_run && fgets(buffer, sizeof(buffer), fpmap)) { - off_t begin, end, len, off; + off_t off, begin, end, len; char tmppath[1024]; char prot[6]; - if (sscanf(buffer, "%jx-%jx %5s %*x %*x:%*x %*d %1023s", &begin, &end, prot, tmppath) != 4) + /* portable off_t and scanf is a pain */ + if ((sizeof(off_t) < 32) || (sizeof(off_t) > 64)) continue; + else if (sizeof(off_t) == 32) { + int32_t begin32, end32; + + if (sscanf(buffer, "%" SCNx32 "-%" SCNx32 " %5s %*x %*x:%*x %*d %1023s", &begin32, &end32, prot, tmppath) != 4) + continue; + begin = (off_t)begin32; + end = (off_t)end32; + } else if (sizeof(off_t) <= 64) { + int64_t begin64, end64; + + if (sscanf(buffer, "%" SCNx64 "-%" SCNx64 " %5s %*x %*x:%*x %*d %1023s", &begin64, &end64, prot, tmppath) != 4) + continue; + begin = (off_t)begin64; + end = (off_t)end64; + } /* ignore non-readable or non-private mappings */ if ((prot[0] != 'r') && (prot[3] != 'p'))