[PATCH v2 0/1] MR2892: wined3d: Fix uninitialized variable warning.
```c dlls/wined3d/context_vk.c:2377:42: warning: ‘null_binding’ may be used uninitialized in this function [-Wmaybe-uninitialized] 2377 | *null_buffer_binding = b->binding = null_binding; | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` -- v2: wined3d: Fix uninitialized variable warning. https://gitlab.winehq.org/wine/wine/-/merge_requests/2892
From: Davide Beatrici <git(a)davidebeatrici.dev> dlls/wined3d/context_vk.c:2377:42: warning: ‘null_binding’ may be used uninitialized in this function [-Wmaybe-uninitialized] 2377 | *null_buffer_binding = b->binding = null_binding; | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ --- dlls/wined3d/context_vk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/wined3d/context_vk.c b/dlls/wined3d/context_vk.c index 10713985e7e..8076ac54166 100644 --- a/dlls/wined3d/context_vk.c +++ b/dlls/wined3d/context_vk.c @@ -2337,7 +2337,7 @@ static bool wined3d_context_vk_update_graphics_pipeline_key(struct wined3d_conte { struct wined3d_shader_signature_element *element; struct wined3d_shader_signature *signature; - uint32_t null_binding, location; + uint32_t null_binding = UINT32_MAX, location; for (i = 0; i < ARRAY_SIZE(state->streams); ++i) { -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/2892
With what gcc version and compiler flags does this appear? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/2892#note_33688
On Wed May 24 17:50:18 2023 +0000, Zebediah Figura wrote:
With what gcc version and compiler flags does this appear?
gcc-9 (Ubuntu 9.4.0-1ubuntu1~18.04) 9.4.0
x86_64-w64-mingw32-gcc (GCC) 9.3-win32 20200422
``` export CFLAGS_X32="-march=i686 -msse2 -mfpmath=sse -Og -ftree-vectorize" export CFLAGS_X64="-march=x86-64 -msse3 -mfpmath=sse -Og -ftree-vectorize" export LDFLAGS="-Wl,-O1,--sort-common,--as-needed" ``` -- https://gitlab.winehq.org/wine/wine/-/merge_requests/2892#note_33712
On Wed May 24 17:52:33 2023 +0000, Davide Beatrici wrote:
``` gcc-9 (Ubuntu 9.4.0-1ubuntu1~18.04) 9.4.0 x86_64-w64-mingw32-gcc (GCC) 9.3-win32 20200422 ``` ``` export CFLAGS_X32="-march=i686 -msse2 -mfpmath=sse -Og -ftree-vectorize" export CFLAGS_X64="-march=x86-64 -msse3 -mfpmath=sse -Og -ftree-vectorize" export LDFLAGS="-Wl,-O1,--sort-common,--as-needed" ```
That's both old and nonstandard, and while I'm not going to argue too hard against fixing these warnings, it doesn't seem the best use of time. I have to wonder how many other such warnings exist across the codebase with those options... Anyway, suppressing -Wmaybe-uninitialized by initializing the variable to a dummy value is bad for clarity, and in my experience almost never the right solution. In this case I'd rather replace the for + if pattern (which I pretty much universally dislike) with a helper function. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/2892#note_33718
That's both old and nonstandard, and while I'm not going to argue too hard against fixing these warnings, it doesn't seem the best use of time. I have to wonder how many other such warnings exist across the codebase with those options...
Quite a few, not too many though.
Anyway, suppressing -Wmaybe-uninitialized by initializing the variable to a dummy value is bad for clarity, and in my experience almost never the right solution. In this case I'd rather replace the for + if pattern (which I pretty much universally dislike) with a helper function.
I strongly agree, I honestly didn't like this "solution" anyway. !2863 solved the warning the right way. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/2892#note_33722
participants (3)
-
Davide Beatrici -
Davide Beatrici (@davidebeatrici) -
Zebediah Figura (@zfigura)