[02/10] nfsd: remove pointless memory allocations.
diff mbox

Message ID 148117124466.31271.5520473899286758519.stgit@noble
State New
Headers show

Commit Message

NeilBrown Dec. 8, 2016, 4:27 a.m. UTC
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>
---
 utils/nfsd/nfsd.c |   13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)



--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/utils/nfsd/nfsd.c b/utils/nfsd/nfsd.c
index 89179be76113..d8f873ba3717 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);
 }