[v2 PATCH] dwrite/tests: Silence a compiler warning in test_fontsetbuilder.

Nikolay Sivov nsivov at codeweavers.com
Fri Sep 13 00:10:01 CDT 2019


From: Gerald Pfeifer <gerald at pfeifer.com>

GCC 10 alphas (and probably before that) issue

  font.c: In function ¡test_fontsetbuilder¢:
  font.c:9149:21: warning: ¡ivalue¢ may be used uninitialized in this
  function [-Wmaybe-uninitialized]
   9149 |                     wsprintfW(buffW, fmtW, ivalue);
        |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

in dlls/dwrite/tests/font.c.

The structure of our code is

  switch ... {
    case 1: ivalue =... ; break;
    case 2: ivalue =... ; break;
    default: ;
  }
  switch ... {
    case 1: case 2: do something with ivalue;
    default: ;
  }

so this looks like a false positive, however one that appears rather
involved for compilers to handle.

Hence, best to pragmatically silence this by initializing ivalue in
the default case?

Gerald

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/dwrite/tests/font.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dlls/dwrite/tests/font.c b/dlls/dwrite/tests/font.c
index 309c0a2b08..7d434222a3 100644
--- a/dlls/dwrite/tests/font.c
+++ b/dlls/dwrite/tests/font.c
@@ -9105,7 +9105,7 @@ todo_wine
                 static const WCHAR fmtW[] = {'%','u',0};
                 IDWriteLocalizedStrings *values;
                 WCHAR buffW[255], buff2W[255];
-                UINT32 c, ivalue;
+                UINT32 c, ivalue = 0;
                 BOOL exists;
 
                 hr = IDWriteFontSet_GetPropertyValues(fontset, 0, id, &exists, &values);
-- 
2.23.0




More information about the wine-devel mailing list