From patchwork Mon May 29 13:00:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zhangjin Wu X-Patchwork-Id: 13258542 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D24C0C77B7E for ; Mon, 29 May 2023 13:00:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LGYjU2gajyWnZoEeWMe+4LSHV1RiMA87+2AmAKjjWFA=; b=mJmmnyDI6k8eHS VGluCpsCJVvRzh9d9oWMcQvuxnNkUPflT2RvqpuvYiQ2q/AvGgQHB6srrNPt6ELO3mAMJnxbADklK +4NZQGI3QhuoiqWIHgCDP0ANc3QHXHfQz+dnJPJgYhL3r1sS3BRrgJf7/AJFqoBJ7yItavSJ06m3U +GeUYNhjq93w92e1bP4bVRP1n8AfC5QhglCwVdXuptSqebpIrZQE2EJCqsetWqDJ9LrP1hRjhMc5D p1QMtQsLK88IaCfzwzaVCCEjNRB8QpXIX1IanDDT+krXCCfUjnmSWRGFF1LGH/xBiNICOGs2LsV8x P+cJMib1dZrdi5LTP+Eg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q3cU4-00AW8B-2Q; Mon, 29 May 2023 13:00:24 +0000 Received: from bg4.exmail.qq.com ([43.154.54.12]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q3cU1-00AW6j-2Q for linux-riscv@lists.infradead.org; Mon, 29 May 2023 13:00:23 +0000 X-QQ-mid: bizesmtp78t1685365209tn304cds Received: from linux-lab-host.localdomain ( [119.123.130.80]) by bizesmtp.qq.com (ESMTP) with id ; Mon, 29 May 2023 21:00:07 +0800 (CST) X-QQ-SSF: 00200000000000D0V000000A0000000 X-QQ-FEAT: rZJGTgY0+YPLNKIjmriA1LyRD/9GVh50DK49bFM+u4kQwihN+a4qP4/e9Lr+I tlmnaNZ+nIUm6A2omPGy/+sSzZrOubvL+5ZvqVr3IsHscrGxbzvQRuwqG7viOZO6b+sh992 HUiH7R5VAiWB6QaViufuoxqSKbNbwowdK7F797RyTOJhl1+JgSrGd+24WyK7eVDXzu83zSv eDNpUtxLJstDd39F4/RIIHuzZzCNldhAlJF4/t0rfGfd1dgRmCa3+IYz/wD7XfyhPtK57Ao Rmvu4usRDG5AyT2Kj66AC6iBUeSMjXIqPJypayw8mcuGFHrB0/PmUIReymTHZVQCZWy2w7j hLj7rV3KyYOR8VuFnHZ7q1HAwSUI7VPcjcPc9a8f6dEHBjOv8+WhJvLFKrnmy9ZVB6+7sNR X-QQ-GoodBg: 0 X-BIZMAIL-ID: 879951463538973120 From: Zhangjin Wu To: w@1wt.eu Cc: arnd@arndb.de, falcon@tinylab.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org, thomas@t-8ch.de Subject: [PATCH v2 3/7] selftests/nolibc: fix up compile warning with glibc on x86_64 Date: Mon, 29 May 2023 21:00:01 +0800 Message-Id: X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230529_060022_082723_7ED52717 X-CRM114-Status: GOOD ( 11.13 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Compiling nolibc-test.c with gcc on x86_64 got such warning: tools/testing/selftests/nolibc/nolibc-test.c: In function ‘expect_eq’: tools/testing/selftests/nolibc/nolibc-test.c:177:24: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘uint64_t’ {aka ‘long unsigned int’} [-Wformat=] 177 | llen += printf(" = %lld ", expr); | ~~~^ ~~~~ | | | | | uint64_t {aka long unsigned int} | long long int | %ld It because that glibc defines uint64_t as "unsigned long int" when word size (means sizeof(long)) is 64bit (see include/bits/types.h), but nolibc directly use the 64bit "unsigned long long" (see tools/include/nolibc/stdint.h), which is simpler, seems kernel uses it too (include/uapi/asm-generic/int-ll64.h). It is able to do like glibc, defining __WORDSIZE for all of platforms and using "unsigned long int" to define uint64_t when __WORDSIZE is 64bits, but here uses a simpler solution: nolibc always requires %lld to match "unsigned long long", for others, only require %lld when word size is 32bit. Signed-off-by: Zhangjin Wu --- tools/testing/selftests/nolibc/nolibc-test.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index d417ca5d976f..7f9b716fd9b1 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -174,7 +174,11 @@ static int expect_eq(uint64_t expr, int llen, uint64_t val) { int ret = !(expr == val); +#if __SIZEOF_LONG__ == 4 || defined(NOLIBC) llen += printf(" = %lld ", expr); +#else + llen += printf(" = %ld ", expr); +#endif pad_spc(llen, 64, ret ? "[FAIL]\n" : " [OK]\n"); return ret; }