From nobody Wed May 15 10:08:57 2024 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 4VfTTQ0jcfz5KcLN; Wed, 15 May 2024 10:08:58 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VfTTQ0D7Yz4jjt; Wed, 15 May 2024 10:08:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1715767738; 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=V96TYmQyLEvuwT5t734prn4chO7hhWG84fBuYTN9vDc=; b=S0UI/LM0c3RtsBQhQsB9x+SV/ucGiVCsXitH44eDFahKDcV8lUZN/lziZRFj7YesW1Yc06 QENXG7LPmlYp3OLE4/SwQaFwUMwD9jYK5IgDg70OsONMpv24I1J+p591/YzFwZdUIB09xG cM7BUebQrHzqHwep9A0VW3eqSdsPPYWlEHLkzrJHv7sV7tynkUDgQdPYC09btnZL2fwrO4 cihGkiEqxjcyZZuilkMhYnOb+kvTbG8yKsF8RVATUrl3Y76zrKk1Q/1MTxAw0kLK0esLas G/QXJDY7eb5jC4KOrazB5lcXVBu6ZVneFfJa++7nJZjhR+a8za7NtpZr0lLMMw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1715767738; a=rsa-sha256; cv=none; b=S/UJWTEaOMztHPNbw2B0LiyNiUcJnGLtM6CC4NnCO+ixMYqsD+CAjlHAo1y0dvWTnjOJdO OcbpM4nastgsjZhBm/8lmO2fKQAJWEITrN/UqaXxISdQnhh9aqFBXCD+8zwZC8SIeZ3Oaj 4puv0f/6ksKOuQjBdVT8h62DNN+AWnu0XTwygkm1BZaOA2uaF9k+kkdmfzTiMnq/Jf7xSp MzfzWZy/GuKnXzkeJ7NX44GADSIg7/zjgVDhaMx9DygjpidlWJtCPeWhnN/YToybf7bD+w iHJscPFdR2LFf/AC3Aw8rlxO22KiBLWQUocQjSu3Sl0huqt58Tp9oU2fvdZssQ== 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=1715767738; 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=V96TYmQyLEvuwT5t734prn4chO7hhWG84fBuYTN9vDc=; b=H8YlbdC9pz9I90NvmuQIedvJmW3iMMzakCepnqrojvBPanyFkMljLD/lR7F9ZCtp3IrNVq B2+sfPmax8CbS3NeFuKR4KLl/ZNMowOzKuI1aY/JWLzzGctXRLynKKWriBQ5MUwcbTAwS6 eB4dxgHRNQn5fBPaHp5cemr7isskUqMxvZsmS8T5KkkTPqgnhfsZH+ngGYa2rRGSVIz816 MAc2HchQgY8Eu/XrpAeTsI9QioypK8HgU8IEDJ/VVQ8X/N2gBcUWXmuHEKXlcmRbI/JZPK m5TTeIoDj1UeDcsE2Kyy8rEKh1BqOuoFd43//O1MMK8laAcLWr7BhG1EyeZbBA== 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 4VfTTP6wx9z19sD; Wed, 15 May 2024 10:08:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 44FA8v3L061952; Wed, 15 May 2024 10:08:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44FA8vCS061949; Wed, 15 May 2024 10:08:57 GMT (envelope-from git) Date: Wed, 15 May 2024 10:08:57 GMT Message-Id: <202405151008.44FA8vCS061949@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: a7beca6fb113 - main - atf: Guard against multiple evaluation. 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: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a7beca6fb113986839de73b7cf73d933464898c6 Auto-Submitted: auto-generated The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=a7beca6fb113986839de73b7cf73d933464898c6 commit a7beca6fb113986839de73b7cf73d933464898c6 Author: Dag-Erling Smørgrav AuthorDate: 2024-05-15 10:08:44 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-05-15 10:08:44 +0000 atf: Guard against multiple evaluation. Note that the ATF-C++ macros have the same issue, but they are not as easily fixed. MFC after: 3 days Reviewed by: ngie Differential Revision: https://reviews.freebsd.org/D45148 --- contrib/atf/atf-c/macros.h | 151 ++++++++++++++++++++++++++++----------------- 1 file changed, 95 insertions(+), 56 deletions(-) diff --git a/contrib/atf/atf-c/macros.h b/contrib/atf/atf-c/macros.h index 1784fc47435d..abcb9f697907 100644 --- a/contrib/atf/atf-c/macros.h +++ b/contrib/atf/atf-c/macros.h @@ -167,65 +167,104 @@ ATF_CHECK_MSG((expected) == (actual), "%s != %s: " fmt, \ #expected, #actual, ##__VA_ARGS__) -#define ATF_REQUIRE_STREQ(expected, actual) \ - ATF_REQUIRE_MSG(strcmp(expected, actual) == 0, "%s != %s (%s != %s)", \ - #expected, #actual, expected, actual) - -#define ATF_CHECK_STREQ(expected, actual) \ - ATF_CHECK_MSG(strcmp(expected, actual) == 0, "%s != %s (%s != %s)", \ - #expected, #actual, expected, actual) - -#define ATF_REQUIRE_STREQ_MSG(expected, actual, fmt, ...) \ - ATF_REQUIRE_MSG(strcmp(expected, actual) == 0, \ - "%s != %s (%s != %s): " fmt, \ - #expected, #actual, expected, actual, ##__VA_ARGS__) - -#define ATF_CHECK_STREQ_MSG(expected, actual, fmt, ...) \ - ATF_CHECK_MSG(strcmp(expected, actual) == 0, \ - "%s != %s (%s != %s): " fmt, \ - #expected, #actual, expected, actual, ##__VA_ARGS__) - -#define ATF_REQUIRE_INTEQ(expected, actual) \ - ATF_REQUIRE_MSG((expected) == (actual), "%s != %s (%jd != %jd)", \ - #expected, #actual, (intmax_t)(expected), \ - (intmax_t)(actual)) - -#define ATF_CHECK_INTEQ(expected, actual) \ - ATF_CHECK_MSG((expected) == (actual), "%s != %s (%jd != %jd)", #expected, \ - #actual, (intmax_t)(expected), (intmax_t)(actual)) - -#define ATF_REQUIRE_INTEQ_MSG(expected, actual, fmt, ...) \ - ATF_REQUIRE_MSG((expected) == (actual), "%s != %s (%jd != %jd): " fmt, \ - #expected, #actual, (intmax_t)(expected), \ - (intmax_t)(actual), ##__VA_ARGS__) - -#define ATF_CHECK_INTEQ_MSG(expected, actual, fmt, ...) \ - ATF_CHECK_MSG((expected) == (actual), "%s != %s (%jd != %jd): " fmt, \ - #expected, #actual, (intmax_t)(expected), \ - (intmax_t)(actual), ##__VA_ARGS__) - -#define ATF_REQUIRE_MATCH(regexp, string) \ - ATF_REQUIRE_MSG(atf_utils_grep_string("%s", string, regexp), \ - "'%s' not matched in '%s'", regexp, string); - -#define ATF_CHECK_MATCH(regexp, string) \ - ATF_CHECK_MSG(atf_utils_grep_string("%s", string, regexp), \ - "'%s' not matched in '%s'", regexp, string); - -#define ATF_REQUIRE_MATCH_MSG(regexp, string, fmt, ...) \ - ATF_REQUIRE_MSG(atf_utils_grep_string("%s", string, regexp), \ - "'%s' not matched in '%s': " fmt, regexp, string, \ - ##__VA_ARGS__); - -#define ATF_CHECK_MATCH_MSG(regexp, string, fmt, ...) \ - ATF_CHECK_MSG(atf_utils_grep_string("%s", string, regexp), \ - "'%s' not matched in '%s': " fmt, regexp, string, \ - ##__VA_ARGS__); +#define ATF_REQUIRE_STREQ(expected, actual) do { \ + const char *_atf_expected = (expected); \ + const char *_atf_actual = (actual); \ + ATF_REQUIRE_MSG(strcmp(_atf_expected, _atf_actual) == 0, \ + "%s != %s (%s != %s)", #expected, #actual, \ + _atf_expected, _atf_actual); \ + } while (0) + +#define ATF_CHECK_STREQ(expected, actual) do { \ + const char *_atf_expected = (expected); \ + const char *_atf_actual = (actual); \ + ATF_CHECK_MSG(strcmp(_atf_expected, _atf_actual) == 0, \ + "%s != %s (%s != %s)", #expected, #actual, \ + _atf_expected, _atf_actual); \ + } while (0) + +#define ATF_REQUIRE_STREQ_MSG(expected, actual, fmt, ...) do { \ + const char *_atf_expected = (expected); \ + const char *_atf_actual = (actual); \ + ATF_REQUIRE_MSG(strcmp(_atf_expected, _atf_actual) == 0, \ + "%s != %s (%s != %s): " fmt, #expected, #actual, \ + _atf_expected, _atf_actual, ##__VA_ARGS__); \ + } while (0) + +#define ATF_CHECK_STREQ_MSG(expected, actual, fmt, ...) do { \ + const char *_atf_expected = (expected); \ + const char *_atf_actual = (actual); \ + ATF_CHECK_MSG(strcmp(_atf_expected, _atf_actual) == 0, \ + "%s != %s (%s != %s): " fmt, #expected, #actual, \ + _atf_expected, _atf_actual, ##__VA_ARGS__); \ + } while (0) + +#define ATF_REQUIRE_INTEQ(expected, actual) do { \ + intmax_t _atf_expected = (expected); \ + intmax_t _atf_actual = (actual); \ + ATF_REQUIRE_MSG(_atf_expected == _atf_actual, \ + "%s != %s (%jd != %jd)", #expected, #actual, \ + _atf_expected, _atf_actual); \ + } while (0) + +#define ATF_CHECK_INTEQ(expected, actual) do { \ + intmax_t _atf_expected = (expected); \ + intmax_t _atf_actual = (actual); \ + ATF_CHECK_MSG(_atf_expected == _atf_actual, \ + "%s != %s (%jd != %jd)", #expected, #actual, \ + _atf_expected, _atf_actual); \ + } while (0) + +#define ATF_REQUIRE_INTEQ_MSG(expected, actual, fmt, ...) do { \ + intmax_t _atf_expected = (expected); \ + intmax_t _atf_actual = (actual); \ + ATF_REQUIRE_MSG(_atf_expected == _atf_actual, \ + "%s != %s (%jd != %jd): " fmt, #expected, #actual, \ + _atf_expected, _atf_actual, ##__VA_ARGS__); \ + } while (0) + +#define ATF_CHECK_INTEQ_MSG(expected, actual, fmt, ...) do { \ + intmax_t _atf_expected = (expected); \ + intmax_t _atf_actual = (actual); \ + ATF_CHECK_MSG(_atf_expected == _atf_actual, \ + "%s != %s (%jd != %jd): " fmt, #expected, #actual, \ + _atf_expected, _atf_actual, ##__VA_ARGS__); \ + } while (0) + +#define ATF_REQUIRE_MATCH(regexp, string) do { \ + const char *_atf_regexp = (regexp); \ + const char *_atf_string = (string); \ + ATF_REQUIRE_MSG(atf_utils_grep_string("%s", _atf_string, _atf_regexp), \ + "'%s' not matched in '%s'", _atf_regexp, _atf_string); \ + } while (0) + +#define ATF_CHECK_MATCH(regexp, string) do { \ + const char *_atf_regexp = (regexp); \ + const char *_atf_string = (string); \ + ATF_CHECK_MSG(atf_utils_grep_string("%s", _atf_string, _atf_regexp), \ + "'%s' not matched in '%s'", _atf_regexp, _atf_string); \ + } while (0) + +#define ATF_REQUIRE_MATCH_MSG(regexp, string, fmt, ...) do { \ + const char *_atf_regexp = (regexp); \ + const char *_atf_string = (string); \ + ATF_REQUIRE_MSG(atf_utils_grep_string("%s", _atf_string, _atf_regexp), \ + "'%s' not matched in '%s': " fmt, _atf_regexp, _atf_string, \ + ##__VA_ARGS__); \ + } while (0) + +#define ATF_CHECK_MATCH_MSG(regexp, string, fmt, ...) do { \ + const char *_atf_regexp = (regexp); \ + const char *_atf_string = (string); \ + ATF_CHECK_MSG(atf_utils_grep_string("%s", _atf_string, _atf_regexp), \ + "'%s' not matched in '%s': " fmt, _atf_regexp, _atf_string, \ + ##__VA_ARGS__); \ + } while (0) #define ATF_CHECK_ERRNO(exp_errno, bool_expr) \ - atf_tc_check_errno(__FILE__, __LINE__, exp_errno, #bool_expr, bool_expr) + atf_tc_check_errno(__FILE__, __LINE__, (exp_errno), #bool_expr, (bool_expr)) #define ATF_REQUIRE_ERRNO(exp_errno, bool_expr) \ - atf_tc_require_errno(__FILE__, __LINE__, exp_errno, #bool_expr, bool_expr) + atf_tc_require_errno(__FILE__, __LINE__, (exp_errno), #bool_expr, (bool_expr)) #endif /* !defined(ATF_C_MACROS_H) */