summaryrefslogtreecommitdiffstats
path: root/tools/vty_check.cocci
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2016-12-09 17:50:01 +0100
committerDavid Lamparter <equinox@opensourcerouting.org>2016-12-09 17:50:01 +0100
commit5304ba7e560fc9b5f13fd5657e370d726714673b (patch)
treea505ad39c3396ecf20d5f1d2192bb83258dd59c8 /tools/vty_check.cocci
parentlib: remove vty->index (diff)
downloadfrr-5304ba7e560fc9b5f13fd5657e370d726714673b.tar.xz
frr-5304ba7e560fc9b5f13fd5657e370d726714673b.zip
*: kill useless if(...) after VTY_DECLVAR_CONTEXT
VTY_DECLVAR_CONTEXT already contains a NULL check, vty warning message and return statement. These are not needed. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to '')
-rw-r--r--tools/vty_check.cocci22
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/vty_check.cocci b/tools/vty_check.cocci
new file mode 100644
index 000000000..7e5fcc405
--- /dev/null
+++ b/tools/vty_check.cocci
@@ -0,0 +1,22 @@
+/*
+ * VTY_DECLVAR_CONTEXT contains a built-in "if (!var) return;"
+ */
+@@
+identifier var, typ;
+statement S;
+@@
+
+ {
+ ...
+ \(
+ VTY_DECLVAR_CONTEXT(typ, var);
+ \|
+ VTY_DECLVAR_CONTEXT_SUB(typ, var);
+ \)
+ ...
+- if (
+- \( !var \| var == NULL \)
+- )
+- S
+ ...
+ }