ucrtbase: Fix _Syserror_map behavior on unknown error.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=50407
Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2021-02-02 18:13:11 +01:00 committed by Alexandre Julliard
parent d24ce1374c
commit b54ab691a7
3 changed files with 33 additions and 0 deletions

View File

@ -216,6 +216,7 @@ static void (CDECL *p__Do_call)(void *this);
static short (__cdecl *p__Dtest)(double *d);
static short (__cdecl *p__Dscale)(double *d, int exp);
static short (__cdecl *p__FExp)(float *x, float y, int exp);
static const char* (__cdecl *p__Syserror_map)(int err);
/* filesystem */
static ULONGLONG(__cdecl *p_tr2_sys__File_size)(char const*);
@ -575,6 +576,8 @@ static BOOL init(void)
"?_Internal_reserve@_Concurrent_vector_base_v4@details@Concurrency@@IEAAX_K00@Z");
SET(p_vector_base_v4__Internal_resize,
"?_Internal_resize@_Concurrent_vector_base_v4@details@Concurrency@@IEAAX_K00P6AXPEAX0@ZP6AX1PEBX0@Z3@Z");
SET(p__Syserror_map,
"?_Syserror_map@std@@YAPEBDH@Z");
} else {
SET(p_tr2_sys__File_size,
"?_File_size@sys@tr2@std@@YA_KPBD@Z");
@ -648,6 +651,8 @@ static BOOL init(void)
"?_Mtx_unlock@threads@stdext@@YAXPAX@Z");
SET(p_vector_base_v4__Segment_index_of,
"?_Segment_index_of@_Concurrent_vector_base_v4@details@Concurrency@@KAII@Z");
SET(p__Syserror_map,
"?_Syserror_map@std@@YAPBDH@Z");
#ifdef __i386__
SET(p_i386_Thrd_current,
"_Thrd_current");
@ -1170,6 +1175,14 @@ static void test__FExp(void)
ok(ret == FP_NORMAL, "ret = %x\n", ret);
}
static void test__Syserror_map(void)
{
const char *r;
r = p__Syserror_map(0);
ok(!r, "_Syserror_map(0) returned %p\n", r);
}
static void test_tr2_sys__File_size(void)
{
ULONGLONG val;
@ -3306,6 +3319,7 @@ START_TEST(msvcp120)
test__Dtest();
test__Dscale();
test__FExp();
test__Syserror_map();
test_tr2_sys__File_size();
test_tr2_sys__Equivalent();

View File

@ -196,6 +196,7 @@ static int (__cdecl *p_To_wide)(const char *src, WCHAR *dst);
static int (__cdecl *p_Unlink)(WCHAR const*);
static ULONG (__cdecl *p__Winerror_message)(ULONG, char*, ULONG);
static int (__cdecl *p__Winerror_map)(int);
static const char* (__cdecl *p__Syserror_map)(int err);
static BOOLEAN (WINAPI *pCreateSymbolicLinkW)(const WCHAR *, const WCHAR *, DWORD);
@ -234,6 +235,7 @@ static BOOL init(void)
SET(p__Reschedule_chore, "?_Reschedule_chore@details@Concurrency@@YAHPEBU_Threadpool_chore@12@@Z");
SET(p__Release_chore, "?_Release_chore@details@Concurrency@@YAXPEAU_Threadpool_chore@12@@Z");
SET(p__Winerror_message, "?_Winerror_message@std@@YAKKPEADK@Z");
SET(p__Syserror_map, "?_Syserror_map@std@@YAPEBDH@Z");
} else {
#ifdef __arm__
SET(p_task_continuation_context_ctor, "??0task_continuation_context@Concurrency@@AAA@XZ");
@ -264,6 +266,7 @@ static BOOL init(void)
SET(p__Reschedule_chore, "?_Reschedule_chore@details@Concurrency@@YAHPBU_Threadpool_chore@12@@Z");
SET(p__Release_chore, "?_Release_chore@details@Concurrency@@YAXPAU_Threadpool_chore@12@@Z");
SET(p__Winerror_message, "?_Winerror_message@std@@YAKKPADK@Z");
SET(p__Syserror_map, "?_Syserror_map@std@@YAPBDH@Z");
}
SET(p_Close_dir, "_Close_dir");
@ -1314,6 +1317,17 @@ static void test__Winerror_map(void)
}
}
static void test__Syserror_map(void)
{
const char *r1, *r2;
r1 = p__Syserror_map(0);
ok(r1 != NULL, "_Syserror_map(0) returned NULL\n");
r2 = p__Syserror_map(1234);
ok(r2 != NULL, "_Syserror_map(1234) returned NULL\n");
ok(r1 == r2, "r1 = %p(%s), r2 = %p(%s)\n", r1, r1, r2, r2);
}
static void test_Equivalent(void)
{
int val, i;
@ -1391,6 +1405,7 @@ START_TEST(msvcp140)
test_Last_write_time();
test__Winerror_message();
test__Winerror_map();
test__Syserror_map();
test_Equivalent();
FreeLibrary(msvcp);
}

View File

@ -2864,7 +2864,11 @@ const char* __cdecl _Syserror_map(int err)
if(syserror_map[i].err == err)
return syserror_map[i].str;
}
#if _MSVCP_VER >= 140
return "unknown error";
#else
return NULL;
#endif
}
#endif