From: Frantisek Sumsal Date: Wed, 4 Mar 2026 18:17:42 +0000 (+0100) Subject: coccinelle: simplify the SD_JSON_BUILD_PAIR_* transformations X-Git-Tag: v260-rc3~80^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=77ee36a740be18ded2cbfa165b3666745c76a237;p=thirdparty%2Fsystemd.git 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. --- diff --git a/coccinelle/sd_build_pair.cocci b/coccinelle/sd_build_pair.cocci index f0724ef8241..8c9af38cb2d 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) +)