[klibc] [PATCH 1/4] ipconfig: reduce checkpatch noise

maximilian attems max at stro.at
Fri Jul 8 04:28:39 PDT 2011


fix for better codingstyle:
ERROR: "foo * bar" should be "foo *bar"
..

ERROR: switch and case should be at the same indent

WARNING: braces {} are not necessary for single statement blocks

WARNING: labels should not be indented
..

WARNING: braces {} are not necessary for any arm of this statement
..

ERROR: do not use assignment in if condition

ERROR: space prohibited after that '&' (ctx:WxW)

Signed-off-by: maximilian attems <max at stro.at>
---
 usr/kinit/ipconfig/dhcp_proto.c |    2 +-
 usr/kinit/ipconfig/main.c       |   42 ++++++++++++++++++--------------------
 usr/kinit/ipconfig/packet.c     |    4 +-
 3 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/usr/kinit/ipconfig/dhcp_proto.c b/usr/kinit/ipconfig/dhcp_proto.c
index 993db52..afd2eca 100644
--- a/usr/kinit/ipconfig/dhcp_proto.c
+++ b/usr/kinit/ipconfig/dhcp_proto.c
@@ -80,7 +80,7 @@ static struct iovec dhcp_request_iov[DHCP_IOV_LEN] = {
  * 6 = DHCPNACK
  */
 static int dhcp_parse(struct netdev *dev, struct bootp_hdr *hdr,
-		      uint8_t * exts, int extlen)
+		      uint8_t *exts, int extlen)
 {
 	uint8_t type = 0;
 	uint32_t serverid = INADDR_NONE;
diff --git a/usr/kinit/ipconfig/main.c b/usr/kinit/ipconfig/main.c
index 8dc6cbe..8782ae7 100644
--- a/usr/kinit/ipconfig/main.c
+++ b/usr/kinit/ipconfig/main.c
@@ -100,19 +100,19 @@ static void configure_device(struct netdev *dev)
  * Always start with a single quote ('), then leave all characters
  * except ' and ! unchanged.
  */
-static void write_option(FILE* f, const char* name, const char* chr)
+static void write_option(FILE *f, const char *name, const char *chr)
 {
 
 	fprintf(f, "%s='", name);
 	while (*chr) {
 		switch (*chr) {
-			case '!':
-			case '\'':
-				fprintf(f, "'\\%c'", *chr);
-				break;
-			default:
-				fprintf(f, "%c", *chr);
-				break;
+		case '!':
+		case '\'':
+			fprintf(f, "'\\%c'", *chr);
+			break;
+		default:
+			fprintf(f, "%c", *chr);
+			break;
 		}
 		++chr;
 	}
@@ -341,9 +341,8 @@ static int do_pkt_recv(int pkt_fd, time_t now)
 	int ret = 0;
 	struct state *s;
 
-	for (s = slist; s; s = s->next) {
+	for (s = slist; s; s = s->next)
 		ret |= process_receive_event(s, now);
-	}
 	return ret;
 }
 
@@ -430,7 +429,7 @@ static int loop(void)
 			timeout_ms -= delta_ms;
 		}
 	}
-      bail:
+bail:
 	packet_close();
 
 	return rc;
@@ -451,13 +450,12 @@ static int add_one_dev(struct netdev *dev)
 	/*
 	 * Select the state that we start from.
 	 */
-	if (dev->caps & CAP_DHCP && dev->ip_addr == INADDR_ANY) {
+	if (dev->caps & CAP_DHCP && dev->ip_addr == INADDR_ANY)
 		state->restart_state = state->state = DEVST_DHCPDISC;
-	} else if (dev->caps & CAP_DHCP) {
+	else if (dev->caps & CAP_DHCP)
 		state->restart_state = state->state = DEVST_DHCPREQ;
-	} else if (dev->caps & CAP_BOOTP) {
+	else if (dev->caps & CAP_BOOTP)
 		state->restart_state = state->state = DEVST_BOOTP;
-	}
 
 	state->next = slist;
 	slist = state;
@@ -465,7 +463,7 @@ static int add_one_dev(struct netdev *dev)
 	return 0;
 }
 
-static void parse_addr(uint32_t * addr, const char *ip)
+static void parse_addr(uint32_t *addr, const char *ip)
 {
 	struct in_addr in;
 	if (inet_aton(ip, &in) == 0) {
@@ -497,7 +495,7 @@ static unsigned int parse_proto(const char *ip)
 		fprintf(stderr, "%s: invalid protocol '%s'\n", progname, ip);
 		longjmp(abort_buf, 1);
 	}
-      bail:
+bail:
 	return caps;
 }
 
@@ -584,11 +582,10 @@ static int parse_device(struct netdev *dev, const char *ip)
 static void bringup_device(struct netdev *dev)
 {
 	if (netdev_up(dev) == 0) {
-		if (dev->caps) {
+		if (dev->caps)
 			add_one_dev(dev);
-		} else {
+		else
 			complete_device(dev);
-		}
 	}
 }
 
@@ -646,7 +643,7 @@ static struct netdev *add_device(const char *info)
 	       dev->caps & CAP_BOOTP ? " BOOTP" : "",
 	       dev->caps & CAP_RARP ? " RARP" : "");
 	return dev;
-      bail:
+bail:
 	free(dev);
 	return NULL;
 }
@@ -694,7 +691,8 @@ static int add_all_devices(struct netdev *template)
 		    (flags & (IFF_BROADCAST | IFF_POINTOPOINT))) {
 			dprintf("Trying to bring up %s\n", de->d_name);
 
-			if (!(dev = add_device(de->d_name)))
+			dev = add_device(de->d_name);
+			if (!dev)
 				continue;
 			bringup_one_dev(template, dev);
 		}
diff --git a/usr/kinit/ipconfig/packet.c b/usr/kinit/ipconfig/packet.c
index ea5a25d..446073a 100644
--- a/usr/kinit/ipconfig/packet.c
+++ b/usr/kinit/ipconfig/packet.c
@@ -156,7 +156,7 @@ int packet_send(struct netdev *dev, struct iovec *iov, int iov_len)
 
 	ipudp_hdrs.ip.tot_len = htons(len);
 	ipudp_hdrs.ip.check   = 0;
-	ipudp_hdrs.ip.check   = ip_checksum((uint16_t *) & ipudp_hdrs.ip,
+	ipudp_hdrs.ip.check   = ip_checksum((uint16_t *) &ipudp_hdrs.ip,
 					    ipudp_hdrs.ip.ihl);
 
 	ipudp_hdrs.udp.len    = htons(len - sizeof(struct iphdr));
@@ -186,7 +186,7 @@ void packet_discard(struct netdev *dev)
 *   0 = Discarded packet (non-DHCP/BOOTP traffic)
  * >0 = Size of packet
  */
-int packet_recv(struct netdev* dev, struct iovec *iov, int iov_len)
+int packet_recv(struct netdev *dev, struct iovec *iov, int iov_len)
 {
 	struct iphdr *ip, iph;
 	struct udphdr *udp;
-- 
1.7.5.4



More information about the klibc mailing list