netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2 0/2] Fixes from LGTM
@ 2022-06-17 17:19 Stephen Hemminger
  2022-06-17 17:19 ` [PATCH iproute2 1/2] genl: fix duplicate include guard Stephen Hemminger
  2022-06-17 17:19 ` [PATCH iproute2 2/2] tc: declaration hides parameter Stephen Hemminger
  0 siblings, 2 replies; 3+ messages in thread
From: Stephen Hemminger @ 2022-06-17 17:19 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

Ran LGTM (aka codeql) on iproute2 and it found a couple of
obvious poitential issues.

Stephen Hemminger (2):
  genl: fix duplicate include guard
  tc: declaration hides parameter

 genl/genl_utils.h |  4 ++--
 tc/f_basic.c      |  6 +++---
 tc/f_bpf.c        |  6 +++---
 tc/f_flower.c     | 14 +++++++-------
 tc/f_fw.c         |  6 +++---
 tc/f_matchall.c   |  6 +++---
 tc/f_route.c      |  6 +++---
 tc/f_rsvp.c       |  6 +++---
 8 files changed, 27 insertions(+), 27 deletions(-)

-- 
2.35.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH iproute2 1/2] genl: fix duplicate include guard
  2022-06-17 17:19 [PATCH iproute2 0/2] Fixes from LGTM Stephen Hemminger
@ 2022-06-17 17:19 ` Stephen Hemminger
  2022-06-17 17:19 ` [PATCH iproute2 2/2] tc: declaration hides parameter Stephen Hemminger
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2022-06-17 17:19 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

The include guard should be unique per file.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 genl/genl_utils.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/genl/genl_utils.h b/genl/genl_utils.h
index 87b4f34c58d8..9fbeba75b4b8 100644
--- a/genl/genl_utils.h
+++ b/genl/genl_utils.h
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _TC_UTIL_H_
-#define _TC_UTIL_H_ 1
+#ifndef _GENL_UTILS_H_
+#define _GENL_UTILS_H_ 1
 
 #include <linux/genetlink.h>
 #include "utils.h"
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH iproute2 2/2] tc: declaration hides parameter
  2022-06-17 17:19 [PATCH iproute2 0/2] Fixes from LGTM Stephen Hemminger
  2022-06-17 17:19 ` [PATCH iproute2 1/2] genl: fix duplicate include guard Stephen Hemminger
@ 2022-06-17 17:19 ` Stephen Hemminger
  1 sibling, 0 replies; 3+ messages in thread
From: Stephen Hemminger @ 2022-06-17 17:19 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

In several places (code reuse?), the variable handle is a parameter
to the function, but then is defined inside basic block for classid.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 tc/f_basic.c    |  6 +++---
 tc/f_bpf.c      |  6 +++---
 tc/f_flower.c   | 14 +++++++-------
 tc/f_fw.c       |  6 +++---
 tc/f_matchall.c |  6 +++---
 tc/f_route.c    |  6 +++---
 tc/f_rsvp.c     |  6 +++---
 7 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/tc/f_basic.c b/tc/f_basic.c
index 7b19cea6e87e..9a60758e803e 100644
--- a/tc/f_basic.c
+++ b/tc/f_basic.c
@@ -70,14 +70,14 @@ static int basic_parse_opt(struct filter_util *qu, char *handle,
 			continue;
 		} else if (matches(*argv, "classid") == 0 ||
 			   strcmp(*argv, "flowid") == 0) {
-			unsigned int handle;
+			unsigned int classid;
 
 			NEXT_ARG();
-			if (get_tc_classid(&handle, *argv)) {
+			if (get_tc_classid(&classid, *argv)) {
 				fprintf(stderr, "Illegal \"classid\"\n");
 				return -1;
 			}
-			addattr_l(n, MAX_MSG, TCA_BASIC_CLASSID, &handle, 4);
+			addattr_l(n, MAX_MSG, TCA_BASIC_CLASSID, &classid, 4);
 		} else if (matches(*argv, "action") == 0) {
 			NEXT_ARG();
 			if (parse_action(&argc, &argv, TCA_BASIC_ACT, n)) {
diff --git a/tc/f_bpf.c b/tc/f_bpf.c
index fa3552aefffd..96e4576aa2f8 100644
--- a/tc/f_bpf.c
+++ b/tc/f_bpf.c
@@ -126,14 +126,14 @@ opt_bpf:
 			bpf_uds_name = cfg.uds;
 		} else if (matches(*argv, "classid") == 0 ||
 			   matches(*argv, "flowid") == 0) {
-			unsigned int handle;
+			unsigned int classid;
 
 			NEXT_ARG();
-			if (get_tc_classid(&handle, *argv)) {
+			if (get_tc_classid(&classid, *argv)) {
 				fprintf(stderr, "Illegal \"classid\"\n");
 				return -1;
 			}
-			addattr32(n, MAX_MSG, TCA_BPF_CLASSID, handle);
+			addattr32(n, MAX_MSG, TCA_BPF_CLASSID, classid);
 		} else if (matches(*argv, "direct-action") == 0 ||
 			   matches(*argv, "da") == 0) {
 			bpf_flags |= TCA_BPF_FLAG_ACT_DIRECT;
diff --git a/tc/f_flower.c b/tc/f_flower.c
index 805ca6718fa7..622ec321f310 100644
--- a/tc/f_flower.c
+++ b/tc/f_flower.c
@@ -1452,17 +1452,17 @@ static int flower_parse_opt(struct filter_util *qu, char *handle,
 	while (argc > 0) {
 		if (matches(*argv, "classid") == 0 ||
 		    matches(*argv, "flowid") == 0) {
-			unsigned int handle;
+			unsigned int classid;
 
 			NEXT_ARG();
-			ret = get_tc_classid(&handle, *argv);
+			ret = get_tc_classid(&classid, *argv);
 			if (ret) {
 				fprintf(stderr, "Illegal \"classid\"\n");
 				return -1;
 			}
-			addattr_l(n, MAX_MSG, TCA_FLOWER_CLASSID, &handle, 4);
+			addattr_l(n, MAX_MSG, TCA_FLOWER_CLASSID, &classid, 4);
 		} else if (matches(*argv, "hw_tc") == 0) {
-			unsigned int handle;
+			unsigned int classid;
 			__u32 tc;
 			char *end;
 
@@ -1476,10 +1476,10 @@ static int flower_parse_opt(struct filter_util *qu, char *handle,
 				fprintf(stderr, "TC index exceeds max range\n");
 				return -1;
 			}
-			handle = TC_H_MAKE(TC_H_MAJ(t->tcm_parent),
+			classid = TC_H_MAKE(TC_H_MAJ(t->tcm_parent),
 					   TC_H_MIN(tc + TC_H_MIN_PRIORITY));
-			addattr_l(n, MAX_MSG, TCA_FLOWER_CLASSID, &handle,
-				  sizeof(handle));
+			addattr_l(n, MAX_MSG, TCA_FLOWER_CLASSID, &classid,
+				  sizeof(classid));
 		} else if (matches(*argv, "ip_flags") == 0) {
 			NEXT_ARG();
 			ret = flower_parse_matching_flags(*argv,
diff --git a/tc/f_fw.c b/tc/f_fw.c
index 688364f55d1d..3c6ea93d2944 100644
--- a/tc/f_fw.c
+++ b/tc/f_fw.c
@@ -70,14 +70,14 @@ static int fw_parse_opt(struct filter_util *qu, char *handle, int argc, char **a
 	while (argc > 0) {
 		if (matches(*argv, "classid") == 0 ||
 		    matches(*argv, "flowid") == 0) {
-			unsigned int handle;
+			unsigned int classid;
 
 			NEXT_ARG();
-			if (get_tc_classid(&handle, *argv)) {
+			if (get_tc_classid(&classid, *argv)) {
 				fprintf(stderr, "Illegal \"classid\"\n");
 				return -1;
 			}
-			addattr_l(n, 4096, TCA_FW_CLASSID, &handle, 4);
+			addattr_l(n, 4096, TCA_FW_CLASSID, &classid, 4);
 		} else if (matches(*argv, "police") == 0) {
 			NEXT_ARG();
 			if (parse_police(&argc, &argv, TCA_FW_POLICE, n)) {
diff --git a/tc/f_matchall.c b/tc/f_matchall.c
index 253ed5ce42e0..231d749e1f43 100644
--- a/tc/f_matchall.c
+++ b/tc/f_matchall.c
@@ -63,14 +63,14 @@ static int matchall_parse_opt(struct filter_util *qu, char *handle,
 	while (argc > 0) {
 		if (matches(*argv, "classid") == 0 ||
 			   strcmp(*argv, "flowid") == 0) {
-			unsigned int handle;
+			unsigned int classid;
 
 			NEXT_ARG();
-			if (get_tc_classid(&handle, *argv)) {
+			if (get_tc_classid(&classid, *argv)) {
 				fprintf(stderr, "Illegal \"classid\"\n");
 				return -1;
 			}
-			addattr_l(n, MAX_MSG, TCA_MATCHALL_CLASSID, &handle, 4);
+			addattr_l(n, MAX_MSG, TCA_MATCHALL_CLASSID, &classid, 4);
 		} else if (matches(*argv, "action") == 0) {
 			NEXT_ARG();
 			if (parse_action(&argc, &argv, TCA_MATCHALL_ACT, n)) {
diff --git a/tc/f_route.c b/tc/f_route.c
index 31fa96a0565e..ad516b382ac0 100644
--- a/tc/f_route.c
+++ b/tc/f_route.c
@@ -91,14 +91,14 @@ static int route_parse_opt(struct filter_util *qu, char *handle, int argc, char
 			fh |= (0x8000|id)<<16;
 		} else if (matches(*argv, "classid") == 0 ||
 			   strcmp(*argv, "flowid") == 0) {
-			unsigned int handle;
+			unsigned int classid;
 
 			NEXT_ARG();
-			if (get_tc_classid(&handle, *argv)) {
+			if (get_tc_classid(&classid, *argv)) {
 				fprintf(stderr, "Illegal \"classid\"\n");
 				return -1;
 			}
-			addattr_l(n, 4096, TCA_ROUTE4_CLASSID, &handle, 4);
+			addattr_l(n, 4096, TCA_ROUTE4_CLASSID, &classid, 4);
 		} else if (matches(*argv, "police") == 0) {
 			NEXT_ARG();
 			if (parse_police(&argc, &argv, TCA_ROUTE4_POLICE, n)) {
diff --git a/tc/f_rsvp.c b/tc/f_rsvp.c
index 388e9ee59ad3..0211c3f5e74b 100644
--- a/tc/f_rsvp.c
+++ b/tc/f_rsvp.c
@@ -230,14 +230,14 @@ static int rsvp_parse_opt(struct filter_util *qu, char *handle, int argc,
 			pinfo_ok++;
 		} else if (matches(*argv, "classid") == 0 ||
 			   strcmp(*argv, "flowid") == 0) {
-			unsigned int handle;
+			unsigned int classid;
 
 			NEXT_ARG();
-			if (get_tc_classid(&handle, *argv)) {
+			if (get_tc_classid(&classid, *argv)) {
 				fprintf(stderr, "Illegal \"classid\"\n");
 				return -1;
 			}
-			addattr_l(n, 4096, TCA_RSVP_CLASSID, &handle, 4);
+			addattr_l(n, 4096, TCA_RSVP_CLASSID, &classid, 4);
 		} else if (strcmp(*argv, "tunnelid") == 0) {
 			unsigned int tid;
 
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-17 17:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-17 17:19 [PATCH iproute2 0/2] Fixes from LGTM Stephen Hemminger
2022-06-17 17:19 ` [PATCH iproute2 1/2] genl: fix duplicate include guard Stephen Hemminger
2022-06-17 17:19 ` [PATCH iproute2 2/2] tc: declaration hides parameter Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).