Message ID | 20230801-nolibc-warnings-v2-8-1ba5ca57bd9b@weissschuh.net |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2482839vqg; Mon, 31 Jul 2023 23:44:52 -0700 (PDT) X-Google-Smtp-Source: APBJJlEZS+0c9APegedOayTliDIrDE8qK/Hd8MkAhU0+rkEyAMOoJyBHgJTV7X3Nnak0mY1xVS8F X-Received: by 2002:a05:6a20:a11d:b0:13d:3b4d:e4b4 with SMTP id q29-20020a056a20a11d00b0013d3b4de4b4mr10848876pzk.9.1690872291643; Mon, 31 Jul 2023 23:44:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690872291; cv=none; d=google.com; s=arc-20160816; b=D1Ae1GV7Msb5nEBpgHkoXZmPfPIUEs05TsyvYbezHPoAgAJgNI/7p0MFnEQH2+/hxD 3v8NMl3QDIfXUo5KdElUzONAXjaRhA5NpulM1rHs3SZVR8sKXFaByXqbkCllt+HAz4ED ZiZiE7YFBfXZa4BGDcPugGrScqAUErMtsUWEOKcnbaryFyNH5Cpj6OAN125mZnsRrxq0 /+0wBv6Ly19JZD4lqwOQK6v46aUhsNP0wZx1oEndR1TaxJPFEHY15jObHsggd7fxZ4Rq GnZW/TQt25Zxfq6bqRSbZxeUW8dXkrkccCJ+H7Pqp2oZL+zdDm4mpq5Rm6yxRGZTCvRg rxSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=wehqtfHeuCLn2jD0z8WqJNWT47c1qLFP/TIxDcxawu0=; fh=UZfhiU2pgwvZdBOe9fFEhnfTQX0/6KsvXKQubWsfhik=; b=PZw/5Ap9SKzaVeLonJjGE/c1ppaB5Z7L4fIFIEiabX3KCBqjH2auuqybB3u5OB2aQG CFherj/Q6vGXLQVU6juZPVMIK0bsn7lOcq2X1rqXCgEdnzki2xogu6nhKFLHHxOX2Qs0 nj5PrnpKTO7lHRW5PZx8BR4bhUQubBo8AE2XguofhGzSj7AnaaPjUvYtN5uhhFEnQ2La +kWY+TgUDX3tsLbCiWyUvOXSjMY2LFZL6npJ/R/inmqM8JrzLi/FQC5mVRQnYFmf4d8C QA6EPlgrn4dcA6haQaJnkwIkVgxxJSDDXKHYPQx8JsS9Wk643nXqHEGxEQkxPZwJHmgX 8LvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b="Zgy7/+IP"; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w128-20020a628286000000b00686ee44513bsi8507083pfd.124.2023.07.31.23.44.39; Mon, 31 Jul 2023 23:44:51 -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; dkim=pass header.i=@weissschuh.net header.s=mail header.b="Zgy7/+IP"; 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 S230297AbjHAFaq (ORCPT <rfc822;maxi.paulin@gmail.com> + 99 others); Tue, 1 Aug 2023 01:30:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230187AbjHAFaZ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 1 Aug 2023 01:30:25 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D44361FC8; Mon, 31 Jul 2023 22:30:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1690867813; bh=8JUgAV5EcZ7Ceowdi0aIq4X8Gxvivj8ysQlFLj7p6c0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Zgy7/+IPfRl0O1LMksFDmy6N7NQcNdJG67rCdDSGcvKRewPhw8NeCamE3SYH0z4ga 54Gb9wxDJQGsNhmU8s991DJqr6IcthpZZUGO3P/yLUUSQ4ZBZ6L45uDVmntv2z4srd YbBUtpPGNiP22z8lqs5m9RD3temuxgDnOKEXXA6o= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= <linux@weissschuh.net> Date: Tue, 01 Aug 2023 07:30:15 +0200 Subject: [PATCH v2 08/10] selftests/nolibc: avoid sign-compare warnings MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20230801-nolibc-warnings-v2-8-1ba5ca57bd9b@weissschuh.net> References: <20230801-nolibc-warnings-v2-0-1ba5ca57bd9b@weissschuh.net> In-Reply-To: <20230801-nolibc-warnings-v2-0-1ba5ca57bd9b@weissschuh.net> To: Willy Tarreau <w@1wt.eu>, Shuah Khan <shuah@kernel.org> Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Yuan Tan <tanyuan@tinylab.org>, Zhangjin Wu <falcon@tinylab.org>, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= <linux@weissschuh.net> X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1690867811; l=1128; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=8JUgAV5EcZ7Ceowdi0aIq4X8Gxvivj8ysQlFLj7p6c0=; b=pCV2p6S7run/8FWyjhQPMKcAGy/+ZpJLIc6UU7mZGDa4K0Jxx09bm7WJogGjHGrYzJ/Jei5Hm TDZs9FG2TfvDwsVcJD+zPQG8eTjqSJOlWmM5yVJFcWbY+Ba8mxEZJOw X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_PASS,T_SCC_BODY_TEXT_LINE, T_SPF_HELO_TEMPERROR,URIBL_BLOCKED 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773006108787260759 X-GMAIL-MSGID: 1773008104190923173 |
Series |
tools/nolibc: enable compiler warnings
|
|
Commit Message
Thomas Weißschuh
Aug. 1, 2023, 5:30 a.m. UTC
These warnings will be enabled later so avoid triggering them.
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
---
tools/testing/selftests/nolibc/nolibc-test.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
Hi Zhangjin! On 2023-08-01 13:48:19+0800, Zhangjin Wu wrote: > > These warnings will be enabled later so avoid triggering them. > > > > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> > > --- > > tools/testing/selftests/nolibc/nolibc-test.c | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c > > index cb17cccd0bc7..82714051c72f 100644 > > --- a/tools/testing/selftests/nolibc/nolibc-test.c > > +++ b/tools/testing/selftests/nolibc/nolibc-test.c > > @@ -749,7 +749,7 @@ static int test_mmap_munmap(void) > > }; > > > > page_size = getpagesize(); > > - if (page_size < 0) > > + if (page_size == 0) > > return -1; > > > > It was my mistake before, but do we need to align with the one used in > test_getpagesize(): > > static int test_getpagesize(void) > { > long x = getpagesize(); > int c; > > if (x < 0) > return x; > > Use 'long' instead of 'size_t' to declare page_size? Good point. Given that getpagesize() is documented as returning "int" I guess we should actually change the implementation in nolibc. > Thanks, > Zhangjin > > > /* find a right file to mmap, existed and accessible */ > > @@ -998,7 +998,7 @@ static int run_stdlib(int min, int max) > > #define EXPECT_VFPRINTF(c, expected, fmt, ...) \ > > ret += expect_vfprintf(llen, c, expected, fmt, ##__VA_ARGS__) > > > > -static int expect_vfprintf(int llen, size_t c, const char *expected, const char *fmt, ...) > > +static int expect_vfprintf(int llen, int c, const char *expected, const char *fmt, ...) > > { > > int ret, fd, w, r; > > char buf[100]; > > > > -- > > 2.41.0
> On 2023-08-01 13:48:19+0800, Zhangjin Wu wrote: > > > These warnings will be enabled later so avoid triggering them. > > > > > > Signed-off-by: Thomas Weißschuh <linux@weissschuh.net> > > > --- > > > tools/testing/selftests/nolibc/nolibc-test.c | 4 ++-- > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > > diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c > > > index cb17cccd0bc7..82714051c72f 100644 > > > --- a/tools/testing/selftests/nolibc/nolibc-test.c > > > +++ b/tools/testing/selftests/nolibc/nolibc-test.c > > > @@ -749,7 +749,7 @@ static int test_mmap_munmap(void) > > > }; > > > > > > page_size = getpagesize(); > > > - if (page_size < 0) > > > + if (page_size == 0) > > > return -1; > > > > > > > It was my mistake before, but do we need to align with the one used in > > test_getpagesize(): > > > > static int test_getpagesize(void) > > { > > long x = getpagesize(); > > int c; > > > > if (x < 0) > > return x; > > > > Use 'long' instead of 'size_t' to declare page_size? > > Good point. > > Given that getpagesize() is documented as returning "int" I guess we > should actually change the implementation in nolibc. > Yes, it is documented at [1], perhaps Willy looked at this line before: This interface, returning an int, may have problems representing appropriate values in the future. Applications should use the sysconf() function instead. [1]: https://pubs.opengroup.org/onlinepubs/7908799/xsh/getpagesize.html > > Thanks, > > Zhangjin
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index cb17cccd0bc7..82714051c72f 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -749,7 +749,7 @@ static int test_mmap_munmap(void) }; page_size = getpagesize(); - if (page_size < 0) + if (page_size == 0) return -1; /* find a right file to mmap, existed and accessible */ @@ -998,7 +998,7 @@ static int run_stdlib(int min, int max) #define EXPECT_VFPRINTF(c, expected, fmt, ...) \ ret += expect_vfprintf(llen, c, expected, fmt, ##__VA_ARGS__) -static int expect_vfprintf(int llen, size_t c, const char *expected, const char *fmt, ...) +static int expect_vfprintf(int llen, int c, const char *expected, const char *fmt, ...) { int ret, fd, w, r; char buf[100];