diff options
author | NeilBrown <neilb@suse.com> | 2016-12-06 11:27:21 -0500 |
---|---|---|
committer | Steve Dickson <steved@redhat.com> | 2016-12-06 11:27:21 -0500 |
commit | 29aced680a423e6d97cab4faaae81c3e77eb5fc3 (patch) | |
tree | 4ec845d0a536302f9a94a88e1bb421d97d181814 | |
parent | fc1127d754578cd1dc3b52aebce1d5ae09f2d347 (diff) | |
download | nfs-utils-29aced680a423e6d97cab4faaae81c3e77eb5fc3.tar.gz |
Remove error messages on xstrdup failure.
xstrdup() prints a messages and exits, except in statd where
is prints a message and fails. So there is no point printing
an extra message when xstrdup() fails, and except in statd,
no point calling exit() as well.
So remove some pointless code.
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Steve Dickson <steved@redhat.com>
-rw-r--r-- | utils/mountd/mountd.c | 6 | ||||
-rw-r--r-- | utils/nfsd/nfsd.c | 35 | ||||
-rw-r--r-- | utils/nfsidmap/nfsidmap.c | 7 | ||||
-rw-r--r-- | utils/statd/statd.c | 5 |
4 files changed, 10 insertions, 43 deletions
diff --git a/utils/mountd/mountd.c b/utils/mountd/mountd.c index a0ab293..d6cebbb 100644 --- a/utils/mountd/mountd.c +++ b/utils/mountd/mountd.c @@ -721,11 +721,7 @@ main(int argc, char **argv) reverse_resolve = 1; break; case 's': - if ((state_dir = xstrdup(optarg)) == NULL) { - fprintf(stderr, "%s: xstrdup(%s) failed!\n", - progname, optarg); - exit(1); - } + state_dir = xstrdup(optarg); break; case 't': num_threads = atoi (optarg); diff --git a/utils/nfsd/nfsd.c b/utils/nfsd/nfsd.c index 7b5e67a..9a65877 100644 --- a/utils/nfsd/nfsd.c +++ b/utils/nfsd/nfsd.c @@ -27,6 +27,7 @@ #include "nfslib.h" #include "nfssvc.h" #include "xlog.h" +#include "xcommon.h" #ifndef NFSD_NPROC #define NFSD_NPROC 8 @@ -67,23 +68,9 @@ main(int argc, char **argv) int grace = -1; int lease = -1; - progname = strdup(basename(argv[0])); - if (!progname) { - fprintf(stderr, "%s: unable to allocate memory.\n", argv[0]); - exit(1); - } - - port = strdup("nfs"); - if (!port) { - fprintf(stderr, "%s: unable to allocate memory.\n", progname); - exit(1); - } - - haddr = malloc(sizeof(char *)); - if (!haddr) { - fprintf(stderr, "%s: unable to allocate memory.\n", progname); - exit(1); - } + progname = xstrdup(basename(argv[0])); + port = xstrdup("nfs"); + haddr = xmalloc(sizeof(char *)); haddr[0] = NULL; xlog_syslog(0); @@ -103,12 +90,7 @@ main(int argc, char **argv) exit(1); } } - haddr[hcounter] = strdup(optarg); - if (!haddr[hcounter]) { - fprintf(stderr, "%s: unable to allocate " - "memory.\n", progname); - exit(1); - } + haddr[hcounter] = xstrdup(optarg); hcounter++; break; case 'P': /* XXX for nfs-server compatibility */ @@ -121,12 +103,7 @@ main(int argc, char **argv) usage(progname); } free(port); - port = strdup(optarg); - if (!port) { - fprintf(stderr, "%s: unable to allocate " - "memory.\n", progname); - exit(1); - } + port = xstrdup(optarg); break; case 'r': rdma_port = "nfsrdma"; diff --git a/utils/nfsidmap/nfsidmap.c b/utils/nfsidmap/nfsidmap.c index 63545fc..374bc5d 100644 --- a/utils/nfsidmap/nfsidmap.c +++ b/utils/nfsidmap/nfsidmap.c @@ -15,6 +15,7 @@ #include <unistd.h> #include "xlog.h" #include "conffile.h" +#include "xcommon.h" int verbose = 0; char *usage = "Usage: %s [-vh] [-c || [-u|-g|-r key] || -d || -l || [-t timeout] key desc]"; @@ -441,11 +442,7 @@ int main(int argc, char **argv) key = strtol(argv[optind++], NULL, 10); - arg = strdup(argv[optind]); - if (arg == NULL) { - xlog_err("strdup failed: %m"); - return EXIT_FAILURE; - } + arg = xstrdup(argv[optind]); type = strtok(arg, ":"); value = strtok(NULL, ":"); if (value == NULL) { diff --git a/utils/statd/statd.c b/utils/statd/statd.c index e5b4c98..15f2b18 100644 --- a/utils/statd/statd.c +++ b/utils/statd/statd.c @@ -332,11 +332,8 @@ int main (int argc, char **argv) exit(1); break; case 'H': /* PRC: specify the ha-callout program */ - if ((ha_callout_prog = xstrdup(optarg)) == NULL) { - fprintf(stderr, "%s: xstrdup(%s) failed!\n", - argv[0], optarg); + if ((ha_callout_prog = xstrdup(optarg)) == NULL) exit(1); - } break; case '?': /* heeeeeelllllllpppp? heh */ case 'h': |