From nobody Thu Mar 20 04:44:32 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4ZJCfT4tCvz5rGv0; Thu, 20 Mar 2025 04:44:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZJCfT2pQ1z4Dt4; Thu, 20 Mar 2025 04:44:33 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1742445873; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=57gRk0JZ+Q9q0ICm4qIL+Rh7listEuRY0/F4F7FtEJc=; b=i0xDyHNRkctJ8YKOrhDcTdRbeAP0tmUOcdG7fd2RdpkOf3AQ0QlDax5vHN9/pF4kzpsSUS mRQQx7+HjK/KcH75QvSVKndCXjEfuuY9WPaX3v3hCiV2mNaC6VDOMIqpt9ydIrofXrSlL7 O1lJhEkBArU0Ycng3rwe/xN4puqmQBgDD837qGPCzyyvfN/ed5f1Xj55bLCXTHnMM/ijT2 cgn3Qw2buwuhJ6iViCcDREoQ8k8WaeGUySthHEz6YCy8oMYBQ96oOM6GWC0f/gmJiDFZWK W+K1gc+tH0NB9SRSg60pmRDv0sUHJlTCZYlj47+dSPmvWQ98RDyDnEZ3Qi+8bg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1742445873; a=rsa-sha256; cv=none; b=eH5W2ibClJzCr++ZdHEb6ag6cXCGkjgxZnBHSgGNWV+vU2bAXRHStQRKDPbAlct63c3d5F GTuMBjeQPU0nrELUKyay3cOrRTE4guFWaybhu19s+Azs4NOwjJDiE5KLjHMVWj4rS4H+r/ 2Z3qLFnid89ZPIQ33S/oKMNMcUYkhtY5dlDhZ6ZMYMejombFCTA3gsol58S6UVxUAmbrOG PJH2CFRglr/xoysokNVJtehlEvkzOqMoYA0EeKQHsuZ6XNPgs48cP4jCpFyQwaGgFPrLMN aDhblSnmD1NE9slDGG0Q/qpTQaThO4Ng6McpRbtgqALEUE7/NmwCx3qJ8CuI1w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1742445873; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=57gRk0JZ+Q9q0ICm4qIL+Rh7listEuRY0/F4F7FtEJc=; b=UtGHM6PMyLLZBcx+FzSGeE8vrfbnvA1RlaoN09inR+exEWPotaOijQjb97fXin7FgWte2B zJjV2cgj3FBAETRNgXOhVFg3j8GhZ7LB5tU0lxDoFJQ992hKaTMGJn781N/XenmhagRgFe Hhyu+obz/VR1kCUhtKBuicT5ak9OanU7rQK4OHxBVATUYVTUzM3BkNhydXjLL61NH3GKrt 2wYQvqTP2gIbAJVGH8ccXBki23nsx9PUV/mIrm1Y2w44uSrcqDqa+lbp3/ncFVhQJhs/Ul 762mQ94EsUm4ZPgA0oPy5f/l8qpq6HxR0Rem6WRiOPKqEouK0vouG0pJuK6NnQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4ZJCfT0HtCzr3w; Thu, 20 Mar 2025 04:44:33 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 52K4iWO1055464; Thu, 20 Mar 2025 04:44:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 52K4iWFa055461; Thu, 20 Mar 2025 04:44:32 GMT (envelope-from git) Date: Thu, 20 Mar 2025 04:44:32 GMT Message-Id: <202503200444.52K4iWFa055461@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: 85242b59d17d - main - libc: tests: fix luacheck warnings in the fortification test generator List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 85242b59d17dcbfbc82afea9d4232006df074210 Auto-Submitted: auto-generated The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=85242b59d17dcbfbc82afea9d4232006df074210 commit 85242b59d17dcbfbc82afea9d4232006df074210 Author: Kyle Evans AuthorDate: 2025-03-20 04:42:57 +0000 Commit: Kyle Evans CommitDate: 2025-03-20 04:44:25 +0000 libc: tests: fix luacheck warnings in the fortification test generator All of these are simple shadowing that don't need to happen; we're passing the shadowed value through in every case anyways, just use it in the closure in a more lua-natural fashion. While we're here, lint the generator every time we generate tests to ensure that we don't regress without having to remember to manually run luacheck. Reported by: jlduran Reviewed by: jlduran, markj Differential Revision: https://reviews.freebsd.org/D49235 --- lib/libc/tests/secure/Makefile | 10 +++++++++- lib/libc/tests/secure/generate-fortify-tests.lua | 12 ++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/libc/tests/secure/Makefile b/lib/libc/tests/secure/Makefile index ccf89afb1ad5..beaa01457cfe 100644 --- a/lib/libc/tests/secure/Makefile +++ b/lib/libc/tests/secure/Makefile @@ -18,10 +18,18 @@ FORTIFY_TCATS+= unistd FORTIFY_TCATS+= wchar # Manually run after updating the test generator. -generate-tests: .PHONY +lint-generator: .PHONY + @if ! which luacheck>/dev/null; then \ + 1>&2 echo "devel/lua-luacheck is required to regenerate and lint these tests"; \ + exit 1; \ + fi + luacheck ${.CURDIR}/generate-fortify-tests.lua + +generate-tests: .PHONY lint-generator .for tcat in ${FORTIFY_TCATS} ATF_TESTS_C+= fortify_${tcat}_test +.ORDER: lint-generator generate-tests-${tcat} generate-tests: generate-tests-${tcat} generate-tests-${tcat}: .PHONY ${.CURDIR}/generate-fortify-tests.lua ${tcat} > ${.CURDIR}/fortify_${tcat}_test.c diff --git a/lib/libc/tests/secure/generate-fortify-tests.lua b/lib/libc/tests/secure/generate-fortify-tests.lua index 0e46b8867862..ef9e0299dd48 100755 --- a/lib/libc/tests/secure/generate-fortify-tests.lua +++ b/lib/libc/tests/secure/generate-fortify-tests.lua @@ -1113,7 +1113,7 @@ local function configurable(def, idx) end local function generate_stackframe(buftype, bufsize, disposition, heap, def) - local function len_offset(inverted, disposition) + local function len_offset(inverted) -- Tests that don't use __len in their arguments may use an -- inverted sense because we can't just specify a length that -- would induce an access just after the end. Instead, we have @@ -1128,7 +1128,7 @@ local function generate_stackframe(buftype, bufsize, disposition, heap, def) end end - local function test_uses_len(def) + local function test_uses_len() if def.uses_len then return true end @@ -1151,8 +1151,8 @@ local function generate_stackframe(buftype, bufsize, disposition, heap, def) local vars = "\tstruct {\n" vars = vars .. "\t\tuint8_t padding_l;\n" - local uses_len = test_uses_len(def) - local bufsize_offset = len_offset(not uses_len, disposition) + local uses_len = test_uses_len() + local bufsize_offset = len_offset(not uses_len) local buftype_elem = array_type(buftype) local size_expr = bufsize @@ -1230,7 +1230,7 @@ local function write_test(fh, func, disposition, heap, def) return end - local function need_addr(buftype) + local function need_addr() return not (buftype:match("%[%]") or buftype:match("%*")) end @@ -1292,7 +1292,7 @@ local function write_test(fh, func, disposition, heap, def) end if arg == "__buf" then - if not heap and need_addr(buftype) then + if not heap and need_addr() then body = body .. "&" end