X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fopenfile.c;h=c98313e1a0f36ef4dac06b98cf99c1942ab61fe7;hb=36fcb2c26ec411cf83f4a9a3c86dbc417c854e7c;hp=96cef6cbfe03e0a9da69f6c25dfbdb4c754731cf;hpb=72057a3af19ee02d9a686bd7e7d074917e381310;p=fs%2Flustre-release.git diff --git a/lustre/tests/openfile.c b/lustre/tests/openfile.c index 96cef6c..c98313e 100644 --- a/lustre/tests/openfile.c +++ b/lustre/tests/openfile.c @@ -45,7 +45,7 @@ #include #include #include -#include +#include typedef struct flag_mapping { const char *string; @@ -100,16 +100,15 @@ int main(int argc, char** argv) while ((c = getopt (argc, argv, "f:m:")) != -1) { switch (c) { case 'f': { - char *tmp; + char *tmp; - cloned_flags = (char *)malloc(strlen(optarg)+1); - if (cloned_flags == NULL) { - fprintf(stderr, "Insufficient memory.\n"); - save_errno = -1; - goto out; - } + cloned_flags = strdup(optarg); + if (cloned_flags == NULL) { + fprintf(stderr, "Insufficient memory.\n"); + save_errno = -1; + goto out; + } - strncpy(cloned_flags, optarg, strlen(optarg)+1); flags = atoi(cloned_flags); if (flags > 0) { flag_set = 1;