Skip to content

[Win32] clang-cl warnings #41

@gvanem

Description

@gvanem

Building with clang-cl on Win-10, shows some important warnings:

src/sandbox-windows.c(370,9): warning: variable 'sync' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
    if (!instance->waited)
        ^~~~~~~~~~~~~~~~~
src/sandbox-windows.c(584,9): note: uninitialized use occurs here
    if (sync)
        ^~~~
src/sandbox-windows.c(370,5): note: remove the 'if' if its condition is always false
    if (!instance->waited)
    ^~~~~~~~~~~~~~~~~~~~~~
src/sandbox-windows.c(363,9): warning: variable 'sync' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
    if (!instance)
        ^~~~~~~~~
src/sandbox-windows.c(584,9): note: uninitialized use occurs here
    if (sync)
        ^~~~
src/sandbox-windows.c(363,5): note: remove the 'if' if its condition is always false
    if (!instance)
    ^~~~~~~~~~~~~~
src/sandbox-windows.c(383,5): note: variable 'sync' is declared here
    HANDLE sync = CreateEvent(&inherit_handle, FALSE, FALSE, NULL);
    ^
2 warnings generated.

Which I fixed by:

--- a/src/sandbox-windows.c 2022-09-18 12:05:05
+++ b/src/sandbox-windows.c 2022-09-19 12:00:35
@@ -346,6 +346,7 @@
     int errnum = 0;
     struct bxfi_sandbox *instance = NULL;
     BOOL success = FALSE;
+    HANDLE sync = NULL;

     struct bxfi_prepare_ctx prep = {
         .handles = NULL,
@@ -380,7 +381,7 @@
         .bInheritHandle = TRUE
     };

-    HANDLE sync = CreateEvent(&inherit_handle, FALSE, FALSE, NULL);
+    sync = CreateEvent(&inherit_handle, FALSE, FALSE, NULL);
     errnum = -EPROTO;
     if (!sync)
         goto error;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions