]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
coccinelle: simplify the SD_JSON_BUILD_PAIR_* transformations
authorFrantisek Sumsal <frantisek@sumsal.cz>
Wed, 4 Mar 2026 18:17:42 +0000 (19:17 +0100)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Thu, 5 Mar 2026 09:27:58 +0000 (10:27 +0100)
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

index f0724ef8241c0e2108914b74ff691b5f82a2ff8d..8c9af38cb2d1345dc5aa486db57cbceb9753b43f 100644 (file)
@@ -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)
+)