From patchwork Thu Dec 8 04:27:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 9465759 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6A22C60459 for ; Thu, 8 Dec 2016 04:28:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 519BF283FF for ; Thu, 8 Dec 2016 04:28:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4680F28415; Thu, 8 Dec 2016 04:28:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFB1A283FF for ; Thu, 8 Dec 2016 04:27:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752797AbcLHE17 (ORCPT ); Wed, 7 Dec 2016 23:27:59 -0500 Received: from mx2.suse.de ([195.135.220.15]:43941 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751091AbcLHE16 (ORCPT ); Wed, 7 Dec 2016 23:27:58 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 9B678AAC8; Thu, 8 Dec 2016 04:27:57 +0000 (UTC) From: NeilBrown To: "J. Bruce Fields" , Steve Dickson Date: Thu, 08 Dec 2016 15:27:24 +1100 Subject: [PATCH 02/10] nfsd: remove pointless memory allocations. Cc: linux-nfs@vger.kernel.org Message-ID: <148117124466.31271.5520473899286758519.stgit@noble> In-Reply-To: <148117122602.31271.13586847542442809540.stgit@noble> References: <148117122602.31271.13586847542442809540.stgit@noble> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There is not need to e.g. strdup(optarg), and the value is constant. It can just be used directly. Signed-off-by: NeilBrown --- 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 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); }