public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Steve Dickson <SteveD@redhat.com>
To: Jim Rees <rees@umich.edu>
Cc: Linux NFS Mailing List <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH 2/2] nfsidmap: Added -v and -t flags
Date: Mon, 14 Nov 2011 10:06:55 -0500	[thread overview]
Message-ID: <4EC12E8F.3000109@RedHat.com> (raw)
In-Reply-To: <20111112191526.GB25581@umich.edu>



On 11/12/2011 02:15 PM, Jim Rees wrote:
> Steve Dickson wrote:
> 
>   +	arg = malloc(sizeof(char) * strlen(argv[optind]) + 1);
>   +	strcpy(arg, argv[optind]);
> 
> strdup() would have been simpler.  But don't re-do it just for this.
We should also be checking for failure as well... Here's how I took care of it:

-       arg = malloc(sizeof(char) * strlen(argv[2]) + 1);
-       strcpy(arg, argv[2]);
+       if (verbose)
+               nfs4_set_debug(verbose, NULL);
+
+       key = strtol(argv[optind++], NULL, 10);
+
+       arg = strdup(argv[optind]);
+       if (arg == NULL) {
+               xlog_err("strdup failed: %m");
+               return 1;
+       }

steved.

  reply	other threads:[~2011-11-14 15:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-12 15:55 [PATCH 0/2] Added error logging and verbosity flag (ver #2) Steve Dickson
2011-11-12 15:55 ` [PATCH 1/2] nfsidmap: Added Error Logging Steve Dickson
2011-11-12 15:55 ` [PATCH 2/2] nfsidmap: Added -v and -t flags Steve Dickson
2011-11-12 19:15   ` Jim Rees
2011-11-14 15:06     ` Steve Dickson [this message]
2011-11-14 21:12 ` [PATCH 0/2] Added error logging and verbosity flag (ver #2) Steve Dickson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4EC12E8F.3000109@RedHat.com \
    --to=steved@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=rees@umich.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox