From nobody Mon May 20 09:35:07 2024 X-Original-To: dev-commits-src-all@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 4VjXV50VTpz5KZCv; Mon, 20 May 2024 09:35:09 +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 4VjXV40DN0z4t4f; Mon, 20 May 2024 09:35:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716197708; 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=uF3jUX02zaqmUh6j0iPFkKscVhb91CiTDjIb4IdAPqg=; b=T8TgTWRSwgZOWQ9Xnispg683/W5+s7NH0PgsOH71yHXF/qwjeAHthRu75n2tYVdNAdZkty trpaeHmXq9Xx3Qqe7Puw6XV0u4CAKCMY3+arwhIBEHCKGiy7QzPlKR1D6p+zkYyIYD4Oip 5VeeLYFvc5fK408TWT9qNyEB2INkNNH7QTxnQPi9P01hrjEeC1Gz9HvPtYEWoD3t/7YpdV /DUt1PHHV8WDnZwydFQcZHypAuPZWZbBFLMcK/xBN6/SKrPzxOX7Ifl2iDELp4KVPDcuG8 V/fteBJRvQ+AQyFRTBzfmYtyDf6/R6I3nNokRQ8+pSREM3nZ7CLP5IndWueUUQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1716197708; a=rsa-sha256; cv=none; b=Z3NYsR6J6oGX6OZBS1TM9GlfR7DHqC43+0kegakzrf0WwbN7sOvye8wUHCs718toHz2d+g suYuiHGx1bFlBHBnKuuN24GYKNuaYd0eRcoz6KDIfp+woYkUxmAi87ULVCKlbW0ItLui+1 ns54kKzBfHxP+q/XfK2Pv0OyVPqZe2Z4wejpS+R28TRC2kqomhYAm5M48ggWG9ThVeAi6D M07IuuQLvIE1nW4KEPA0AD88hKuWr5FAEFXnKIFUk0z2qBSsOZimHy86G4Ax6wPvWWWV6z 2tzHewbDhk6aCxuEGESbEgun6n9RtoGjW7w5TsM+2Dy2MkZcFTKJmYJ0GhyR1A== 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=1716197708; 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=uF3jUX02zaqmUh6j0iPFkKscVhb91CiTDjIb4IdAPqg=; b=pelSDDTICzU5Nne6h1wY6XxFt6Upsy78sSSiBJWiFXIagXo3zP7q37U7iSL+oX+2ciZyBK +igrJnGPtRe8WMiZ0EJYI/UZJVrJTJWZ0I5u+DLrGBvsEahBY4xdamW14UzVTptTzYR0kX va3aAPuWq/7K4pUTEbbWVig5Pi5qPgyoJQL/G5CA0fDufgpr4xIUz+FcG8/n0WXkn2C258 Tq2et94RPsua3XbBlTfoHdF+O3RmHWee6bL88nqrZ6zeZ/uh6MsPY7UlTyE60YgOczcxJy 9XrIXZiYUlAzasuQOQENtkgEoPX7vrp6r7Gvt1hZye83Qb6y2obQCvu4gtnhQw== 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 4VjXV36v8WzYT3; Mon, 20 May 2024 09:35:07 +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 44K9Z72R039824; Mon, 20 May 2024 09:35:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44K9Z7of039821; Mon, 20 May 2024 09:35:07 GMT (envelope-from git) Date: Mon, 20 May 2024 09:35:07 GMT Message-Id: <202405200935.44K9Z7of039821@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: d16bc4fda821 - stable/13 - atf: Guard against multiple evaluation. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/stable/13 X-Git-Reftype: branch X-Git-Commit: d16bc4fda8215adab6b1c219ec2edd862fd757ac Auto-Submitted: auto-generated The branch stable/13 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=d16bc4fda8215adab6b1c219ec2edd862fd757ac commit d16bc4fda8215adab6b1c219ec2edd862fd757ac Author: Dag-Erling Smørgrav AuthorDate: 2024-05-15 10:08:44 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-05-20 09:04:59 +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 (cherry picked from commit a7beca6fb113986839de73b7cf73d933464898c6) --- 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) */