From patchwork Tue Aug 1 05:30:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13335773 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7C5AEB64DD for ; Tue, 1 Aug 2023 05:30:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230096AbjHAFaT (ORCPT ); Tue, 1 Aug 2023 01:30:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230076AbjHAFaS (ORCPT ); Tue, 1 Aug 2023 01:30:18 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 656171FC9; Mon, 31 Jul 2023 22:30:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1690867812; bh=LvmZQIdIvROwNs8BBjCvj4x9lJTSLnFE4blB41Pgq2w=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=YsSJpqZ2f/fuBOe5XDdxzjkeIbjaFCdpFWaAu5aP0JM1Si7mfcjWZfrWbsLy/RwkE IqQbfH5hv6EuqnFt1Vjn/qfWgkIZ3BKmJjTb1aRzu6vZmecUEiYGoSdhmWleRCM0hP dcemk/ArZ0C72K/RL43mX2eoBpZZr2Ktas9VEDeg= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 01 Aug 2023 07:30:08 +0200 Subject: [PATCH v2 01/10] tools/nolibc: drop unused variables MIME-Version: 1.0 Message-Id: <20230801-nolibc-warnings-v2-1-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 , Shuah Khan Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Yuan Tan , Zhangjin Wu , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1690867811; l=540; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=LvmZQIdIvROwNs8BBjCvj4x9lJTSLnFE4blB41Pgq2w=; b=ptgAfvbtUCQspRY5LLdaICU9RvnVqt3pjEXxvYG8xyULrsdoSM0Affxkp6csANNKE7RmW659D skYac7bVfXmBbbdEyqrDJoUF6P0IRr+6/wl87piN8r0AphhAFb5BvnD X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Nobody needs it, get rid of it. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/sys.h | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 8bfe7db20b80..889ccf5f0d56 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -738,7 +738,6 @@ static __attribute__((unused)) int open(const char *path, int flags, ...) { mode_t mode = 0; - int ret; if (flags & O_CREAT) { va_list args; From patchwork Tue Aug 1 05:30:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13335774 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DD96C00528 for ; Tue, 1 Aug 2023 05:30:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230111AbjHAFaU (ORCPT ); Tue, 1 Aug 2023 01:30:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230080AbjHAFaS (ORCPT ); Tue, 1 Aug 2023 01:30:18 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [IPv6:2a01:4f8:c010:41de::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FC7E1FC8; Mon, 31 Jul 2023 22:30:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1690867812; bh=9JcxE/sRcogPp0X3mpqUzzaMeZv7ua9TZds5/yNngTc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=bxqjKiZq2c9Jtsp+M1m02PFTibkb0pfk/Kp2mOnDkA0C9DQG7xI0hO3umOgBwTgo1 Xebk3FyJsTz6vrYb4/PZJPxGpDHWI5XlHkt7GVNTUMPJsyilyYr+Q4zt+sUneBCbSW fTW+3q/Ntk2am8fnyWjDSTsDYu//KGf7ZrFHMDQk= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 01 Aug 2023 07:30:09 +0200 Subject: [PATCH v2 02/10] tools/nolibc: sys: avoid implicit sign cast MIME-Version: 1.0 Message-Id: <20230801-nolibc-warnings-v2-2-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 , Shuah Khan Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Yuan Tan , Zhangjin Wu , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1690867811; l=704; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=9JcxE/sRcogPp0X3mpqUzzaMeZv7ua9TZds5/yNngTc=; b=pDCw8ZJtjbVkmrXmNV1kxMUun7xzLlpXVsSxJJLeAbQtZE/iBEkEZgIPjqXWPbJC49X9Or75F SGWD4IbaZcKBAq5SY9G6Uam5wrMHWvW0QOPmRsSL8w8Gg5odi2eS61h X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org getauxval() returns an unsigned long but the overall type of the ternary operator needs to be signed. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/sys.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 889ccf5f0d56..2c5d9b06acf5 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -466,7 +466,7 @@ static unsigned long getauxval(unsigned long key); static __attribute__((unused)) long getpagesize(void) { - return __sysret(getauxval(AT_PAGESZ) ?: -ENOENT); + return __sysret((long)getauxval(AT_PAGESZ) ?: -ENOENT); } From patchwork Tue Aug 1 05:30:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13335777 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B2560C00528 for ; Tue, 1 Aug 2023 05:30:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230184AbjHAFaY (ORCPT ); Tue, 1 Aug 2023 01:30:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230099AbjHAFaV (ORCPT ); Tue, 1 Aug 2023 01:30:21 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 145031BF1; Mon, 31 Jul 2023 22:30:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1690867812; bh=K1nxWE0fnm2Rd+ee1CtTMEzoebCOmluJAHtmf4S2JYw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=cIt+g1aA+jbm6fXI+/dPh2DuwqkoKOOo4wP+v0r+PducTtkw+/Hva1UQ5XBBBqTPH xdjYo7Su6Yf1Dn/C6onQtRLZDAX9APRXi2kFZzWxTu4E8o1G3ASEn/Ecg1F2OS/7wi YzmVUoTN8hYPTULKPmDDTqzc3xQe5J+7Kqyoylqg= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 01 Aug 2023 07:30:10 +0200 Subject: [PATCH v2 03/10] tools/nolibc: stdint: use int for size_t on 32bit MIME-Version: 1.0 Message-Id: <20230801-nolibc-warnings-v2-3-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 , Shuah Khan Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Yuan Tan , Zhangjin Wu , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1690867811; l=1072; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=K1nxWE0fnm2Rd+ee1CtTMEzoebCOmluJAHtmf4S2JYw=; b=ZyMAlp1fnMw5VR86DHSU2eD2euSXRI/6caWE9TNe6th9+CHufDYJ1f+j9pRXLM9tMXSXEP4Mb iQk6ibEQH0oBpfYcs26MtSjoWM0HJzl4CdfjtL5bBv8mVr9Jw/HUmse X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Otherwise both gcc and clang may generate warnings about type mismatches: sysroot/mips/include/string.h:12:14: warning: mismatch in argument 1 type of built-in function 'malloc'; expected 'unsigned int' [-Wbuiltin-declaration-mismatch] 12 | static void *malloc(size_t len); | ^~~~~~ Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/stdint.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/include/nolibc/stdint.h b/tools/include/nolibc/stdint.h index 4b282435a59a..0f390c3028d8 100644 --- a/tools/include/nolibc/stdint.h +++ b/tools/include/nolibc/stdint.h @@ -15,7 +15,11 @@ typedef unsigned int uint32_t; typedef signed int int32_t; typedef unsigned long long uint64_t; typedef signed long long int64_t; +#if __SIZE_WIDTH__ == 64 typedef unsigned long size_t; +#else +typedef unsigned int size_t; +#endif typedef signed long ssize_t; typedef unsigned long uintptr_t; typedef signed long intptr_t; From patchwork Tue Aug 1 05:30:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13335775 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA97CEB64DD for ; Tue, 1 Aug 2023 05:30:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230152AbjHAFaW (ORCPT ); Tue, 1 Aug 2023 01:30:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230136AbjHAFaV (ORCPT ); Tue, 1 Aug 2023 01:30:21 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 867AC1FC3; Mon, 31 Jul 2023 22:30:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1690867812; bh=j96CuOLvJppfEA70wZqqPAJsnlrN3A9fJ6xA4htw4tY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=R35OYw1zLozA6mdagb67ZWoj6xAVDTadUXownJy7jL8pv5aqZeCLokMpx2sCtNLxl 6kE1tAb6W84xwAP/dJXnGR3z+uM+1FUIVnL3Uh7t+hftKSzb8HYXPOuzXQt4sGJoja JS+5dO3mCd7v6TPhJXnmxh0JRr3WZ2KyAJbCwXYQ= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 01 Aug 2023 07:30:11 +0200 Subject: [PATCH v2 04/10] selftests/nolibc: drop unused variables MIME-Version: 1.0 Message-Id: <20230801-nolibc-warnings-v2-4-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 , Shuah Khan Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Yuan Tan , Zhangjin Wu , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1690867811; l=1031; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=j96CuOLvJppfEA70wZqqPAJsnlrN3A9fJ6xA4htw4tY=; b=SElh9ZEtkHumDZa9Llk+sszzBJ4Sddw5iSXmUudN8LRkmWmuPYLugrF3XUh4J0KOPv7AhPuD0 Psa9lbfPYAqAP+CZbuiKmFN2e/CWRjkl+ouZhqVkXyzX3CzEqfx26W6 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org These got copied around as new testcases where created. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/nolibc-test.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 03b1d30f5507..9a5a212ea55c 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -885,9 +885,7 @@ int run_syscall(int min, int max) int run_stdlib(int min, int max) { int test; - int tmp; int ret = 0; - void *p1, *p2; for (test = min; test >= 0 && test <= max; test++) { int llen = 0; /* line length */ @@ -1028,9 +1026,7 @@ static int expect_vfprintf(int llen, size_t c, const char *expected, const char static int run_vfprintf(int min, int max) { int test; - int tmp; int ret = 0; - void *p1, *p2; for (test = min; test >= 0 && test <= max; test++) { int llen = 0; /* line length */ From patchwork Tue Aug 1 05:30:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13335783 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84520EB64DD for ; Tue, 1 Aug 2023 05:30:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230260AbjHAFa3 (ORCPT ); Tue, 1 Aug 2023 01:30:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230204AbjHAFaZ (ORCPT ); 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 DBDF41FC9; 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=t0qk+AwJl3e2iYM6YfPN4zCJ2i2DkKFX7aAcqHYG5aA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=WFrragxd5fLMtRVUxOPQ/n6rmX73PLARLJYW9GdmtaAnXAhlESunZamp8M3cUXor3 A6NMBubKMopQhR7bbx5ggJCGtwwEB9MZb1Hj0j6wx/twdEfhU7eXy85u5fne+NZlu9 GTuIEI4fOS584zki+fR/9vtQyTIlhEQdR3DJ39cQ= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 01 Aug 2023 07:30:12 +0200 Subject: [PATCH v2 05/10] selftests/nolibc: mark test helpers as potentially unused MIME-Version: 1.0 Message-Id: <20230801-nolibc-warnings-v2-5-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 , Shuah Khan Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Yuan Tan , Zhangjin Wu , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1690867811; l=10728; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=t0qk+AwJl3e2iYM6YfPN4zCJ2i2DkKFX7aAcqHYG5aA=; b=At9i11TsxMuGKJoH9+QjkI+INCTwFKJ0R3w/+/5KqKD2gt74Q9anxUpepv72jzpom7vZBXf0C o6GV9FAuRARBlaxz+ZQQLT2uo8JGOGXvPoqlEW7JWvrEXqpDzA+sk85 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org When warning about unused functions these would be reported by we want to keep them for future use. Suggested-by: Zhangjin Wu Link: https://lore.kernel.org/lkml/20230731064826.16584-1-falcon@tinylab.org/ Suggested-by: Willy Tarreau Link: https://lore.kernel.org/lkml/20230731224929.GA18296@1wt.eu/ Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/nolibc-test.c | 75 ++++++++++++++++++---------- 1 file changed, 50 insertions(+), 25 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 9a5a212ea55c..1555759bb164 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -164,7 +164,8 @@ static void result(int llen, enum RESULT r) #define EXPECT_ZR(cond, expr) \ do { if (!(cond)) result(llen, SKIPPED); else ret += expect_zr(expr, llen); } while (0) -static int expect_zr(int expr, int llen) +static __attribute__((unused)) +int expect_zr(int expr, int llen) { int ret = !(expr == 0); @@ -177,7 +178,8 @@ static int expect_zr(int expr, int llen) #define EXPECT_NZ(cond, expr, val) \ do { if (!(cond)) result(llen, SKIPPED); else ret += expect_nz(expr, llen; } while (0) -static int expect_nz(int expr, int llen) +static __attribute__((unused)) +int expect_nz(int expr, int llen) { int ret = !(expr != 0); @@ -190,7 +192,8 @@ static int expect_nz(int expr, int llen) #define EXPECT_EQ(cond, expr, val) \ do { if (!(cond)) result(llen, SKIPPED); else ret += expect_eq(expr, llen, val); } while (0) -static int expect_eq(uint64_t expr, int llen, uint64_t val) +static __attribute__((unused)) +int expect_eq(uint64_t expr, int llen, uint64_t val) { int ret = !(expr == val); @@ -203,7 +206,8 @@ static int expect_eq(uint64_t expr, int llen, uint64_t val) #define EXPECT_NE(cond, expr, val) \ do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ne(expr, llen, val); } while (0) -static int expect_ne(int expr, int llen, int val) +static __attribute__((unused)) +int expect_ne(int expr, int llen, int val) { int ret = !(expr != val); @@ -216,7 +220,8 @@ static int expect_ne(int expr, int llen, int val) #define EXPECT_GE(cond, expr, val) \ do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ge(expr, llen, val); } while (0) -static int expect_ge(int expr, int llen, int val) +static __attribute__((unused)) +int expect_ge(int expr, int llen, int val) { int ret = !(expr >= val); @@ -229,7 +234,8 @@ static int expect_ge(int expr, int llen, int val) #define EXPECT_GT(cond, expr, val) \ do { if (!(cond)) result(llen, SKIPPED); else ret += expect_gt(expr, llen, val); } while (0) -static int expect_gt(int expr, int llen, int val) +static __attribute__((unused)) +int expect_gt(int expr, int llen, int val) { int ret = !(expr > val); @@ -242,7 +248,8 @@ static int expect_gt(int expr, int llen, int val) #define EXPECT_LE(cond, expr, val) \ do { if (!(cond)) result(llen, SKIPPED); else ret += expect_le(expr, llen, val); } while (0) -static int expect_le(int expr, int llen, int val) +static __attribute__((unused)) +int expect_le(int expr, int llen, int val) { int ret = !(expr <= val); @@ -255,7 +262,8 @@ static int expect_le(int expr, int llen, int val) #define EXPECT_LT(cond, expr, val) \ do { if (!(cond)) result(llen, SKIPPED); else ret += expect_lt(expr, llen, val); } while (0) -static int expect_lt(int expr, int llen, int val) +static __attribute__((unused)) +int expect_lt(int expr, int llen, int val) { int ret = !(expr < val); @@ -268,7 +276,8 @@ static int expect_lt(int expr, int llen, int val) #define EXPECT_SYSZR(cond, expr) \ do { if (!(cond)) result(llen, SKIPPED); else ret += expect_syszr(expr, llen); } while (0) -static int expect_syszr(int expr, int llen) +static __attribute__((unused)) +int expect_syszr(int expr, int llen) { int ret = 0; @@ -287,7 +296,8 @@ static int expect_syszr(int expr, int llen) #define EXPECT_SYSEQ(cond, expr, val) \ do { if (!(cond)) result(llen, SKIPPED); else ret += expect_syseq(expr, llen, val); } while (0) -static int expect_syseq(int expr, int llen, int val) +static __attribute__((unused)) +int expect_syseq(int expr, int llen, int val) { int ret = 0; @@ -306,7 +316,8 @@ static int expect_syseq(int expr, int llen, int val) #define EXPECT_SYSNE(cond, expr, val) \ do { if (!(cond)) result(llen, SKIPPED); else ret += expect_sysne(expr, llen, val); } while (0) -static int expect_sysne(int expr, int llen, int val) +static __attribute__((unused)) +int expect_sysne(int expr, int llen, int val) { int ret = 0; @@ -328,7 +339,8 @@ static int expect_sysne(int expr, int llen, int val) #define EXPECT_SYSER(cond, expr, expret, experr) \ EXPECT_SYSER2(cond, expr, expret, experr, 0) -static int expect_syserr2(int expr, int expret, int experr1, int experr2, int llen) +static __attribute__((unused)) +int expect_syserr2(int expr, int expret, int experr1, int experr2, int llen) { int ret = 0; int _errno = errno; @@ -351,7 +363,8 @@ static int expect_syserr2(int expr, int expret, int experr1, int experr2, int ll #define EXPECT_PTRZR(cond, expr) \ do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrzr(expr, llen); } while (0) -static int expect_ptrzr(const void *expr, int llen) +static __attribute__((unused)) +int expect_ptrzr(const void *expr, int llen) { int ret = 0; @@ -369,7 +382,8 @@ static int expect_ptrzr(const void *expr, int llen) #define EXPECT_PTRNZ(cond, expr) \ do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrnz(expr, llen); } while (0) -static int expect_ptrnz(const void *expr, int llen) +static __attribute__((unused)) +int expect_ptrnz(const void *expr, int llen) { int ret = 0; @@ -386,7 +400,8 @@ static int expect_ptrnz(const void *expr, int llen) #define EXPECT_PTREQ(cond, expr, cmp) \ do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptreq(expr, llen, cmp); } while (0) -static int expect_ptreq(const void *expr, int llen, const void *cmp) +static __attribute__((unused)) +int expect_ptreq(const void *expr, int llen, const void *cmp) { int ret = 0; @@ -403,7 +418,8 @@ static int expect_ptreq(const void *expr, int llen, const void *cmp) #define EXPECT_PTRNE(cond, expr, cmp) \ do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrne(expr, llen, cmp); } while (0) -static int expect_ptrne(const void *expr, int llen, const void *cmp) +static __attribute__((unused)) +int expect_ptrne(const void *expr, int llen, const void *cmp) { int ret = 0; @@ -420,7 +436,8 @@ static int expect_ptrne(const void *expr, int llen, const void *cmp) #define EXPECT_PTRGE(cond, expr, cmp) \ do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrge(expr, llen, cmp); } while (0) -static int expect_ptrge(const void *expr, int llen, const void *cmp) +static __attribute__((unused)) +int expect_ptrge(const void *expr, int llen, const void *cmp) { int ret = !(expr >= cmp); @@ -432,7 +449,8 @@ static int expect_ptrge(const void *expr, int llen, const void *cmp) #define EXPECT_PTRGT(cond, expr, cmp) \ do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrgt(expr, llen, cmp); } while (0) -static int expect_ptrgt(const void *expr, int llen, const void *cmp) +static __attribute__((unused)) +int expect_ptrgt(const void *expr, int llen, const void *cmp) { int ret = !(expr > cmp); @@ -445,7 +463,8 @@ static int expect_ptrgt(const void *expr, int llen, const void *cmp) #define EXPECT_PTRLE(cond, expr, cmp) \ do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrle(expr, llen, cmp); } while (0) -static int expect_ptrle(const void *expr, int llen, const void *cmp) +static __attribute__((unused)) +int expect_ptrle(const void *expr, int llen, const void *cmp) { int ret = !(expr <= cmp); @@ -458,7 +477,8 @@ static int expect_ptrle(const void *expr, int llen, const void *cmp) #define EXPECT_PTRLT(cond, expr, cmp) \ do { if (!(cond)) result(llen, SKIPPED); else ret += expect_ptrlt(expr, llen, cmp); } while (0) -static int expect_ptrlt(const void *expr, int llen, const void *cmp) +static __attribute__((unused)) +int expect_ptrlt(const void *expr, int llen, const void *cmp) { int ret = !(expr < cmp); @@ -473,7 +493,8 @@ static int expect_ptrlt(const void *expr, int llen, const void *cmp) #define EXPECT_PTRER(cond, expr, expret, experr) \ EXPECT_PTRER2(cond, expr, expret, experr, 0) -static int expect_ptrerr2(const void *expr, const void *expret, int experr1, int experr2, int llen) +static __attribute__((unused)) +int expect_ptrerr2(const void *expr, const void *expret, int experr1, int experr2, int llen) { int ret = 0; int _errno = errno; @@ -495,7 +516,8 @@ static int expect_ptrerr2(const void *expr, const void *expret, int experr1, int #define EXPECT_STRZR(cond, expr) \ do { if (!(cond)) result(llen, SKIPPED); else ret += expect_strzr(expr, llen); } while (0) -static int expect_strzr(const char *expr, int llen) +static __attribute__((unused)) +int expect_strzr(const char *expr, int llen) { int ret = 0; @@ -513,7 +535,8 @@ static int expect_strzr(const char *expr, int llen) #define EXPECT_STRNZ(cond, expr) \ do { if (!(cond)) result(llen, SKIPPED); else ret += expect_strnz(expr, llen); } while (0) -static int expect_strnz(const char *expr, int llen) +static __attribute__((unused)) +int expect_strnz(const char *expr, int llen) { int ret = 0; @@ -531,7 +554,8 @@ static int expect_strnz(const char *expr, int llen) #define EXPECT_STREQ(cond, expr, cmp) \ do { if (!(cond)) result(llen, SKIPPED); else ret += expect_streq(expr, llen, cmp); } while (0) -static int expect_streq(const char *expr, int llen, const char *cmp) +static __attribute__((unused)) +int expect_streq(const char *expr, int llen, const char *cmp) { int ret = 0; @@ -549,7 +573,8 @@ static int expect_streq(const char *expr, int llen, const char *cmp) #define EXPECT_STRNE(cond, expr, cmp) \ do { if (!(cond)) result(llen, SKIPPED); else ret += expect_strne(expr, llen, cmp); } while (0) -static int expect_strne(const char *expr, int llen, const char *cmp) +static __attribute__((unused)) +int expect_strne(const char *expr, int llen, const char *cmp) { int ret = 0; From patchwork Tue Aug 1 05:30:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13335778 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0B2DDC0015E for ; Tue, 1 Aug 2023 05:30:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230238AbjHAFa1 (ORCPT ); Tue, 1 Aug 2023 01:30:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230179AbjHAFaX (ORCPT ); Tue, 1 Aug 2023 01:30:23 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82B7F1FC6; 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=IgjLrXapLUyrHe3QIhxAoxZT1uWllcSWJz1V8L+G1yU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Yq19FH/D4gFvCvGG+FLJ4e8m7mSmbZMJ8oKL0JPgpzl8mMmJTMYt4GMH5LzJ08fRu gvWH+zBimOttLfS/OICkpHz/kWyYfnr4CfvSyOjodkKhDIX2GD9xvdUbv31e2QoTIm WY/QDcQ2bkSoeaJ59lnWGPRYMTKXKGIjTka6iyn0= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 01 Aug 2023 07:30:13 +0200 Subject: [PATCH v2 06/10] selftests/nolibc: make functions static if possible MIME-Version: 1.0 Message-Id: <20230801-nolibc-warnings-v2-6-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 , Shuah Khan Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Yuan Tan , Zhangjin Wu , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1690867811; l=2423; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=IgjLrXapLUyrHe3QIhxAoxZT1uWllcSWJz1V8L+G1yU=; b=w25nddOU5uOwRkjgP9UtA/ejR4rshXc6sRpWgDkm3xvpc8I6XGN03VoEMhM41hQIZbGjb+4tK rAFxCxanxBhDQC7u9ejvxT0uvqDNylbialOlKhWUnS1xzy2WsNCLmsW X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org This allows the compiler to generate warnings if they go unused. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/nolibc-test.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 1555759bb164..53a3773c7790 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -80,7 +80,7 @@ char *itoa(int i) /* returns the error name (e.g. "ENOENT") for common errors, "SUCCESS" for 0, * or the decimal value for less common ones. */ -const char *errorname(int err) +static const char *errorname(int err) { switch (err) { case 0: return "SUCCESS"; @@ -593,7 +593,7 @@ int expect_strne(const char *expr, int llen, const char *cmp) #define CASE_TEST(name) \ case __LINE__: llen += printf("%d %s", test, #name); -int run_startup(int min, int max) +static int run_startup(int min, int max) { int test; int ret = 0; @@ -640,7 +640,7 @@ int run_startup(int min, int max) /* used by some syscall tests below */ -int test_getdents64(const char *dir) +static int test_getdents64(const char *dir) { char buffer[4096]; int fd, ret; @@ -734,7 +734,7 @@ static int test_stat_timestamps(void) return 0; } -int test_mmap_munmap(void) +static int test_mmap_munmap(void) { int ret, fd, i; void *mem; @@ -796,7 +796,7 @@ int test_mmap_munmap(void) /* Run syscall tests between IDs and . * Return 0 on success, non-zero on failure. */ -int run_syscall(int min, int max) +static int run_syscall(int min, int max) { struct timeval tv; struct timezone tz; @@ -907,7 +907,7 @@ int run_syscall(int min, int max) return ret; } -int run_stdlib(int min, int max) +static int run_stdlib(int min, int max) { int test; int ret = 0; @@ -1141,7 +1141,7 @@ static int run_protection(int min, int max) } /* prepare what needs to be prepared for pid 1 (stdio, /dev, /proc, etc) */ -int prepare(void) +static int prepare(void) { struct stat stat_buf; @@ -1208,7 +1208,7 @@ static const struct test test_names[] = { { 0 } }; -int is_setting_valid(char *test) +static int is_setting_valid(char *test) { int idx, len, test_len, valid = 0; char delimiter; From patchwork Tue Aug 1 05:30:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13335779 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6061AEB64DD for ; Tue, 1 Aug 2023 05:30:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230219AbjHAFa0 (ORCPT ); Tue, 1 Aug 2023 01:30:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230181AbjHAFaX (ORCPT ); Tue, 1 Aug 2023 01:30:23 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 820CD1FC0; 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=68cbroggSXK5AuaobFuJ+Z2zDm6urN4gJ+66FGT1Uuk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=OJi9b8qPlP1oIS+wo7uoBxGWfGJcbh5IH4vppHDXWwPpKJsZw7NyxC6xLZU+Xk0oH tIov+5UfdtYKbAxEZddRhL47R234mYUatJQN4OHVQdeZytCx5GsSXKFSduVJzXGnSE 6/SsgtJF0xwSu7wGnx5L4il/XP7F6N6IF/Uv5XeM= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 01 Aug 2023 07:30:14 +0200 Subject: [PATCH v2 07/10] selftests/nolibc: avoid unused arguments warnings MIME-Version: 1.0 Message-Id: <20230801-nolibc-warnings-v2-7-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 , Shuah Khan Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Yuan Tan , Zhangjin Wu , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1690867811; l=759; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=68cbroggSXK5AuaobFuJ+Z2zDm6urN4gJ+66FGT1Uuk=; b=f5FFo8CzKRA1WOhf9Y0SVYApgArlbh3IMK9g/aVCZ2I4Rv1TeOJ6Pd9a0RsBt5Ad1uInWMaDR 8Bqy2lWFtwIBMYMbPj7r7MHO6dN+SCk4XG7J1tu4l/zoBeJY4ZuykSv X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org This warnings will be enabled later so avoid triggering it. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/nolibc-test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 53a3773c7790..cb17cccd0bc7 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -1089,7 +1089,8 @@ static int smash_stack(void) return 1; } -static int run_protection(int min, int max) +static int run_protection(int __attribute__((unused)) min, + int __attribute__((unused)) max) { pid_t pid; int llen = 0, status; From patchwork Tue Aug 1 05:30:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13335780 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F806C04E69 for ; Tue, 1 Aug 2023 05:30:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230254AbjHAFa2 (ORCPT ); Tue, 1 Aug 2023 01:30:28 -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 ); 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?= Date: Tue, 01 Aug 2023 07:30:15 +0200 Subject: [PATCH v2 08/10] selftests/nolibc: avoid sign-compare warnings MIME-Version: 1.0 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 , Shuah Khan Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Yuan Tan , Zhangjin Wu , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= 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= Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org These warnings will be enabled later so avoid triggering them. Signed-off-by: Thomas Weißschuh --- 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; /* 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]; From patchwork Tue Aug 1 05:30:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13335781 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49751C00528 for ; Tue, 1 Aug 2023 05:30:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230266AbjHAFa3 (ORCPT ); Tue, 1 Aug 2023 01:30:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230188AbjHAFaZ (ORCPT ); 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 0F0C31FC3; Mon, 31 Jul 2023 22:30:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1690867813; bh=+UidgUyTA/KFUXNdvZyyZmaUyZXJ9vuTjGYxg60wA00=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=AVLr7ez6Xso9rIiCq4XROnDn87bAXg6Gu+TqqS5fJxVWzM+cEMh6v8CKhONkYrbVa kUH+qIh/OljtRxtQwTBEKzvhDh381ngp1ZSsnptM/xin7BOHEiFmb2Q3pCi3CP+fS5 IVFICVId0E4ByCfMXC5uw5KQrwlA9d2ce4IUT18g= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 01 Aug 2023 07:30:16 +0200 Subject: [PATCH v2 09/10] selftests/nolibc: test return value of read() in test_vfprintf MIME-Version: 1.0 Message-Id: <20230801-nolibc-warnings-v2-9-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 , Shuah Khan Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Yuan Tan , Zhangjin Wu , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1690867811; l=826; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=+UidgUyTA/KFUXNdvZyyZmaUyZXJ9vuTjGYxg60wA00=; b=1TjhwvvgPvP269jHQXdAQsLEjEYjifMWLDyOHpOqaW6hu+NWX+/3UwMD5u0Shu4CJ5pFD1VCA t/aAkmg/LRNBR4+1k4EukM6GFycmMc4SFbETt0POLETAe6YgDzd9VqM X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org If read() fails and returns -1 buf would be accessed out of bounds. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/nolibc-test.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index 82714051c72f..a334f8450a34 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -1031,6 +1031,12 @@ static int expect_vfprintf(int llen, int c, const char *expected, const char *fm lseek(fd, 0, SEEK_SET); r = read(fd, buf, sizeof(buf) - 1); + if (r == -1) { + llen += printf(" read() = %s", errorname(errno)); + result(llen, FAIL); + return 1; + } + buf[r] = '\0'; fclose(memfile); From patchwork Tue Aug 1 05:30:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13335782 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95697C0015E for ; Tue, 1 Aug 2023 05:30:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230273AbjHAFab (ORCPT ); Tue, 1 Aug 2023 01:30:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230230AbjHAFa1 (ORCPT ); Tue, 1 Aug 2023 01:30:27 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F04E1BF1; Mon, 31 Jul 2023 22:30:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1690867813; bh=lFg1vkQ35QpMNiPZG92VmH5E2lHoFnctsQX4/bx0f88=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=IAd1+tBymHSE0y4XvTvxwpfywlvdj+FzyaFGcsuVczFg2Vzc9Aheiyk7EKa3Vxboq aCnJEhdrhgM3oHyAFwFCwhP8NiuPdrocJFiBYsUM4Iegc3wA4xIOARigTiYe5+1zvW nBzSsgMtZ8O0Do71ec3KDC3LJijkfZyXNAVmcDYk= From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= Date: Tue, 01 Aug 2023 07:30:17 +0200 Subject: [PATCH v2 10/10] selftests/nolibc: enable compiler warnings MIME-Version: 1.0 Message-Id: <20230801-nolibc-warnings-v2-10-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 , Shuah Khan Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Yuan Tan , Zhangjin Wu , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1690867811; l=924; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=lFg1vkQ35QpMNiPZG92VmH5E2lHoFnctsQX4/bx0f88=; b=42I9jdwYI9NMCidgc4CYrdDi1RHSUkiVh+XQnznHQaz3fzAAJqconUyQunqWm3YqCWTbE0xai M1VuwuHZ1zpD5mBQR+eHGv8pdmJnvKK6lJDRONGmN4hm9Fcd7Ap/h35 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org It will help the developers to avoid cruft and detect some bugs. Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/nolibc/Makefile b/tools/testing/selftests/nolibc/Makefile index f42adef87e12..d6c24c37120c 100644 --- a/tools/testing/selftests/nolibc/Makefile +++ b/tools/testing/selftests/nolibc/Makefile @@ -79,7 +79,7 @@ endif CFLAGS_s390 = -m64 CFLAGS_mips = -EL CFLAGS_STACKPROTECTOR ?= $(call cc-option,-mstack-protector-guard=global $(call cc-option,-fstack-protector-all)) -CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 \ +CFLAGS ?= -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 -W -Wall -Wextra \ $(call cc-option,-fno-stack-protector) \ $(CFLAGS_$(ARCH)) $(CFLAGS_STACKPROTECTOR) LDFLAGS := -s