naccyde / rpms / iproute

Forked from rpms/iproute 9 months ago
Clone

Blame SOURCES/0046-ip-fix-all-the-checkpatch-warnings.patch

4aca6e
From dca16c0ab9a250b332e46deca0c9770988c5bc42 Mon Sep 17 00:00:00 2001
4aca6e
From: Phil Sutter <psutter@redhat.com>
4aca6e
Date: Tue, 28 Feb 2017 16:10:58 +0100
4aca6e
Subject: [PATCH] ip: fix all the checkpatch warnings
4aca6e
4aca6e
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1417289
4aca6e
Upstream Status: iproute2.git commit ec7aff5c4f15f
4aca6e
4aca6e
commit ec7aff5c4f15fbf7fe4886e826dffa02e1f7673b
4aca6e
Author: Stephen Hemminger <shemming@brocade.com>
4aca6e
Date:   Sun Jul 26 21:46:44 2015 -0700
4aca6e
4aca6e
    ip: fix all the checkpatch warnings
4aca6e
4aca6e
    Zhang Shengju some places where tabs were not being used.
4aca6e
    Go ahead and fix all the trival checkpatch warnings in ip/ip.c
4aca6e
    Also fix bridge.c
4aca6e
---
4aca6e
 bridge/bridge.c | 34 +++++++++++++++++++---------------
4aca6e
 include/utils.h |  2 +-
4aca6e
 ip/ip.c         | 48 ++++++++++++++++++++++++++----------------------
4aca6e
 3 files changed, 46 insertions(+), 38 deletions(-)
4aca6e
4aca6e
diff --git a/bridge/bridge.c b/bridge/bridge.c
4aca6e
index 88469ca..eaf09c8 100644
4aca6e
--- a/bridge/bridge.c
4aca6e
+++ b/bridge/bridge.c
4aca6e
@@ -18,12 +18,12 @@
4aca6e
 struct rtnl_handle rth = { .fd = -1 };
4aca6e
 int preferred_family = AF_UNSPEC;
4aca6e
 int resolve_hosts;
4aca6e
-int oneline = 0;
4aca6e
+int oneline;
4aca6e
 int show_stats;
4aca6e
 int show_details;
4aca6e
 int compress_vlans;
4aca6e
 int timestamp;
4aca6e
-char * _SL_ = NULL;
4aca6e
+const char *_SL_;
4aca6e
 
4aca6e
 static void usage(void) __attribute__((noreturn));
4aca6e
 
4aca6e
@@ -31,10 +31,10 @@ static void usage(void)
4aca6e
 {
4aca6e
 	fprintf(stderr,
4aca6e
 "Usage: bridge [ OPTIONS ] OBJECT { COMMAND | help }\n"
4aca6e
-"where  OBJECT := { link | fdb | mdb | vlan | monitor }\n"
4aca6e
-"       OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] |\n"
4aca6e
-"                    -o[neline] | -t[imestamp] | -n[etns] name |\n"
4aca6e
-"                    -c[ompressvlans] }\n");
4aca6e
+"where	OBJECT := { link | fdb | mdb | vlan | monitor }\n"
4aca6e
+"	OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] |\n"
4aca6e
+"		     -o[neline] | -t[imestamp] | -n[etns] name |\n"
4aca6e
+"		     -c[ompressvlans] }\n");
4aca6e
 	exit(-1);
4aca6e
 }
4aca6e
 
4aca6e
@@ -48,9 +48,9 @@ static const struct cmd {
4aca6e
 	const char *cmd;
4aca6e
 	int (*func)(int argc, char **argv);
4aca6e
 } cmds[] = {
4aca6e
-	{ "link", 	do_link },
4aca6e
-	{ "fdb", 	do_fdb },
4aca6e
-	{ "mdb", 	do_mdb },
4aca6e
+	{ "link",	do_link },
4aca6e
+	{ "fdb",	do_fdb },
4aca6e
+	{ "mdb",	do_mdb },
4aca6e
 	{ "vlan",	do_vlan },
4aca6e
 	{ "monitor",	do_monitor },
4aca6e
 	{ "help",	do_help },
4aca6e
@@ -66,7 +66,8 @@ static int do_cmd(const char *argv0, int argc, char **argv)
4aca6e
 			return c->func(argc-1, argv+1);
4aca6e
 	}
4aca6e
 
4aca6e
-	fprintf(stderr, "Object \"%s\" is unknown, try \"bridge help\".\n", argv0);
4aca6e
+	fprintf(stderr,
4aca6e
+		"Object \"%s\" is unknown, try \"bridge help\".\n", argv0);
4aca6e
 	return -1;
