mingw: load system libraries the recommended way

When we access IPv6-related functions, we load the corresponding system library using the `LoadLibrary()` function, which is not the recommended way to load system libraries. In practice, it does not make a difference: the `ws2_32.dll` library containing the IPv6 functions is already loaded into memory, so LoadLibrary() simply reuses the already-loaded library. Still, recommended way is recommended way, so let's use that instead. While at it, also adjust the code in contrib/ that loads system libraries. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Oct 23, 2018 at 03:51 UTC c6f050a4349339f812cdc3131ce104057424f492
2 files changed +4 -2
compat/mingw.c
+2 -1
@@ -1577,7 +1577,8 @@ static void ensure_socket_initialization(void)
1577 WSAGetLastError());
1578
1579 for (name = libraries; *name; name++) {
1580 - ipv6_dll = LoadLibrary(*name);
1580 + ipv6_dll = LoadLibraryExA(*name, NULL,
1581 + LOAD_LIBRARY_SEARCH_SYSTEM32);
1582 if (!ipv6_dll)
1583 continue;
1584
contrib/credential/wincred/git-credential-wincred.c
+2 -1
@@ -75,7 +75,8 @@ static CredDeleteWT CredDeleteW;
75 static void load_cred_funcs(void)
76 {
77 /* load DLLs */
78 - advapi = LoadLibrary("advapi32.dll");
78 + advapi = LoadLibraryExA("advapi32.dll", NULL,
79 + LOAD_LIBRARY_SEARCH_SYSTEM32);
80 if (!advapi)
81 die("failed to load advapi32.dll");
82