eal/windows: use bundled getopt with MinGW
authorDmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Thu, 24 Sep 2020 23:17:07 +0000 (02:17 +0300)
committerThomas Monjalon <thomas@monjalon.net>
Mon, 5 Oct 2020 07:12:24 +0000 (09:12 +0200)
commitff5db45d476c8169cdb975aa5ac3d0a4cb8a16d2
tree969d26c7ffb660836195b18e708c4923b1ab37f9
parent4e1b5092ad1ce3e3bd66eb20a9976d027e424b0a
eal/windows: use bundled getopt with MinGW

Clang builds use getopt.c in librte_eal while MinGW provides
implementation as part of the toolchain. Statically linking librte_eal
to an application that depends on getopt results in undefined reference
errors with MinGW. There are no such errors with Clang, because with
Clang librte_eal actually defines getopt functions.

Use getopt.c in EAL with Clang and MinGW to get identical behavior.
Adjust code for MinGW. Incidentally, this removes a bug when free() is
called on uninitialized memory.

Fixes: 5e373e456e6 ("eal/windows: add getopt implementation")
Cc: stable@dpdk.org
Reported-by: Khoa To <khot@microsoft.com>
Reported-by: Tal Shnaiderman <talshn@nvidia.com>
Signed-off-by: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Acked-by: Khoa To <khot@microsoft.com>
Acked-by: Pallavi Kadam <pallavi.kadam@intel.com>
lib/librte_eal/meson.build
lib/librte_eal/windows/getopt.c