From: Donatas Abraitis Date: Thu, 18 Nov 2021 08:55:13 +0000 (+0200) Subject: tools: Add coccinelle script to replace inet_ntop inside JSON X-Git-Tag: base_8.2~189^2~8 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=8b3c84254d252394800672a2ecf1d017ce20df87;p=mirror%2Ffrr.git tools: Add coccinelle script to replace inet_ntop inside JSON Signed-off-by: Donatas Abraitis --- diff --git a/tools/coccinelle/json_object_string_addf.cocci b/tools/coccinelle/json_object_string_addf.cocci new file mode 100644 index 0000000000..d9f92e564c --- /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); +)