[PATCH 0/4] MR9429: Avoid a few compiler warnings.
Gitlab CI uses `--enable-werror` for its builds, but to improve backtraces with my recent address sanitizer experiments I am using these flags `-g -O1 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-optimize-sibling-calls -fno-inline-functions` with both, gcc at the unix side and llvm-mingw at the pe side. Therefore these warnings would turn into errors. This four patches are helping gcc at the unix side. Would these patches be acceptable? Should they be separate merge requests? <details> <summary>Details</summary> ``` ccache gcc -m64 -c -o tools/winebuild/utils.o .../wine/tools/winebuild/utils.c \ -Itools/winebuild -I.../wine/tools/winebuild -Iinclude \ -I.../wine/include -D__WINESRC__ -DWINE_UNIX_LIB -Wall -pipe \ -fcf-protection=none -fvisibility=hidden -fno-stack-protector -fno-strict-aliasing \ -Wdeclaration-after-statement -Wempty-body -Wignored-qualifiers -Winit-self -Wlogical-op \ -Wno-packed-not-aligned -Wpointer-arith -Wshift-overflow=2 -Wstrict-prototypes -Wtype-limits \ -Wunused-but-set-parameter -Wvla -Wwrite-strings -Wno-misleading-indentation -gdwarf-4 -Werror \ -g -O1 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-optimize-sibling-calls -fno-inline-functions .../wine/tools/winebuild/utils.c: In function 'find_tool': .../wine/tools/winebuild/utils.c:230:8: error: 'file' may be used uninitialized [-Werror=maybe-uninitialized] 230 | if (!file && cc_command.count) file = find_clang_tool( cc_command, name ); | ^ .../wine/tools/winebuild/utils.c:214:17: note: 'file' was declared here 214 | const char *file; | ^~~~ cc1: all warnings being treated as errors make: *** [Makefile:610992: tools/winebuild/utils.o] Error 1 ccache gcc -m64 -c -o dlls/ntdll/unix/file.o .../wine/dlls/ntdll/unix/file.c -Idlls/ntdll \ -I.../wine/dlls/ntdll -Iinclude \ -I.../wine/include -D__WINESRC__ -DLTC_NO_PROTOTYPES \ -DLTC_SOURCE -D_NTSYSTEM_ -D_ACRTIMP= -DWINBASEAPI= -DWINE_UNIX_LIB \ -I/usr/include/x86_64-linux-gnu -Wall -pipe -fcf-protection=none -fvisibility=hidden \ -fno-stack-protector -fno-strict-aliasing -Wdeclaration-after-statement -Wempty-body \ -Wignored-qualifiers -Winit-self -Wlogical-op -Wno-packed-not-aligned -Wpointer-arith \ -Wshift-overflow=2 -Wstrict-prototypes -Wtype-limits -Wunused-but-set-parameter -Wvla \ -Wwrite-strings -Wno-misleading-indentation -gdwarf-4 -Werror -fPIC -fasynchronous-unwind-tables \ -g -O1 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-optimize-sibling-calls -fno-inline-functions .../wine/dlls/ntdll/unix/file.c: In function 'NtReadFile': .../wine/dlls/ntdll/unix/file.c:5758:23: error: 'avail_mode' may be used uninitialized [-Werror=maybe-uninitialized] 5758 | if (total && avail_mode) | ~~~~~~^~~~~~~~~~~~~ .../wine/dlls/ntdll/unix/file.c:5755:18: note: 'avail_mode' was declared here 5755 | BOOL avail_mode; | ^~~~~~~~~~ cc1: all warnings being treated as errors make: *** [Makefile:318598: dlls/ntdll/unix/file.o] Error 1 ccache gcc -m64 -c -o dlls/sane.ds/unixlib.o .../wine/dlls/sane.ds/unixlib.c -Idlls/sane.ds \ -I.../wine/dlls/sane.ds -Iinclude \ -I.../wine/include -D__WINESRC__ -DWINE_UNIX_LIB -Wall -pipe \ -fcf-protection=none -fvisibility=hidden -fno-stack-protector -fno-strict-aliasing \ -Wdeclaration-after-statement -Wempty-body -Wignored-qualifiers -Winit-self -Wlogical-op \ -Wno-packed-not-aligned -Wpointer-arith -Wshift-overflow=2 -Wstrict-prototypes -Wtype-limits \ -Wunused-but-set-parameter -Wvla -Wwrite-strings -Wno-misleading-indentation -gdwarf-4 -Werror \ -fPIC -fasynchronous-unwind-tables -g -O1 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-optimize-sibling-calls -fno-inline-functions .../wine/dlls/sane.ds/unixlib.c: In function 'read_data': .../wine/dlls/sane.ds/unixlib.c:332:8: error: 'status' may be used uninitialized [-Werror=maybe-uninitialized] 332 | if (status == SANE_STATUS_EOF) return TWCC_SUCCESS; | ^ .../wine/dlls/sane.ds/unixlib.c:321:17: note: 'status' was declared here 321 | SANE_Status status; | ^~~~~~ cc1: all warnings being treated as errors make: *** [Makefile:366624: dlls/sane.ds/unixlib.o] Error 1 ccache gcc -m64 -c -o server/directory.o .../wine/server/directory.c -Iserver \ -I.../wine/server -Iinclude \ -I.../wine/include -D__WINESRC__ -DWINE_UNIX_LIB -Wall -pipe \ -fcf-protection=none -fvisibility=hidden -fno-stack-protector -fno-strict-aliasing \ -Wdeclaration-after-statement -Wempty-body -Wignored-qualifiers -Winit-self -Wlogical-op \ -Wno-packed-not-aligned -Wpointer-arith -Wshift-overflow=2 -Wstrict-prototypes -Wtype-limits \ -Wunused-but-set-parameter -Wvla -Wwrite-strings -Wno-misleading-indentation -gdwarf-4 -Werror \ -g -O1 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -fno-optimize-sibling-calls -fno-inline-functions .../wine/server/directory.c: In function 'create_session': .../wine/server/directory.c:327:44: error: 'snprintf' output may be truncated before the last format character [-Werror=format-truncation=] 327 | snprintf( id_strA, sizeof(id_strA), "%u", id ); | ^ .../wine/server/directory.c:327:5: note: 'snprintf' output between 2 and 11 bytes into a destination of size 10 327 | snprintf( id_strA, sizeof(id_strA), "%u", id ); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors make: *** [Makefile:607457: server/directory.o] Error 1 ``` </details> -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9429
From: Bernhard Übelacker <bernhardu(a)mailbox.org> --- tools/winebuild/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c index 1f0cde60bf9..39ffbc0badd 100644 --- a/tools/winebuild/utils.c +++ b/tools/winebuild/utils.c @@ -211,7 +211,7 @@ static const char *find_clang_tool( struct strarray clang, const char *tool ) struct strarray find_tool( const char *name, const char * const *names ) { struct strarray ret = empty_strarray; - const char *file; + const char *file = NULL; const char *alt_names[2]; if (!names) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9429
From: Bernhard Übelacker <bernhardu(a)mailbox.org> --- dlls/ntdll/unix/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/ntdll/unix/file.c b/dlls/ntdll/unix/file.c index bb74b975c8a..7b6f10ad913 100644 --- a/dlls/ntdll/unix/file.c +++ b/dlls/ntdll/unix/file.c @@ -5752,7 +5752,7 @@ NTSTATUS WINAPI NtReadFile( HANDLE handle, HANDLE event, PIO_APC_ROUTINE apc, vo if (async_read) { - BOOL avail_mode; + BOOL avail_mode = FALSE; if ((status = get_io_avail_mode( handle, type, &avail_mode ))) goto err; if (total && avail_mode) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9429
From: Bernhard Übelacker <bernhardu(a)mailbox.org> --- dlls/sane.ds/unixlib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/sane.ds/unixlib.c b/dlls/sane.ds/unixlib.c index 0002e64eacb..b29daad2c08 100644 --- a/dlls/sane.ds/unixlib.c +++ b/dlls/sane.ds/unixlib.c @@ -318,7 +318,7 @@ static NTSTATUS read_data( void *args ) const struct read_data_params *params = args; unsigned char *buffer = params->buffer; int read_len, remaining = params->len; - SANE_Status status; + SANE_Status status = SANE_STATUS_GOOD; *params->retlen = 0; while (remaining) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9429
From: Bernhard Übelacker <bernhardu(a)mailbox.org> --- server/directory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/directory.c b/server/directory.c index c56c216d6d5..a25a577c677 100644 --- a/server/directory.c +++ b/server/directory.c @@ -311,7 +311,7 @@ static void create_session( unsigned int id ) struct directory *dir_id, *dir_bno, *dir_dosdevices, *dir_windows, *dir_winstation; struct object *link_global, *link_local, *link_session, *link_bno, *link_windows; struct unicode_str id_str; - char id_strA[10]; + char id_strA[11]; WCHAR *id_strW; if (!id) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/9429
Would these patches be acceptable? Should they be separate merge requests?
If it's catching legitimate bugs that's of course acceptable, but in general we don't change the code to silence false positives that only appear with non-standard compile flags. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9429#note_121690
Thanks for the explanation, will try how dropping those flags really affects backtraces. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9429#note_121802
This merge request was closed by Bernhard Übelacker. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/9429
participants (2)
-
Alexandre Julliard (@julliard) -
Bernhard Übelacker