Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp527417rdg; Thu, 12 Oct 2023 12:33:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEnCLS+4BU9xyEU4Ig15Uf0H1TfCTxn6faR9ThZ1srRJiJgvcATKtuPBCvZWAS1R6BFXez2 X-Received: by 2002:a92:c54a:0:b0:357:4d46:e1a1 with SMTP id a10-20020a92c54a000000b003574d46e1a1mr6062228ilj.9.1697139227934; Thu, 12 Oct 2023 12:33:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697139227; cv=none; d=google.com; s=arc-20160816; b=ZNBmRZTAkRD6l7HpD308qrhlAuM780C6hjpYCI1nKAsOkO2Ej13vJUbU1RuEtEZHHh lj/HHHPUri5CQOLab2AvhajC1tYYoxD6x9TqC3UoY0CnTN+UFSXAfGaUWUB/CM2M9vSY LjdbBzHIFH5tGBavafkjfIyGP7OgpUxiR5rharkEwGqxliqVSeH/amvGnICv/RCuTtn2 98dIIq2YpYeNTtjIsiDUMOClZr7Z/1QbTMSVUWLbiKT0OJ7GtPHfryXI6eUf7xXRCgAg 8xBQ5YJTLjOrxpD/EoBuHGQK7MoikY2U0YNxyPe+yOpm/JQUlzwe0aliibV9q6fTxkni zGhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=398iR0TCz03h4tOiy2WH6iQ0rXdNTfuc1SoeFtRlyqE=; fh=THcOZpAstuQgjCQdp+HFLuFrh45sne4+DD/0SDoXq0I=; b=B6Mulr1hp6UIGcZeN3t9f7YjC1AlJBS6WQ8c0Q4GtDfo4+NUrRQQT3Kkfh0At3VsoM GAhqlgB08gNl/UX2vPgYgZ+kWzLuQ2gpfwgHuy5X+iVHA6BT1rQbd8gL5485tLtiR0UL QO9UABcOOdPIFnguTUAkqCz9oiGwZwuScuOMEpHC0d9/07CMamD8KIIsHK2mZu0DSkuz 6qD7L4I0w8P67ogw/VpYOt+QQdBMjRGqiP3Uq80/LiypsOpgLUAFg6BD0+5nfuLs8sXz al/vx4t6QutsG0neCxYqwEa8PiMLIEqqkA8yKTG17ggb4+ySNlNUWEYFIHwpQ+A4ahd6 Pj0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tWRBq9Nq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id n125-20020a634083000000b00578b6e32b60si2864897pga.126.2023.10.12.12.33.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 12:33:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tWRBq9Nq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 165DD83FC3A4; Thu, 12 Oct 2023 12:33:40 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442375AbjJLTdN (ORCPT + 99 others); Thu, 12 Oct 2023 15:33:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442285AbjJLTcl (ORCPT ); Thu, 12 Oct 2023 15:32:41 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91162ED for ; Thu, 12 Oct 2023 12:32:38 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14B0FC43391; Thu, 12 Oct 2023 19:32:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697139156; bh=u/ByFzD4Ej36/aCXkG6Bkh+tE+GTKi/3gaOUP8BZznA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tWRBq9Nq+Thv2/uvAXTFN64r5KeSnfsvdBT6R4eppcwd13qGP3piYHIuw2+706PBV TsdQDwBzk4cxCfop380Qb1ywbK9gnAe3r58V3UZdrHKXh0JJmWDwAkL50oJcUhI7XJ I/PxY4FtDzihWOBBYxVp2wocg8Xcd/Oc4u4bLc94XUFmTw124E2xHI/qMq7zEa25nB t967tALqxD2Z2qpy27HjSzcJlhqbucfxqvwz64ZhEi9Ke7d5K3ZpnASIPvPujBcko9 IHhPbGAtyiSwNiBjxRehoGXFK+6sCDq8fWayhRla6TsWofhIaQtdC6fxrCedhWgThB ZmOjslede4QSg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 544B0CE0C3E; Thu, 12 Oct 2023 12:32:35 -0700 (PDT) From: "Paul E. McKenney" To: linux-kernel@vger.kernel.org Cc: gwml@vger.gnuweeb.org, kernel-team@meta.com, w@lwt.eu, =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= Subject: [PATCH nolibc 10/19] selftests/nolibc: libc-test: avoid -Wstringop-overflow warnings Date: Thu, 12 Oct 2023 12:32:24 -0700 Message-Id: <20231012193233.207857-10-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 12 Oct 2023 12:33:40 -0700 (PDT) From: Thomas Weißschuh Newer versions of glibc annotate the poll() function with __attribute__(access) which triggers a compiler warning inside the testcase poll_fault. Avoid this by using a plain NULL which is enough for the testcase. To avoid potential future warnings also adapt the other EFAULT testcases, except select_fault as NULL is a valid value for its argument. nolibc-test.c: In function ‘run_syscall’: nolibc-test.c:338:62: warning: ‘poll’ writing 8 bytes into a region of size 0 overflows the destination [-Wstringop-overflow=] 338 | do { if (!(cond)) result(llen, SKIPPED); else ret += expect_syserr2(expr, expret, experr1, experr2, llen); } while (0) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ nolibc-test.c:341:9: note: in expansion of macro ‘EXPECT_SYSER2’ 341 | EXPECT_SYSER2(cond, expr, expret, experr, 0) | ^~~~~~~~~~~~~ nolibc-test.c:905:47: note: in expansion of macro ‘EXPECT_SYSER’ 905 | CASE_TEST(poll_fault); EXPECT_SYSER(1, poll((void *)1, 1, 0), -1, EFAULT); break; | ^~~~~~~~~~~~ cc1: note: destination object is likely at address zero In file included from /usr/include/poll.h:1, from nolibc-test.c:33: /usr/include/sys/poll.h:54:12: note: in a call to function ‘poll’ declared with attribute ‘access (write_only, 1, 2)’ 54 | extern int poll (struct pollfd *__fds, nfds_t __nfds, int __timeout) | ^~~~ Signed-off-by: Thomas Weißschuh --- tools/testing/selftests/nolibc/nolibc-test.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c index fb3bf91462e2..a3ee4496bf0a 100644 --- a/tools/testing/selftests/nolibc/nolibc-test.c +++ b/tools/testing/selftests/nolibc/nolibc-test.c @@ -894,14 +894,14 @@ int run_syscall(int min, int max) CASE_TEST(lseek_0); EXPECT_SYSER(1, lseek(0, 0, SEEK_SET), -1, ESPIPE); break; CASE_TEST(mkdir_root); EXPECT_SYSER(1, mkdir("/", 0755), -1, EEXIST); break; CASE_TEST(mmap_bad); EXPECT_PTRER(1, mmap(NULL, 0, PROT_READ, MAP_PRIVATE, 0, 0), MAP_FAILED, EINVAL); break; - CASE_TEST(munmap_bad); EXPECT_SYSER(1, munmap((void *)1, 0), -1, EINVAL); break; + CASE_TEST(munmap_bad); EXPECT_SYSER(1, munmap(NULL, 0), -1, EINVAL); break; CASE_TEST(mmap_munmap_good); EXPECT_SYSZR(1, test_mmap_munmap()); break; CASE_TEST(open_tty); EXPECT_SYSNE(1, tmp = open("/dev/null", 0), -1); if (tmp != -1) close(tmp); break; CASE_TEST(open_blah); EXPECT_SYSER(1, tmp = open("/proc/self/blah", 0), -1, ENOENT); if (tmp != -1) close(tmp); break; CASE_TEST(pipe); EXPECT_SYSZR(1, test_pipe()); break; CASE_TEST(poll_null); EXPECT_SYSZR(1, poll(NULL, 0, 0)); break; CASE_TEST(poll_stdout); EXPECT_SYSNE(1, ({ struct pollfd fds = { 1, POLLOUT, 0}; poll(&fds, 1, 0); }), -1); break; - CASE_TEST(poll_fault); EXPECT_SYSER(1, poll((void *)1, 1, 0), -1, EFAULT); break; + CASE_TEST(poll_fault); EXPECT_SYSER(1, poll(NULL, 1, 0), -1, EFAULT); break; CASE_TEST(prctl); EXPECT_SYSER(1, prctl(PR_SET_NAME, (unsigned long)NULL, 0, 0, 0), -1, EFAULT); break; CASE_TEST(read_badf); EXPECT_SYSER(1, read(-1, &tmp, 1), -1, EBADF); break; CASE_TEST(rmdir_blah); EXPECT_SYSER(1, rmdir("/blah"), -1, ENOENT); break; @@ -910,7 +910,7 @@ int run_syscall(int min, int max) CASE_TEST(select_stdout); EXPECT_SYSNE(1, ({ fd_set fds; FD_ZERO(&fds); FD_SET(1, &fds); select(2, NULL, &fds, NULL, NULL); }), -1); break; CASE_TEST(select_fault); EXPECT_SYSER(1, select(1, (void *)1, NULL, NULL, 0), -1, EFAULT); break; CASE_TEST(stat_blah); EXPECT_SYSER(1, stat("/proc/self/blah", &stat_buf), -1, ENOENT); break; - CASE_TEST(stat_fault); EXPECT_SYSER(1, stat((void *)1, &stat_buf), -1, EFAULT); break; + CASE_TEST(stat_fault); EXPECT_SYSER(1, stat(NULL, &stat_buf), -1, EFAULT); break; CASE_TEST(stat_timestamps); EXPECT_SYSZR(1, test_stat_timestamps()); break; CASE_TEST(symlink_root); EXPECT_SYSER(1, symlink("/", "/"), -1, EEXIST); break; CASE_TEST(unlink_root); EXPECT_SYSER(1, unlink("/"), -1, EISDIR); break; -- 2.40.1