From c33b17feb184d572ba00473922f448da42e9b643 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Tue, 4 Feb 2020 20:08:50 +0200 Subject: [PATCH 1/2] tools: Add coccinelle script to check if we use shorthand operators Signed-off-by: Donatas Abraitis --- scripts/coccinelle/shorthand_operator.cocci | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 scripts/coccinelle/shorthand_operator.cocci diff --git a/scripts/coccinelle/shorthand_operator.cocci b/scripts/coccinelle/shorthand_operator.cocci new file mode 100644 index 0000000000..f7019d4040 --- /dev/null +++ b/scripts/coccinelle/shorthand_operator.cocci @@ -0,0 +1,12 @@ +@@ +identifier data; +constant x; +@@ + +( +- data = data + x ++ data += x +| +- data = data - x ++ data -= x +) From b49a912271eaefa0fc9e7de3c4ed52f21e48fdc9 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Tue, 4 Feb 2020 20:11:59 +0200 Subject: [PATCH 2/2] zebra: Use shorthand operator in ifm_read() Signed-off-by: Donatas Abraitis --- zebra/kernel_socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c index c2812aa47b..7cdd6ef84e 100644 --- a/zebra/kernel_socket.c +++ b/zebra/kernel_socket.c @@ -556,7 +556,7 @@ int ifm_read(struct if_msghdr *ifm) * is 12 bytes larger than the 32 bit version. */ if (((struct sockaddr *)cp)->sa_family == AF_UNSPEC) - cp = cp + 12; + cp += 12; #endif /* Look up for RTA_IFP and skip others. */