Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp3124661rwd; Mon, 29 May 2023 06:08:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4AskLYOlqe99oaFIFL5h+k4CMbrywBdB3H2kDMp+av9iRyYoYShclCYS/d9WiJa+aq1cLZ X-Received: by 2002:a05:6a00:3924:b0:646:74ce:a36c with SMTP id fh36-20020a056a00392400b0064674cea36cmr14699971pfb.8.1685365728004; Mon, 29 May 2023 06:08:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685365727; cv=none; d=google.com; s=arc-20160816; b=aD2VEKm8K+X7xEFrmkL0LjIgllMWM1NLUMYaY6pE9GaiKnlJoX+tec8zyMnv8IKKBE rqo0VCCcpvWQft2LZvLXVXKOu1iectRUWNK+x7a9x0Qf52fpc6dZLINjPIc/YdC3cMV7 vqm20cCWoQjWa2AGltZruVPW8HCLPJYA7N3o6XpdpDzsMz6pNhoy8Z34kyW4wrphZnyY W4UOxUmKLToGHWt/q/qHri+PJVpov/00O2bBx4vksKlYrtD54fXncJQoHlrmiAYgnCD8 F/0PHbyVUWNWGN/mX9rH1KiNTcKsG/tWvPg1SfqihA23hz5rkY8N1mqwp3KUGVVcazOZ gsfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=2iUbdNEOA4z8a2vl+AXpPyf365dTj++T8/CQP6JH7Y0=; b=C98RxzugiLcnds9ZpN0VaW+p9entGyXvZMYu2zMrbcW+D/3DwPnu7Q/3xFdhZw55UF XrfvFylgaOO88mFiheT9iT6q1seZlgtHL4BeiOWB3JlzX5EUSxE7T3n0jCiVcCjJARVJ FpPEh+tgsG/fN3SSrLVmgniPuHXcFM4fW6l02H7Sv74CLT/6HtJo+6FZHlsV5HpHx0Wc pFr3+v9H2gsGmQNbCMUXdnIUSvkdODl5LanSXK/++xcadd1aYcPnR9Ctuok6LPIFyyuJ B2cSX979emh2FonLGyUViF0oNymSwumbj7WJal+g08/iGyheoKezFgqtFB3Pe9bXylEF 03Cg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y191-20020a638ac8000000b0053b8570baafsi9087401pgd.444.2023.05.29.06.08.34; Mon, 29 May 2023 06:08:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229483AbjE2NAV (ORCPT + 99 others); Mon, 29 May 2023 09:00:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229455AbjE2NAU (ORCPT ); Mon, 29 May 2023 09:00:20 -0400 Received: from bg4.exmail.qq.com (bg4.exmail.qq.com [43.155.67.158]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D24391; Mon, 29 May 2023 06:00:18 -0700 (PDT) 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:tinylab.org:qybglogicsvrsz:qybglogicsvrsz3a-3 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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; } -- 2.25.1