From c54142bb84e86e563c228a0f82f1d5f6989dd952 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Thu, 2 Jul 2020 11:39:29 +0300 Subject: [PATCH 1/2] tools: Catch argv_find() cases when testing only the index Signed-off-by: Donatas Abraitis --- tools/coccinelle/argv_find.cocci | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 tools/coccinelle/argv_find.cocci diff --git a/tools/coccinelle/argv_find.cocci b/tools/coccinelle/argv_find.cocci new file mode 100644 index 0000000000..f13b035d7a --- /dev/null +++ b/tools/coccinelle/argv_find.cocci @@ -0,0 +1,16 @@ +@@ +identifier idx; +identifier argv; +identifier argc; +expression e1; +expression e2; +@@ + +- argv_find(argv, argc, e1, &idx); + if ( +- idx ++ argv_find(argv, argc, e1, &idx) + ) + { + e2; + } From 947073e39747f547229076527ac82a8dc8529e60 Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Thu, 2 Jul 2020 11:39:40 +0300 Subject: [PATCH 2/2] bgpd: Actually find the sequence number for large-community-list Signed-off-by: Donatas Abraitis --- bgpd/bgp_vty.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 4eb165385f..449dab12b0 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -17332,8 +17332,7 @@ static int lcommunity_list_set_vty(struct vty *vty, int argc, char *cl_name; char *seq = NULL; - argv_find(argv, argc, "(1-4294967295)", &idx); - if (idx) + if (argv_find(argv, argc, "(1-4294967295)", &idx)) seq = argv[idx]->arg; idx = 0; @@ -17382,8 +17381,7 @@ static int lcommunity_list_unset_vty(struct vty *vty, int argc, int idx = 0; char *seq = NULL; - argv_find(argv, argc, "(1-4294967295)", &idx); - if (idx) + if (argv_find(argv, argc, "(1-4294967295)", &idx)) seq = argv[idx]->arg; idx = 0;