From 77ee36a740be18ded2cbfa165b3666745c76a237 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Wed, 4 Mar 2026 19:17:42 +0100 Subject: [PATCH] coccinelle: simplify the SD_JSON_BUILD_PAIR_* transformations And also disable them on test-json.c, since there we use the macros intentionally in a "non-optimal" way to actually test them. --- coccinelle/sd_build_pair.cocci | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/coccinelle/sd_build_pair.cocci b/coccinelle/sd_build_pair.cocci index f0724ef824..8c9af38cb2 100644 --- a/coccinelle/sd_build_pair.cocci +++ b/coccinelle/sd_build_pair.cocci @@ -1,26 +1,22 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ @@ +/* Disable this transformation on test-json.c */ +position p : script:python() { p[0].file != "src/test/test-json.c" }; expression key, val; @@ -- SD_JSON_BUILD_PAIR(key, SD_JSON_BUILD_BOOLEAN(val)) +( +- SD_JSON_BUILD_PAIR@p(key, SD_JSON_BUILD_BOOLEAN(val)) + SD_JSON_BUILD_PAIR_BOOLEAN(key, val) -@@ -expression key, val; -@@ -- SD_JSON_BUILD_PAIR(key, SD_JSON_BUILD_INTEGER(val)) +| +- SD_JSON_BUILD_PAIR@p(key, SD_JSON_BUILD_INTEGER(val)) + SD_JSON_BUILD_PAIR_INTEGER(key, val) -@@ -expression key, val; -@@ -- SD_JSON_BUILD_PAIR(key, SD_JSON_BUILD_STRING(val)) +| +- SD_JSON_BUILD_PAIR@p(key, SD_JSON_BUILD_STRING(val)) + SD_JSON_BUILD_PAIR_STRING(key, val) -@@ -expression key, val; -@@ -- SD_JSON_BUILD_PAIR(key, SD_JSON_BUILD_UNSIGNED(val)) +| +- SD_JSON_BUILD_PAIR@p(key, SD_JSON_BUILD_UNSIGNED(val)) + SD_JSON_BUILD_PAIR_UNSIGNED(key, val) -@@ -expression key, val; -@@ -- SD_JSON_BUILD_PAIR(key, SD_JSON_BUILD_VARIANT(val)) +| +- SD_JSON_BUILD_PAIR@p(key, SD_JSON_BUILD_VARIANT(val)) + SD_JSON_BUILD_PAIR_VARIANT(key, val) +)