X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_eal%2Fwindows%2Fgetopt.c;h=a1f51c6c2318e847f99cc7d5eb0a633c47356c62;hb=56446c913f0a0c28fb1d734986942da122b1174a;hp=170c9b5e0c00d7c04f45ee0e34d4dc0d6b2a2dfd;hpb=a083f8cc77460c15ac99a427ab6833dc8c8ae5bc;p=dpdk.git diff --git a/lib/librte_eal/windows/getopt.c b/lib/librte_eal/windows/getopt.c index 170c9b5e0c..a1f51c6c23 100644 --- a/lib/librte_eal/windows/getopt.c +++ b/lib/librte_eal/windows/getopt.c @@ -25,8 +25,8 @@ int opterr = 1; /* if error message should be printed */ int optind = 1; /* index into parent argv vector */ int optopt = '?'; /* character checked for validity */ -static void pass(void) {} -#define warnx(a, ...) pass() +static void pass(const char *a) {(void) a; } +#define warnx(a, ...) pass(a) #define PRINT_ERROR ((opterr) && (*options != ':')) @@ -242,7 +242,6 @@ getopt_internal(int nargc, char **nargv, const char *options, char *oli; /* option letter list index */ int optchar, short_too; static int posixly_correct = -1; - char *buf; size_t len; int optreset = 0; @@ -253,16 +252,16 @@ getopt_internal(int nargc, char **nargv, const char *options, * Disable GNU extensions if POSIXLY_CORRECT is set or options * string begins with a '+'. */ - if (posixly_correct == -1) - posixly_correct = _dupenv_s(&buf, &len, "POSIXLY_CORRECT"); + if (posixly_correct == -1) { + errno_t err = _wgetenv_s(&len, NULL, 0, L"POSIXLY_CORRECT"); + posixly_correct = (err == 0) && (len > 0); + } if (!posixly_correct || *options == '+') flags &= ~FLAG_PERMUTE; else if (*options == '-') flags |= FLAG_ALLARGS; if (*options == '+' || *options == '-') options++; - if (!posixly_correct) - free(buf); /* * reset if requested */