diff options
author | maximilian attems <max@stro.at> | 2011-07-07 18:22:31 +0200 |
---|---|---|
committer | maximilian attems <max@stro.at> | 2011-07-08 13:27:09 +0200 |
commit | 9c4561efb4ce645f212075f07e1e61faf7ee96f0 (patch) | |
tree | 6fcd1babe7ce1a1db9af8a09fa1a95c5fcf20860 | |
parent | 68b0eb236321e8ffe3618db1e1443c46d047862d (diff) | |
download | klibc-9c4561efb4ce645f212075f07e1e61faf7ee96f0.tar.gz |
[klibc] nfsmount: various checkpatch fixes
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@stro.at>
-rw-r--r-- | usr/kinit/nfsmount/dummypmap.c | 2 | ||||
-rw-r--r-- | usr/kinit/nfsmount/main.c | 17 | ||||
-rw-r--r-- | usr/kinit/nfsmount/mount.c | 48 | ||||
-rw-r--r-- | 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 e5ebef972d75d..7c5b6bcd64ce3 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 b85901af8bcce..36b29a5f9805f 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 d0eca8a9ea019..e3838f4d11297 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 ff79d042621fe..0a3e2d0414615 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; } |