summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas.abraitis@gmail.com>2021-11-18 09:55:13 +0100
committerDonatas Abraitis <donatas.abraitis@gmail.com>2021-11-18 10:32:46 +0100
commit8b3c84254d252394800672a2ecf1d017ce20df87 (patch)
tree3decbb9e9e54d071b8603dbe4fd402b9113beecd /tools
parentMerge pull request #10077 from idryzhov/pim-if-addr-add (diff)
downloadfrr-8b3c84254d252394800672a2ecf1d017ce20df87.tar.xz
frr-8b3c84254d252394800672a2ecf1d017ce20df87.zip
tools: Add coccinelle script to replace inet_ntop inside JSON
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/coccinelle/json_object_string_addf.cocci19
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/coccinelle/json_object_string_addf.cocci b/tools/coccinelle/json_object_string_addf.cocci
new file mode 100644
index 000000000..d9f92e564
--- /dev/null
+++ b/tools/coccinelle/json_object_string_addf.cocci
@@ -0,0 +1,19 @@
+@@
+identifier json;
+expression family, buf, value;
+constant key, buflen;
+@@
+
+(
+-json_object_string_add(json, key, inet_ntop(AF_INET, &value, buf, sizeof(buf)));
++json_object_string_addf(json, key, "%pI4", &value);
+|
+-json_object_string_add(json, key, inet_ntop(AF_INET, &value, buf, buflen));
++json_object_string_addf(json, key, "%pI4", &value);
+|
+-json_object_string_add(json, key, inet_ntop(AF_INET6, &value, buf, sizeof(buf)));
++json_object_string_addf(json, key, "%pI6", &value);
+|
+-json_object_string_add(json, key, inet_ntop(AF_INET6, &value, buf, buflen));
++json_object_string_addf(json, key, "%pI6", &value);
+)