ac3e150f
by Arkadiusz Hiler at 2025-02-25T23:02:48+01:00
krnl386: Silence a warning in GetSystemDirectory16().
With GCC 14.2 on Debian 11:
$ i686-w64-mingw32-gcc --version
i686-w64-mingw32-gcc (GCC) 14.2.0
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
The following error happens:
In file included from ~/src/wine/dlls/krnl386.exe16/file.c:33:
In function 'lstrcpyA',
inlined from 'GetSystemDirectory16' at ~/src/wine/dlls/krnl386.exe16/file.c:648:9,
inlined from 'get_search_path' at ~/src/wine/dlls/krnl386.exe16/file.c:192:12:
~/src/wine/include/winbase.h:2939:12: error: argument 1 null where non-null expected [-Werror=nonnull]
2939 | return strcpy( dst, src );
| ^~~~~~~~~~~~~~~~~~
In file included from ~/src/wine/dlls/krnl386.exe16/file.c:28:
~/src/wine/include/msvcrt/string.h: In function 'get_search_path':
~/src/wine/include/msvcrt/string.h:53:26: note: in a call to function 'strcpy' declared 'nonnull'
53 | _ACRTIMP char* __cdecl strcpy(char*,const char*);
| ^~~~~~
In function 'lstrcatA',
inlined from 'GetSystemDirectory16' at ~/src/wine/dlls/krnl386.exe16/file.c:649:9,
inlined from 'get_search_path' at ~/src/wine/dlls/krnl386.exe16/file.c:192:12:
~/src/wine/include/winbase.h:2952:12: error: argument 1 null where non-null expected [-Werror=nonnull]
2952 | return strcat( dst, src );
| ^~~~~~~~~~~~~~~~~~
~/src/wine/include/winbase.h:2952:12: note: in a call to built-in function '__builtin_strlen'
(built using --with-mingw and --enable-werror to turn it into an error)
The warning doesn't really matter as get_search_path() calls
GetSystemDirectory16(NULL, 0) to get the size for allocation.
`if (count >= len)` in the latter saves us from ever atempting to
strcpy() onto NULL, but the compiler is not smart enough to figure out
that len will be greater than 0.
This change mimics kernel32's GetSystemDirectoryW().