[PATCH ibdiags 06/16] ibdiags: Do not use optarg for process_opt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jason Gunthorpe <jgg@xxxxxxxxxxxx>

Avoid a -Wshadow warning from gcc, access the global directly instead.

Signed-off-by: Jason Gunthorpe <jgg@xxxxxxxxxxxx>
---
 include/ibdiag_common.h |  3 +--
 src/dump_fts.c          |  3 +--
 src/ibaddr.c            |  3 +--
 src/ibcacheedit.c       |  3 +--
 src/ibccconfig.c        |  3 +--
 src/ibccquery.c         |  3 +--
 src/ibdiag_common.c     | 11 +++++------
 src/iblinkinfo.c        |  3 +--
 src/ibnetdiscover.c     |  3 +--
 src/ibping.c            |  3 +--
 src/ibportstate.c       |  1 -
 src/ibqueryerrors.c     |  3 +--
 src/ibroute.c           |  3 +--
 src/ibsendtrap.c        |  1 -
 src/ibstat.c            |  3 +--
 src/ibsysstat.c         |  3 +--
 src/ibtracert.c         |  3 +--
 src/perfquery.c         |  3 +--
 src/saquery.c           |  3 +--
 src/sminfo.c            |  3 +--
 src/smpdump.c           |  3 +--
 src/smpquery.c          |  3 +--
 src/vendstat.c          |  3 +--
 23 files changed, 25 insertions(+), 48 deletions(-)

diff --git a/include/ibdiag_common.h b/include/ibdiag_common.h
index 34f8eb7cdf3674..6e7ec3851bb190 100644
--- a/include/ibdiag_common.h
+++ b/include/ibdiag_common.h
@@ -135,8 +135,7 @@ struct ibdiag_opt {
 extern int ibdiag_process_opts(int argc, char *const argv[], void *context,
 			       const char *exclude_common_str,
 			       const struct ibdiag_opt custom_opts[],
-			       int (*custom_handler) (void *cxt, int val,
-						      char *optarg),
+			       int (*custom_handler) (void *cxt, int val),
 			       const char *usage_args,
 			       const char *usage_examples[]);
 extern void ibdiag_show_usage(void);
diff --git a/src/dump_fts.c b/src/dump_fts.c
index 3a9299d174e441..b22282b4935bfe 100644
--- a/src/dump_fts.c
+++ b/src/dump_fts.c
@@ -42,7 +42,6 @@
 #include <unistd.h>
 #include <string.h>
 #include <inttypes.h>
-#include <getopt.h>
 #include <netinet/in.h>
 #include <assert.h>
 
@@ -394,7 +393,7 @@ static void process_switch(ibnd_node_t *node, void *fabric)
 	dump_node(node, srcport, (ibnd_fabric_t *)fabric);
 }
 
