[klibc] [PATCH 3/4] nfsmount: various checkpatch fixes

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


fix:
ERROR: "foo * bar" should be "foo *bar"

ERROR: do not use assignment in if condition
..

ERROR: space required before that '!' (ctx:VxW)

ERROR: space prohibited after that '!' (ctx:VxW)

WARNING: suspect code indent for conditional statements (16, 18)

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

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

WARNING: labels should not be indented
..

Signed-off-by: maximilian attems <max at stro.at>
---
 usr/kinit/nfsmount/dummypmap.c |    2 +-
 usr/kinit/nfsmount/main.c      |   17 ++++++++-----
 usr/kinit/nfsmount/mount.c     |   48 +++++++++++++++------------------------
 usr/kinit/nfsmount/portmap.c   |   10 ++++----
 4 files changed, 35 insertions(+), 42 deletions(-)

diff --git a/usr/kinit/nfsmount/dummypmap.c b/usr/kinit/nfsmount/dummypmap.c
index e5ebef9..7c5b6bc 100644
--- a/usr/kinit/nfsmount/dummypmap.c
+++ b/usr/kinit/nfsmount/dummypmap.c
@@ -71,7 +71,7 @@ static const char *protoname(uint32_t proto)
 	}
 }
 
-static void * get_auth(struct rpc_auth *auth)
+static void *get_auth(struct rpc_auth *auth)
 {
 	switch (ntohl(auth->flavor)) {
 	case AUTH_NULL:
diff --git a/usr/kinit/nfsmount/main.c b/usr/kinit/nfsmount/main.c
index b85901a..36b29a5 100644
--- a/usr/kinit/nfsmount/main.c
+++ b/usr/kinit/nfsmount/main.c
@@ -102,7 +102,8 @@ static void parse_opts(char *opts)
 	while ((cp = strsep(&opts, ",")) != NULL) {
 		if (*cp == '\0')
 			continue;
-		if ((val = strchr(cp, '=')) != NULL) {
+		val = strchr(cp, '=');
+		if (val != NULL) {
 			struct int_opts *opts = int_opts;
 			*val++ = '\0';
 			while (opts->name && strcmp(opts->name, cp) != 0)
@@ -207,12 +208,14 @@ int nfsmount_main(int argc, char *argv[])
 
 	hostname = rem_path = argv[optind];
 
-	if ((rem_name = strdup(rem_path)) == NULL) {
+	rem_name = strdup(rem_path);
+	if (rem_name == NULL) {
 		perror("strdup");
 		return 1;
 	}
 
-	if ((rem_path = strchr(rem_path, ':')) == NULL) {
+	rem_path = strchr(rem_path, ':');
+	if (rem_path == NULL) {
 		fprintf(stderr, "%s: need a server\n", progname);
 		free(rem_name);
 		return 1;
@@ -235,7 +238,7 @@ int nfsmount_main(int argc, char *argv[])
 
 	check_path(path);
 
-#if! _KLIBC_NO_MMU
+#if !_KLIBC_NO_MMU
 	/* Note: uClinux can't fork(), so the spoof portmapper is not
 	   available on uClinux. */
 	if (portmap_file)
@@ -255,9 +258,9 @@ int nfsmount_main(int argc, char *argv[])
 	/* If we set up the spoofer, tear it down now */
 	if (spoof_portmap) {
 		kill(spoof_portmap, SIGTERM);
-		while (waitpid(spoof_portmap, NULL, 0) == -1 &&
-		       errno == EINTR)
-		  ;
+		while (waitpid(spoof_portmap, NULL, 0) == -1
+		       && errno == EINTR)
+			;
 	}
 
 	free(rem_name);
diff --git a/usr/kinit/nfsmount/mount.c b/usr/kinit/nfsmount/mount.c
index d0eca8a..e3838f4 100644
--- a/usr/kinit/nfsmount/mount.c
+++ b/usr/kinit/nfsmount/mount.c
@@ -155,7 +155,8 @@ static int mount_call(uint32_t proc, uint32_t version,
 	path_len = strlen(path);
 	call_len = sizeof(*mnt_call) + pad_len(path_len);
 
-	if ((mnt_call = malloc(call_len)) == NULL) {
+	mnt_call = malloc(call_len);
+	if (mnt_call == NULL) {
 		perror("malloc");
 		goto bail;
 	}
@@ -176,9 +177,8 @@ static int mount_call(uint32_t proc, uint32_t version,
 	if (rpc_call(clnt, &rpc) < 0)
 		goto bail;
 
-	if (proc != MNTPROC_MNT) {
+	if (proc != MNTPROC_MNT)
 		goto done;
-	}
 
 	if (rpc.reply_len < MNT_REPLY_MINSIZE) {
 		fprintf(stderr, "incomplete reply: %zu < %zu\n",
@@ -198,9 +198,8 @@ bail:
 	ret = -1;
 
 done:
-	if (mnt_call) {
+	if (mnt_call)
 		free(mnt_call);
-	}
 
 	return ret;
 }
@@ -262,38 +261,32 @@ int nfs_mount(const char *pathname, const char *hostname,
 	int ret = 0;
 	int mountflags;
 
-	if (get_ports(server, data) != 0) {
+	if (get_ports(server, data) != 0)
 		goto bail;
-	}
 
 	dump_params(server, rem_path, data);
 
-	if (data->flags & NFS_MOUNT_TCP) {
+	if (data->flags & NFS_MOUNT_TCP)
 		clnt = tcp_client(server, mount_port, CLI_RESVPORT);
-	} else {
+	else
 		clnt = udp_client(server, mount_port, CLI_RESVPORT);
-	}
 
-	if (clnt == NULL) {
+	if (clnt == NULL)
 		goto bail;
-	}
 
-	if (data->flags & NFS_MOUNT_VER3) {
+	if (data->flags & NFS_MOUNT_VER3)
 		ret = mount_v3(rem_path, data, clnt);
-	} else {
+	else
 		ret = mount_v2(rem_path, data, clnt);
-	}
 
-	if (ret == -1) {
+	if (ret == -1)
 		goto bail;
-	}
 	mounted = 1;
 
-	if (data->flags & NFS_MOUNT_TCP) {
+	if (data->flags & NFS_MOUNT_TCP)
 		sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
-	} else {
+	else
 		sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
-	}
 
 	if (sock == -1) {
 		perror("socket");
@@ -333,25 +326,22 @@ int nfs_mount(const char *pathname, const char *hostname,
 
 	goto done;
 
-      bail:
+bail:
 	if (mounted) {
-		if (data->flags & NFS_MOUNT_VER3) {
+		if (data->flags & NFS_MOUNT_VER3)
 			umount_v3(path, clnt);
-		} else {
+		else
 			umount_v2(path, clnt);
-		}
 	}
 
 	ret = -1;
 
-      done:
-	if (clnt) {
+done:
+	if (clnt)
 		client_free(clnt);
-	}
 
-	if (sock != -1) {
+	if (sock != -1)
 		close(sock);
-	}
 
 	return ret;
 }
diff --git a/usr/kinit/nfsmount/portmap.c b/usr/kinit/nfsmount/portmap.c
index ff79d04..0a3e2d0 100644
--- a/usr/kinit/nfsmount/portmap.c
+++ b/usr/kinit/nfsmount/portmap.c
@@ -35,10 +35,11 @@ uint32_t portmap(uint32_t server, uint32_t program, uint32_t version, uint32_t p
 	struct rpc rpc;
 	uint32_t port = 0;
 
-	if ((clnt = tcp_client(server, RPC_PMAP_PORT, 0)) == NULL) {
-		if ((clnt = udp_client(server, RPC_PMAP_PORT, 0)) == NULL) {
+	clnt = tcp_client(server, RPC_PMAP_PORT, 0);
+	if (clnt == NULL) {
+		clnt = udp_client(server, RPC_PMAP_PORT, 0);
+		if (clnt == NULL)
 			goto bail;
-		}
 	}
 
 	call.program = htonl(program);
@@ -65,9 +66,8 @@ bail:
 	dprintf("Port for %d/%d[%s]: %d\n", program, version,
 		proto == IPPROTO_TCP ? "tcp" : "udp", port);
 
-	if (clnt) {
+	if (clnt)
 		client_free(clnt);
-	}
 
 	return port;
 }
-- 
1.7.5.4



More information about the klibc mailing list