@@ -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);
@@ -67,23 +67,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 +89,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 +102,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";
@@ -441,11 +441,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) {
@@ -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':
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> --- utils/mountd/mountd.c | 6 +----- utils/nfsd/nfsd.c | 34 +++++----------------------------- utils/nfsidmap/nfsidmap.c | 6 +----- utils/statd/statd.c | 5 +---- 4 files changed, 8 insertions(+), 43 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