-static int process_opt(void *context, int ch, char *optarg)
+static int process_opt(void *context, int ch)
 {
 	switch (ch) {
 	case 'a':
diff --git a/src/ibaddr.c b/src/ibaddr.c
index 1a721d0a003f23..c13f3bfc5c7976 100644
--- a/src/ibaddr.c
+++ b/src/ibaddr.c
@@ -39,7 +39,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <getopt.h>
 #include <arpa/inet.h>
 
 #include <infiniband/umad.h>
@@ -91,7 +90,7 @@ static int ib_resolve_addr(ib_portid_t * portid, int portnum, int show_lid,
 
 static int show_lid, show_gid;
 
-static int process_opt(void *context, int ch, char *optarg)
+static int process_opt(void *context, int ch)
 {
 	switch (ch) {
 	case 'g':
diff --git a/src/ibcacheedit.c b/src/ibcacheedit.c
index 904089b3b2e8e8..e8dc244e051f77 100644
--- a/src/ibcacheedit.c
+++ b/src/ibcacheedit.c
@@ -39,7 +39,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <getopt.h>
 #include <inttypes.h>
 
 #include <infiniband/mad.h>
@@ -126,7 +125,7 @@ static int parse_guidbeforeafter(char *arg,
 	return 0;
 }
 
-static int process_opt(void *context, int ch, char *optarg)
+static int process_opt(void *context, int ch)
 {
 	switch (ch) {
 	case 1:
diff --git a/src/ibccconfig.c b/src/ibccconfig.c
index 19a075aa9dd435..54a501ee6cc910 100644
--- a/src/ibccconfig.c
+++ b/src/ibccconfig.c
@@ -41,7 +41,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
-#include <getopt.h>
 #include <errno.h>
 #include <netinet/in.h>
 #include <limits.h>
@@ -545,7 +544,7 @@ static const char *congestion_control_table(ib_portid_t *dest, char **argv,
 	return NULL;
 }
 
-static int process_opt(void *context, int ch, char *optarg)
+static int process_opt(void *context, int ch)
 {
 	switch (ch) {
 	case 'c':
diff --git a/src/ibccquery.c b/src/ibccquery.c
index 9bcbf8645b7bd6..0882983c2ddeac 100644
--- a/src/ibccquery.c
+++ b/src/ibccquery.c
@@ -41,7 +41,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
-#include <getopt.h>
 #include <netinet/in.h>
 
 #define __STDC_FORMAT_MACROS
@@ -340,7 +339,7 @@ static const char *timestamp_dump(ib_portid_t *dest, char **argv, int argc)
 	return NULL;
 }
 
-static int process_opt(void *context, int ch, char *optarg)
+static int process_opt(void *context, int ch)
 {
 	switch (ch) {
 	case 'c':
diff --git a/src/ibdiag_common.c b/src/ibdiag_common.c
index 962527e0c6feab..cdb099dd3771a3 100644
--- a/src/ibdiag_common.c
+++ b/src/ibdiag_common.c
@@ -212,7 +212,7 @@ void ibdiag_show_usage(void)
 	exit(2);
 }
 
-static int process_opt(int ch, char *optarg)
+static int process_opt(int ch)
 {
 	char *endp;
 	long val;
@@ -373,8 +373,7 @@ static void make_str_opts(const struct option *o, char *p, unsigned size)
 int ibdiag_process_opts(int argc, char *const argv[], void *cxt,
 			const char *exclude_common_str,
 			const struct ibdiag_opt custom_opts[],
-			int (*custom_handler) (void *cxt, int val,
-					       char *optarg),
+			int (*custom_handler) (void *cxt, int val),
 			const char *usage_args, const char *usage_examples[])
 {
 	char str_opts[1024];
@@ -403,10 +402,10 @@ int ibdiag_process_opts(int argc, char *const argv[], void *cxt,
 		if (!o)
 			ibdiag_show_usage();
 		if (custom_handler) {
-			if (custom_handler(cxt, ch, optarg) &&
-			    process_opt(ch, optarg))
+			if (custom_handler(cxt, ch) &&
+			    process_opt(ch))
 				ibdiag_show_usage();
-		} else if (process_opt(ch, optarg))
+		} else if (process_opt(ch))
 			ibdiag_show_usage();
 	}
 
diff --git a/src/iblinkinfo.c b/src/iblinkinfo.c
index e5f5b9a7e2d3fa..c838afebdaef3b 100644
--- a/src/iblinkinfo.c
+++ b/src/iblinkinfo.c
@@ -45,7 +45,6 @@
 #include <stdarg.h>
 #include <time.h>
 #include <string.h>
-#include <getopt.h>
 #include <errno.h>
 #include <inttypes.h>
 
@@ -513,7 +512,7 @@ static int diff_node(ibnd_node_t *node, ibnd_fabric_t *orig_fabric,
 	return 0;
 }
 
-static int process_opt(void *context, int ch, char *optarg)
+static int process_opt(void *context, int ch)
 {
 	struct ibnd_config *cfg = context;
 	char *p;
diff --git a/src/ibnetdiscover.c b/src/ibnetdiscover.c
index 91ce56bf011b4d..9a5b3d515c32c3 100644
--- a/src/ibnetdiscover.c
+++ b/src/ibnetdiscover.c
@@ -44,7 +44,6 @@
 #include <unistd.h>
 #include <time.h>
 #include <string.h>
-#include <getopt.h>
 #include <inttypes.h>
 
 #include <infiniband/umad.h>
@@ -991,7 +990,7 @@ static int diff(ibnd_fabric_t *orig_fabric, ibnd_fabric_t *new_fabric)
 
 static int list, group, ports_report;
 
-static int process_opt(void *context, int ch, char *optarg)
+static int process_opt(void *context, int ch)
 {
 	struct ibnd_config *cfg = context;
 	char *p;
diff --git a/src/ibping.c b/src/ibping.c
index b463043ae73eb6..591619a0b6709b 100644
--- a/src/ibping.c
+++ b/src/ibping.c
@@ -40,7 +40,6 @@
 #include <unistd.h>
 #include <string.h>
 #include <signal.h>
-#include <getopt.h>
 #include <time.h>
 
 #include <infiniband/umad.h>
@@ -175,7 +174,7 @@ static void report(int sig)
 static int server = 0, flood = 0;
 static unsigned count = ~0;
 
-static int process_opt(void *context, int ch, char *optarg)
+static int process_opt(void *context, int ch)
 {
 	switch (ch) {
 	case 'c':
diff --git a/src/ibportstate.c b/src/ibportstate.c
index 75eafc5f12970b..f733cf8eab2a92 100644
--- a/src/ibportstate.c
+++ b/src/ibportstate.c
@@ -41,7 +41,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
-#include <getopt.h>
 #include <errno.h>
 
 #include <infiniband/umad.h>
diff --git a/src/ibqueryerrors.c b/src/ibqueryerrors.c
index fa3321c5c6c853..f86daaab9a8374 100644
--- a/src/ibqueryerrors.c
+++ b/src/ibqueryerrors.c
@@ -46,7 +46,6 @@
 #include <stdarg.h>
 #include <time.h>
 #include <string.h>
-#include <getopt.h>
 #include <errno.h>
 #include <inttypes.h>
 
@@ -899,7 +898,7 @@ static void calculate_suppressed_fields(char *str)
 	free(tmp);
 }
 
-static int process_opt(void *context, int ch, char *optarg)
+static int process_opt(void *context, int ch)
 {
 	struct ibnd_config *cfg = context;
 	switch (ch) {
diff --git a/src/ibroute.c b/src/ibroute.c
index 76dab8940c49d4..15d726035bff19 100644
--- a/src/ibroute.c
+++ b/src/ibroute.c
@@ -41,7 +41,6 @@
 #include <unistd.h>
 #include <string.h>
 #include <inttypes.h>
-#include <getopt.h>
 #include <netinet/in.h>
 
 #include <infiniband/umad.h>
@@ -396,7 +395,7 @@ static const char *dump_unicast_tables(ib_portid_t *portid, int startlid,
 	return 0;
 }
 
-static int process_opt(void *context, int ch, char *optarg)
+static int process_opt(void *context, int ch)
 {
 	switch (ch) {
 	case 'a':
diff --git a/src/ibsendtrap.c b/src/ibsendtrap.c
index b6751a957c9183..dd1a92722824e0 100644
--- a/src/ibsendtrap.c
+++ b/src/ibsendtrap.c
@@ -43,7 +43,6 @@
 #include <string.h>
 
 #define _GNU_SOURCE
-#include <getopt.h>
 
 #include <infiniband/mad.h>
 #include <iba/ib_types.h>
diff --git a/src/ibstat.c b/src/ibstat.c
index a6deccf5a91770..308e29118df654 100644
--- a/src/ibstat.c
+++ b/src/ibstat.c
@@ -42,7 +42,6 @@
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <getopt.h>
 #include <netinet/in.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -260,7 +259,7 @@ static int ports_list(char names[][UMAD_CA_NAME_LEN], int n)
 
 static int list_only, short_format, list_ports;
 
-static int process_opt(void *context, int ch, char *optarg)
+static int process_opt(void *context, int ch)
 {
 	switch (ch) {
 	case 'l':
diff --git a/src/ibsysstat.c b/src/ibsysstat.c
index d49eafc63e4b23..9c2da8e7fd4884 100644
--- a/src/ibsysstat.c
+++ b/src/ibsysstat.c
@@ -39,7 +39,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
-#include <getopt.h>
 
 #include <infiniband/umad.h>
 #include <infiniband/mad.h>
@@ -296,7 +295,7 @@ static int build_cpuinfo(void)
 	return ncpu;
 }
 
-static int process_opt(void *context, int ch, char *optarg)
+static int process_opt(void *context, int ch)
 {
 	switch (ch) {
 	case 'o':
diff --git a/src/ibtracert.c b/src/ibtracert.c
index 98911db1442236..91461217bf705f 100644
--- a/src/ibtracert.c
+++ b/src/ibtracert.c
@@ -42,7 +42,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <ctype.h>
-#include <getopt.h>
 #include <netinet/in.h>
 #include <inttypes.h>
 
@@ -756,7 +755,7 @@ static int resolve_lid(ib_portid_t *portid)
 
 static int dumplevel = 2, multicast, mlid;
 
-static int process_opt(void *context, int ch, char *optarg)
+static int process_opt(void *context, int ch)
 {
 	switch (ch) {
 	case 1:
diff --git a/src/perfquery.c b/src/perfquery.c
index 91fe94e74dafbe..b0baa3bec7d3bf 100644
--- a/src/perfquery.c
+++ b/src/perfquery.c
@@ -41,7 +41,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <getopt.h>
 #include <netinet/in.h>
 
 #include <infiniband/umad.h>
@@ -716,7 +715,7 @@ static void dump_portsamples_control(ib_portid_t *portid, int port)
 	       port, buf);
 }
 
-static int process_opt(void *context, int ch, char *optarg)
+static int process_opt(void *context, int ch)
 {
 	switch (ch) {
 	case 'x':
diff --git a/src/saquery.c b/src/saquery.c
index d9c5d387046807..b882b2bdaf08ba 100644
--- a/src/saquery.c
+++ b/src/saquery.c
@@ -50,7 +50,6 @@
 #include <errno.h>
 
 #define _GNU_SOURCE
-#include <getopt.h>
 
 #include <infiniband/umad.h>
 #include <infiniband/mad.h>
@@ -1521,7 +1520,7 @@ static enum saquery_command command = SAQUERY_CMD_QUERY;
 static uint16_t query_type;
 static char *src_lid, *dst_lid;
 
-static int process_opt(void *context, int ch, char *optarg)
+static int process_opt(void *context, int ch)
 {
 	struct query_params *p = context;
 
diff --git a/src/sminfo.c b/src/sminfo.c
index caec7cf00d5f3d..7e6a18a41e12fc 100644
--- a/src/sminfo.c
+++ b/src/sminfo.c
@@ -40,7 +40,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <inttypes.h>
-#include <getopt.h>
 
 #include <infiniband/umad.h>
 #include <infiniband/mad.h>
@@ -74,7 +73,7 @@ const char *const statestr[] = {
 static unsigned act;
 static int prio, state = SMINFO_STANDBY;
 
-static int process_opt(void *context, int ch, char *optarg)
+static int process_opt(void *context, int ch)
 {
 	switch (ch) {
 	case 'a':
diff --git a/src/smpdump.c b/src/smpdump.c
index 3f80ef56ca5868..beb7168bd9aab9 100644
--- a/src/smpdump.c
+++ b/src/smpdump.c
@@ -42,7 +42,6 @@
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <getopt.h>
 #include <netinet/in.h>
 #include <endian.h>
 
@@ -152,7 +151,7 @@ static int str2DRPath(char *str, DRPath * path)
 
 static int dump_char, mgmt_class = IB_SMI_CLASS;
 
-static int process_opt(void *context, int ch, char *optarg)
+static int process_opt(void *context, int ch)
 {
 	switch (ch) {
 	case 's':
diff --git a/src/smpquery.c b/src/smpquery.c
index 4a104174fdcb34..5254d131de2b29 100644
--- a/src/smpquery.c
+++ b/src/smpquery.c
@@ -40,7 +40,6 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
-#include <getopt.h>
 #include <netinet/in.h>
 
 #define __STDC_FORMAT_MACROS
@@ -411,7 +410,7 @@ static const char *guid_info(ib_portid_t *dest, char **argv, int argc)
 	return 0;
 }
 
-static int process_opt(void *context, int ch, char *optarg)
+static int process_opt(void *context, int ch)
 {
 	switch (ch) {
 	case 1:
diff --git a/src/vendstat.c b/src/vendstat.c
index e9916da1a9f456..f7c17578be837c 100644
--- a/src/vendstat.c
+++ b/src/vendstat.c
@@ -39,7 +39,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <getopt.h>
 #include <netinet/in.h>
 
 #include <infiniband/umad.h>
@@ -291,7 +290,7 @@ static is3_config_space_t write_cs, read_cs;
 static unsigned write_cs_records, read_cs_records;
 
 
-static int process_opt(void *context, int ch, char *optarg)
+static int process_opt(void *context, int ch)
 {
 	int ret;
 	switch (ch) {
-- 
2.21.0




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux