summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2016-12-17 12:28:04 -0500
committerSteve Dickson <steved@redhat.com>2016-12-20 13:29:04 -0500
commit50cb92f9da522a59442b4c34b7615a7baddb1e66 (patch)
tree9a6a9522260e6b6e3be61700ee3ecd606a25cfa9
parent1717330ffe1831166f73f8b25b1d7d3b9a49b8c6 (diff)
downloadnfs-utils-50cb92f9da522a59442b4c34b7615a7baddb1e66.tar.gz
nfs-utils-50cb92f9da522a59442b4c34b7615a7baddb1e66.tar.xz
nfs-utils-50cb92f9da522a59442b4c34b7615a7baddb1e66.zip
nfsd: remove pointless memory allocations.
There is not need to e.g. strdup(optarg), and the value is constant. It can just be used directly. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r--utils/nfsd/nfsd.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/utils/nfsd/nfsd.c b/utils/nfsd/nfsd.c
index 89179be..d8f873b 100644
--- a/utils/nfsd/nfsd.c
+++ b/utils/nfsd/nfsd.c
@@ -71,8 +71,8 @@ main(int argc, char **argv)
int grace = -1;
int lease = -1;
- progname = xstrdup(basename(argv[0]));
- port = xstrdup("nfs");
+ progname = basename(argv[0]);
+ port = "nfs";
haddr = xmalloc(sizeof(char *));
haddr[0] = NULL;
@@ -126,14 +126,13 @@ main(int argc, char **argv)
exit(1);
}
}
- haddr[hcounter] = xstrdup(optarg);
+ haddr[hcounter] = optarg;
hcounter++;
break;
case 'P': /* XXX for nfs-server compatibility */
case 'p':
/* only the last -p option has any effect */
- free(port);
- port = xstrdup(optarg);
+ port = optarg;
break;
case 'r':
rdma_port = "nfsrdma";
@@ -334,11 +333,7 @@ set_threads:
if ((error = nfssvc_threads(count)) < 0)
xlog(L_ERROR, "error starting threads: errno %d (%m)", errno);
out:
- free(port);
- for(i=0; i < hcounter; i++)
- free(haddr[i]);
free(haddr);
- free(progname);
return (error != 0);
}