Blob Blame History Raw
From dca16c0ab9a250b332e46deca0c9770988c5bc42 Mon Sep 17 00:00:00 2001
From: Phil Sutter <psutter@redhat.com>
Date: Tue, 28 Feb 2017 16:10:58 +0100
Subject: [PATCH] ip: fix all the checkpatch warnings

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1417289
Upstream Status: iproute2.git commit ec7aff5c4f15f

commit ec7aff5c4f15fbf7fe4886e826dffa02e1f7673b
Author: Stephen Hemminger <shemming@brocade.com>
Date:   Sun Jul 26 21:46:44 2015 -0700

    ip: fix all the checkpatch warnings

    Zhang Shengju some places where tabs were not being used.
    Go ahead and fix all the trival checkpatch warnings in ip/ip.c
    Also fix bridge.c
---
 bridge/bridge.c | 34 +++++++++++++++++++---------------
 include/utils.h |  2 +-
 ip/ip.c         | 48 ++++++++++++++++++++++++++----------------------
 3 files changed, 46 insertions(+), 38 deletions(-)

diff --git a/bridge/bridge.c b/bridge/bridge.c
index 88469ca..eaf09c8 100644
--- a/bridge/bridge.c
+++ b/bridge/bridge.c
@@ -18,12 +18,12 @@
 struct rtnl_handle rth = { .fd = -1 };
 int preferred_family = AF_UNSPEC;
 int resolve_hosts;
-int oneline = 0;
+int oneline;
 int show_stats;
 int show_details;
 int compress_vlans;
 int timestamp;
-char * _SL_ = NULL;
+const char *_SL_;
 
 static void usage(void) __attribute__((noreturn));
 
@@ -31,10 +31,10 @@ static void usage(void)
 {
 	fprintf(stderr,
 "Usage: bridge [ OPTIONS ] OBJECT { COMMAND | help }\n"
-"where  OBJECT := { link | fdb | mdb | vlan | monitor }\n"
-"       OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] |\n"
-"                    -o[neline] | -t[imestamp] | -n[etns] name |\n"
-"                    -c[ompressvlans] }\n");
+"where	OBJECT := { link | fdb | mdb | vlan | monitor }\n"
+"	OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] |\n"
+"		     -o[neline] | -t[imestamp] | -n[etns] name |\n"
+"		     -c[ompressvlans] }\n");
 	exit(-1);
 }
 
@@ -48,9 +48,9 @@ static const struct cmd {
 	const char *cmd;
 	int (*func)(int argc, char **argv);
 } cmds[] = {
-	{ "link", 	do_link },
-	{ "fdb", 	do_fdb },
-	{ "mdb", 	do_mdb },
+	{ "link",	do_link },
+	{ "fdb",	do_fdb },
+	{ "mdb",	do_mdb },
 	{ "vlan",	do_vlan },
 	{ "monitor",	do_monitor },
 	{ "help",	do_help },
@@ -66,7 +66,8 @@ static int do_cmd(const char *argv0, int argc, char **argv)
 			return c->func(argc-1, argv+1);
 	}
 
-	fprintf(stderr, "Object \"%s\" is unknown, try \"bridge help\".\n", argv0);
+	fprintf(stderr,
+		"Object \"%s\" is unknown, try \"bridge help\".\n", argv0);
 	return -1;
 }
 
@@ -74,8 +75,9 @@ int
 main(int argc, char **argv)
 {
 	while (argc > 1) {
-		char *opt = argv[1];
-		if (strcmp(opt,"--") == 0) {
+		const char *opt = argv[1];
+
+		if (strcmp(opt, "--") == 0) {
 			argc--; argv++;
 			break;
 		}
@@ -98,7 +100,7 @@ main(int argc, char **argv)
 			++oneline;
 		} else if (matches(opt, "-timestamp") == 0) {
 			++timestamp;
-                } else if (matches(opt, "-family") == 0) {
+		} else if (matches(opt, "-family") == 0) {
 			argc--;
 			argv++;
 			if (argc <= 1)
@@ -122,13 +124,15 @@ main(int argc, char **argv)
 		} else if (matches(opt, "-compressvlans") == 0) {
 			++compress_vlans;
 		} else {
-			fprintf(stderr, "Option \"%s\" is unknown, try \"bridge help\".\n", opt);
+			fprintf(stderr,
+				"Option \"%s\" is unknown, try \"bridge help\".\n",
+				opt);
 			exit(-1);
 		}
 		argc--;	argv++;
 	}
 
-	_SL_ = oneline ? "\\" : "\n" ;
+	_SL_ = oneline ? "\\" : "\n";
 
 	if (rtnl_open(&rth, 0) < 0)
 		exit(1);
diff --git a/include/utils.h b/include/utils.h
index 1ee9343..22198cb 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -21,7 +21,7 @@ extern int resolve_hosts;
 extern int oneline;
 extern int timestamp;
 extern int timestamp_short;
-extern char * _SL_;
+extern const char * _SL_;
 extern int max_flush_loops;
 extern int batch_mode;
 extern bool do_all;
diff --git a/ip/ip.c b/ip/ip.c
index d6f1391..644e712 100644
--- a/ip/ip.c
+++ b/ip/ip.c
@@ -25,18 +25,18 @@
 #include "namespace.h"
 
 int preferred_family = AF_UNSPEC;
-int human_readable = 0;
-int use_iec = 0;
-int show_stats = 0;
-int show_details = 0;
-int resolve_hosts = 0;
-int oneline = 0;
-int timestamp = 0;
-char * _SL_ = NULL;
-int force = 0;
+int human_readable;
+int use_iec;
+int show_stats;
+int show_details;
+int resolve_hosts;
+int oneline;
+int timestamp;
+const char *_SL_;
+int force;
 int max_flush_loops = 10;
-int batch_mode = 0;
-bool do_all = false;
+int batch_mode;
+bool do_all;
 
 struct rtnl_handle rth = { .fd = -1 };
 
@@ -63,7 +63,7 @@ static void usage(void)
 static int do_help(int argc, char **argv)
 {
 	usage();
-        return 0;
+	return 0;
 }
 
 static const struct cmd {
@@ -88,7 +88,7 @@ static const struct cmd {
 	{ "tap",	do_iptuntap },
 	{ "token",	do_iptoken },
 	{ "tcpmetrics",	do_tcp_metrics },
-	{ "tcp_metrics",do_tcp_metrics },
+	{ "tcp_metrics", do_tcp_metrics },
 	{ "monitor",	do_ipmonitor },
 	{ "xfrm",	do_xfrm },
 	{ "mroute",	do_multiroute },
@@ -104,9 +104,8 @@ static int do_cmd(const char *argv0, int argc, char **argv)
 	const struct cmd *c;
 
 	for (c = cmds; c->cmd; ++c) {
-		if (matches(argv0, c->cmd) == 0) {
+		if (matches(argv0, c->cmd) == 0)
 			return -(c->func(argc-1, argv+1));
-		}
 	}
 
 	fprintf(stderr, "Object \"%s\" is unknown, try \"ip help\".\n", argv0);
@@ -123,7 +122,8 @@ static int batch(const char *name)
 
 	if (name && strcmp(name, "-") != 0) {
 		if (freopen(name, "r", stdin) == NULL) {
-			fprintf(stderr, "Cannot open file \"%s\" for reading: %s\n",
+			fprintf(stderr,
+				"Cannot open file \"%s\" for reading: %s\n",
 				name, strerror(errno));
 			return EXIT_FAILURE;
 		}
@@ -144,7 +144,8 @@ static int batch(const char *name)
 			continue;	/* blank line */
 
 		if (do_cmd(largv[0], largc, largv)) {
-			fprintf(stderr, "Command failed %s:%d\n", name, cmdlineno);
+			fprintf(stderr, "Command failed %s:%d\n",
+				name, cmdlineno);
 			ret = EXIT_FAILURE;
 			if (!force)
 				break;
@@ -171,7 +172,8 @@ int main(int argc, char **argv)
 
 	while (argc > 1) {
 		char *opt = argv[1];
-		if (strcmp(opt,"--") == 0) {
+
+		if (strcmp(opt, "--") == 0) {
 			argc--; argv++;
 			break;
 		}
@@ -184,8 +186,8 @@ int main(int argc, char **argv)
 			argv++;
 			if (argc <= 1)
 				usage();
-                        max_flush_loops = atoi(argv[1]);
-                } else if (matches(opt, "-family") == 0) {
+			max_flush_loops = atoi(argv[1]);
+		} else if (matches(opt, "-family") == 0) {
 			argc--;
 			argv++;
 			if (argc <= 1)
@@ -264,13 +266,15 @@ int main(int argc, char **argv)
 		} else if (matches(opt, "-all") == 0) {
 			do_all = true;
 		} else {
-			fprintf(stderr, "Option \"%s\" is unknown, try \"ip -help\".\n", opt);
+			fprintf(stderr,
+				"Option \"%s\" is unknown, try \"ip -help\".\n",
+				opt);
 			exit(-1);
 		}
 		argc--;	argv++;
 	}
 
-	_SL_ = oneline ? "\\" : "\n" ;
+	_SL_ = oneline ? "\\" : "\n";
 
 	if (batch_file)
 		return batch(batch_file);
-- 
1.8.3.1