From patchwork Thu Aug 3 10:30:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leo Liang X-Patchwork-Id: 1816368 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RGlVS5vWqz1yZl for ; Thu, 3 Aug 2023 20:30:39 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 956873CD60C for ; Thu, 3 Aug 2023 12:30:30 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [217.194.8.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 82F263CC397 for ; Thu, 3 Aug 2023 12:30:28 +0200 (CEST) Received: from Atcsqr.andestech.com (60-248-80-70.hinet-ip.hinet.net [60.248.80.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 309581A009B3 for ; Thu, 3 Aug 2023 12:30:24 +0200 (CEST) Received: from mail.andestech.com (ATCPCS16.andestech.com [10.0.1.222]) by Atcsqr.andestech.com with ESMTP id 373AUGg4064327 for ; Thu, 3 Aug 2023 18:30:16 +0800 (+08) (envelope-from ycliang@andestech.com) Received: from atctrx.andestech.com (10.0.15.173) by ATCPCS16.andestech.com (10.0.1.222) with Microsoft SMTP Server id 14.3.498.0; Thu, 3 Aug 2023 18:30:12 +0800 From: Leo Yu-Chi Liang To: Date: Thu, 3 Aug 2023 18:30:04 +0800 Message-ID: <20230803103004.2429973-1-ycliang@andestech.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.0.15.173] X-DNSRBL: X-SPAM-SOURCE-CHECK: pass X-MAIL: Atcsqr.andestech.com 373AUGg4064327 X-Virus-Scanned: clamav-milter 1.0.1 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.4 required=7.0 tests=RDNS_DYNAMIC,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=disabled version=4.0.0 X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on in-3.smtp.seeweb.it Subject: [LTP] [PATCH 1/1] hugeshmat04: Restore the correct shmmax value X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cynthia@andestech.com, patrick@andestech.com Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" The type of shmmax is unsinged long in Linux kernel and the default value is ((~0UL) - (1UL << 24)). If we try to access this value with %ld format string in scanf-like function, we end up getting different incorrect values depends on the implementation of different libc. Fix this by accessing shmmax with the correct %lu format string. Signed-off-by: Leo Yu-Chi Liang --- testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c index 50efa8a52..b3e7c272a 100644 --- a/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c +++ b/testcases/kernel/mem/hugetlb/hugeshmat/hugeshmat04.c @@ -83,12 +83,12 @@ static void setup(void) long hpage_size, orig_hugepages; orig_hugepages = get_sys_tune("nr_hugepages"); - SAFE_FILE_SCANF(PATH_SHMMAX, "%ld", &orig_shmmax); - SAFE_FILE_PRINTF(PATH_SHMMAX, "%ld", (long)SIZE); - SAFE_FILE_SCANF(PATH_SHMMAX, "%ld", &new_shmmax); + SAFE_FILE_SCANF(PATH_SHMMAX, "%lu", &orig_shmmax); + SAFE_FILE_PRINTF(PATH_SHMMAX, "%lu", (long)SIZE); + SAFE_FILE_SCANF(PATH_SHMMAX, "%lu", &new_shmmax); if (new_shmmax < SIZE) - tst_brk(TCONF, "shmmax too low, have: %ld", new_shmmax); + tst_brk(TCONF, "shmmax too low, have: %lu", new_shmmax); hpage_size = SAFE_READ_MEMINFO("Hugepagesize:") * 1024; @@ -99,7 +99,7 @@ static void setup(void) static void cleanup(void) { if (orig_shmmax != -1) - SAFE_FILE_PRINTF(PATH_SHMMAX, "%ld", orig_shmmax); + SAFE_FILE_PRINTF(PATH_SHMMAX, "%lu", orig_shmmax); } static struct tst_test test = {