4aca6e
 }
4aca6e
 
4aca6e
@@ -74,8 +75,9 @@ int
4aca6e
 main(int argc, char **argv)
4aca6e
 {
4aca6e
 	while (argc > 1) {
4aca6e
-		char *opt = argv[1];
4aca6e
-		if (strcmp(opt,"--") == 0) {
4aca6e
+		const char *opt = argv[1];
4aca6e
+
4aca6e
+		if (strcmp(opt, "--") == 0) {
4aca6e
 			argc--; argv++;
4aca6e
 			break;
4aca6e
 		}
4aca6e
@@ -98,7 +100,7 @@ main(int argc, char **argv)
4aca6e
 			++oneline;
4aca6e
 		} else if (matches(opt, "-timestamp") == 0) {
4aca6e
 			++timestamp;
4aca6e
-                } else if (matches(opt, "-family") == 0) {
4aca6e
+		} else if (matches(opt, "-family") == 0) {
4aca6e
 			argc--;
4aca6e
 			argv++;
4aca6e
 			if (argc <= 1)
4aca6e
@@ -122,13 +124,15 @@ main(int argc, char **argv)
4aca6e
 		} else if (matches(opt, "-compressvlans") == 0) {
4aca6e
 			++compress_vlans;
4aca6e
 		} else {
4aca6e
-			fprintf(stderr, "Option \"%s\" is unknown, try \"bridge help\".\n", opt);
4aca6e
+			fprintf(stderr,
4aca6e
+				"Option \"%s\" is unknown, try \"bridge help\".\n",
4aca6e
+				opt);
4aca6e
 			exit(-1);
4aca6e
 		}
4aca6e
 		argc--;	argv++;
4aca6e
 	}
4aca6e
 
4aca6e
-	_SL_ = oneline ? "\\" : "\n" ;
4aca6e
+	_SL_ = oneline ? "\\" : "\n";
4aca6e
 
4aca6e
 	if (rtnl_open(&rth, 0) < 0)
4aca6e
 		exit(1);
4aca6e
diff --git a/include/utils.h b/include/utils.h
4aca6e
index 1ee9343..22198cb 100644
4aca6e
--- a/include/utils.h
4aca6e
+++ b/include/utils.h
4aca6e
@@ -21,7 +21,7 @@ extern int resolve_hosts;
4aca6e
 extern int oneline;
4aca6e
 extern int timestamp;
4aca6e
 extern int timestamp_short;
4aca6e
-extern char * _SL_;
4aca6e
+extern const char * _SL_;
4aca6e
 extern int max_flush_loops;
4aca6e
 extern int batch_mode;
4aca6e
 extern bool do_all;
4aca6e
diff --git a/ip/ip.c b/ip/ip.c
4aca6e
index d6f1391..644e712 100644
4aca6e
--- a/ip/ip.c
4aca6e
+++ b/ip/ip.c
4aca6e
@@ -25,18 +25,18 @@
4aca6e
 #include "namespace.h"
4aca6e
 
4aca6e
 int preferred_family = AF_UNSPEC;
4aca6e
-int human_readable = 0;
4aca6e
-int use_iec = 0;
4aca6e
-int show_stats = 0;
4aca6e
-int show_details = 0;
4aca6e
-int resolve_hosts = 0;
4aca6e
-int oneline = 0;
4aca6e
-int timestamp = 0;
4aca6e
-char * _SL_ = NULL;
4aca6e
-int force = 0;
4aca6e
+int human_readable;
4aca6e
+int use_iec;
4aca6e
+int show_stats;
4aca6e
+int show_details;
4aca6e
+int resolve_hosts;
4aca6e
+int oneline;
4aca6e
+int timestamp;
4aca6e
+const char *_SL_;
4aca6e
+int force;
4aca6e
 int max_flush_loops = 10;
4aca6e
-int batch_mode = 0;
4aca6e
-bool do_all = false;
4aca6e
+int batch_mode;
4aca6e
+bool do_all;
4aca6e
 
4aca6e
 struct rtnl_handle rth = { .fd = -1 };
4aca6e
 
4aca6e
@@ -63,7 +63,7 @@ static void usage(void)
4aca6e
 static int do_help(int argc, char **argv)
4aca6e
 {
4aca6e
 	usage();
4aca6e
-        return 0;
4aca6e
+	return 0;
4aca6e
 }
4aca6e
 
4aca6e
 static const struct cmd {
4aca6e
@@ -88,7 +88,7 @@ static const struct cmd {
4aca6e
 	{ "tap",	do_iptuntap },
4aca6e
 	{ "token",	do_iptoken },
4aca6e
 	{ "tcpmetrics",	do_tcp_metrics },
4aca6e
-	{ "tcp_metrics",do_tcp_metrics },
4aca6e
+	{ "tcp_metrics", do_tcp_metrics },
4aca6e
 	{ "monitor",	do_ipmonitor },
4aca6e
 	{ "xfrm",	do_xfrm },
4aca6e
 	{ "mroute",	do_multiroute },
4aca6e
@@ -104,9 +104,8 @@ static int do_cmd(const char *argv0, int argc, char **argv)
4aca6e
 	const struct cmd *c;
4aca6e
 
4aca6e
 	for (c = cmds; c->cmd; ++c) {
4aca6e
-		if (matches(argv0, c->cmd) == 0) {
4aca6e
+		if (matches(argv0, c->cmd) == 0)
4aca6e
 			return -(c->func(argc-1, argv+1));
4aca6e
-		}
4aca6e
 	}
4aca6e
 
4aca6e
 	fprintf(stderr, "Object \"%s\" is unknown, try \"ip help\".\n", argv0);
4aca6e
@@ -123,7 +122,8 @@ static int batch(const char *name)
4aca6e
 
4aca6e
 	if (name && strcmp(name, "-") != 0) {
4aca6e
 		if (freopen(name, "r", stdin) == NULL) {
4aca6e
-			fprintf(stderr, "Cannot open file \"%s\" for reading: %s\n",
4aca6e
+			fprintf(stderr,
4aca6e
+				"Cannot open file \"%s\" for reading: %s\n",
4aca6e
 				name, strerror(errno));
4aca6e
 			return EXIT_FAILURE;
4aca6e
 		}
4aca6e
@@ -144,7 +144,8 @@ static int batch(const char *name)
4aca6e
 			continue;	/* blank line */
4aca6e
 
4aca6e
 		if (do_cmd(largv[0], largc, largv)) {
4aca6e
-			fprintf(stderr, "Command failed %s:%d\n", name, cmdlineno);
4aca6e
+			fprintf(stderr, "Command failed %s:%d\n",
4aca6e
+				name, cmdlineno);
4aca6e
 			ret = EXIT_FAILURE;
4aca6e
 			if (!force)
4aca6e
 				break;
4aca6e
@@ -171,7 +172,8 @@ int main(int argc, char **argv)
4aca6e
 
4aca6e
 	while (argc > 1) {
4aca6e
 		char *opt = argv[1];
4aca6e
-		if (strcmp(opt,"--") == 0) {
4aca6e
+
4aca6e
+		if (strcmp(opt, "--") == 0) {
4aca6e
 			argc--; argv++;
4aca6e
 			break;
4aca6e
 		}
4aca6e
@@ -184,8 +186,8 @@ int main(int argc, char **argv)
4aca6e
 			argv++;
4aca6e
 			if (argc <= 1)
4aca6e
 				usage();
4aca6e
-                        max_flush_loops = atoi(argv[1]);
4aca6e
-                } else if (matches(opt, "-family") == 0) {
4aca6e
+			max_flush_loops = atoi(argv[1]);
4aca6e
+		} else if (matches(opt, "-family") == 0) {
4aca6e
 			argc--;
4aca6e
 			argv++;
4aca6e
 			if (argc <= 1)
4aca6e
@@ -264,13 +266,15 @@ int main(int argc, char **argv)
4aca6e
 		} else if (matches(opt, "-all") == 0) {
4aca6e
 			do_all = true;
4aca6e
 		} else {
4aca6e
-			fprintf(stderr, "Option \"%s\" is unknown, try \"ip -help\".\n", opt);
4aca6e
+			fprintf(stderr,
4aca6e
+				"Option \"%s\" is unknown, try \"ip -help\".\n",
4aca6e
+				opt);
4aca6e
 			exit(-1);
4aca6e
 		}
4aca6e
 		argc--;	argv++;
4aca6e
 	}
4aca6e
 
4aca6e
-	_SL_ = oneline ? "\\" : "\n" ;
4aca6e
+	_SL_ = oneline ? "\\" : "\n";
4aca6e
 
4aca6e
 	if (batch_file)
4aca6e
 		return batch(batch_file);
4aca6e
-- 
4aca6e
1.8.3.1
4aca6e