fix uninitialized variable compiler warnings
authorMichael Gilbert <mgilbert@debian.org>
Tue, 13 Sep 2022 00:46:21 +0000 (01:46 +0100)
committerMichael Gilbert <mgilbert@debian.org>
Tue, 13 Sep 2022 00:46:21 +0000 (01:46 +0100)
Gbp-Pq: Topic warnings
Gbp-Pq: Name uninitialized-variables.patch

23 files changed:
dlls/comctl32/button.c
dlls/comdlg32/filedlg.c
dlls/d3dx9_36/mesh.c
dlls/d3dx9_36/texture.c
dlls/gdiplus/font.c
dlls/iphlpapi/iphlpapi_main.c
dlls/mciseq/mcimidi.c
dlls/mf/session.c
dlls/msi/automation.c
dlls/msvcrt/misc.c
dlls/msxml3/xdr.c
dlls/ntdll/locale.c
dlls/ntdll/unix/env.c
dlls/ole32/datacache.c
dlls/scrobj/scrobj.c
dlls/webservices/reader.c
dlls/win32u/dc.c
dlls/win32u/region.c
dlls/wined3d/utils.c
dlls/winex11.drv/window.c
include/winsock2.h
tools/winebuild/import.c
tools/winedump/msc.c

index 72c1a17402cee92327c862830864659354f0d323..3935c8d9746f7e309913ec47c524dcfdecada3a3 100644 (file)
@@ -1820,7 +1820,8 @@ static void BUTTON_DrawThemedLabel(const BUTTON_INFO *info, HDC hdc, UINT text_f
 static void PB_Paint( const BUTTON_INFO *infoPtr, HDC hDC, UINT action )
 {
     RECT     rc, labelRect, imageRect, textRect;
-    UINT     dtFlags, uState;
+    UINT     uState;
+    UINT     dtFlags = (UINT)-1L;
     HPEN     hOldPen, hpen;
     HBRUSH   hOldBrush;
     INT      oldBkMode;
index 0f74c85fcd8b94bb96698230765397ed6c3e34da..63fe8528bf1c6277c2b12cf0dd2c0627a34f977d 100644 (file)
@@ -238,7 +238,7 @@ static BOOL get_config_key_dword(HKEY hkey, const WCHAR *name, DWORD *value)
 
 static BOOL get_config_key_string(HKEY hkey, const WCHAR *name, WCHAR **value)
 {
-    DWORD type, size;
+    DWORD type, size = 0;
     WCHAR *str;
 
     if (RegQueryValueExW(hkey, name, 0, &type, NULL, &size))
index 48abb7ede41a4e93e0016da9e62efb7a3a130e88..322ab5a62362032acd5027d3596ecc1ddaca01ec 100644 (file)
@@ -5524,7 +5524,8 @@ static BOOL attempt_line_merge(struct outline *outline,
                                BOOL to_curve,
                                const struct cos_table *table)
 {
-    D3DXVECTOR2 curdir, lastdir;
+    D3DXVECTOR2 curdir = {0.0f, 0.0f};
+    D3DXVECTOR2 lastdir = {0.0f, 0.0f};
     struct point2d *prevpt, *pt;
     BOOL ret = FALSE;
 
index 6af445890472bd222e09d04c19685b7836878405..b099f17bace2021c7e8fe30d2733118a2170693e 100644 (file)
@@ -1269,7 +1269,7 @@ static inline void fill_texture(const struct pixel_format_desc *format, BYTE *po
 
     for (c = 0; c < 4; c++)
     {
-        float comp_value;
+        float comp_value = 0.f;
         DWORD i, v = 0, mask32 = format->bits[c] == 32 ? ~0U : ((1 << format->bits[c]) - 1);
 
         switch (c)
index 44431ea2ac8041bf101550b7da182dbf44b7ab1b..219db2acad4884e8ec4165ecb99f1b9997a8df8a 100644 (file)
@@ -1394,7 +1394,8 @@ static WCHAR *load_ttf_name_id( const BYTE *mem, DWORD_PTR size, DWORD id )
     const tt_header *header;
     const tt_name_table *name_table;
     const tt_name_record *name_record;
-    DWORD pos, ofs, count;
+    DWORD pos, count;
+    DWORD ofs = 0;
     int i, res, best_lang = 0, best_index = -1;
 
     if (sizeof(tt_header) > size)
index c94f869c9f91ac01b0317e2654589540627ddd3f..61e927084b0e9bf0261b90e716796fa5dbe4229c 100644 (file)
@@ -992,7 +992,9 @@ static DWORD gateway_and_prefix_addresses_alloc( IP_ADAPTER_ADDRESSES *aa, ULONG
     struct nsi_ipv6_forward_key *key6;
     IP_ADAPTER_GATEWAY_ADDRESS *gw, **gw_next;
     IP_ADAPTER_PREFIX *prefix, **prefix_next;
-    DWORD err, count, i, prefix_len, key_size = (family == AF_INET) ? sizeof(*key4) : sizeof(*key6);
+    DWORD err, count, i;
+    DWORD prefix_len = 0;
+    DWORD key_size = (family == AF_INET) ? sizeof(*key4) : sizeof(*key6);
     DWORD sockaddr_size = (family == AF_INET) ? sizeof(SOCKADDR_IN) : sizeof(SOCKADDR_IN6);
     SOCKADDR_INET sockaddr;
     NET_LUID *luid;
@@ -1085,6 +1087,11 @@ static DWORD gateway_and_prefix_addresses_alloc( IP_ADAPTER_ADDRESSES *aa, ULONG
                         err = ERROR_NOT_ENOUGH_MEMORY;
                         goto err;
                     }
+                    if (prefix_len == 0)
+                    {
+                        err = ERROR_INVALID_DATA;
+                        goto err;
+                    }
                     prefix->Length = sizeof(*prefix);
                     prefix->Address.lpSockaddr = (SOCKADDR *)(prefix + 1);
                     prefix->Address.iSockaddrLength = sockaddr_size;
index 33f9fde42c7bcee7bbaa5346dbbbecc807d5c8ae..b703922cebfbfc9555be2b3cc31815ce0306206e 100644 (file)
@@ -247,9 +247,9 @@ static DWORD        MIDI_mciReadNextEvent(WINE_MCIMIDI* wmm, MCI_MIDITRACK* mmt)
 {
     BYTE       b1, b2 = 0, b3;
     WORD       hw = 0;
-    DWORD      evtPulse;
+    DWORD      evtPulse = 0;
     DWORD      evtLength;
-    DWORD      tmp;
+    DWORD      tmp = 0;
 
     if (mmioSeek(wmm->hFile, mmt->dwIndex, SEEK_SET) != mmt->dwIndex) {
        WARN("Can't seek at %08X\n", mmt->dwIndex);
index c8ec1b5c33f58744f936cff9ad1631006475d7ab..92a680852a3027a3cf81f42aa4483156802be849 100644 (file)
@@ -525,7 +525,7 @@ static void session_clear_queued_topologies(struct media_session *session)
 static void session_set_topo_status(struct media_session *session, HRESULT status,
         MF_TOPOSTATUS topo_status)
 {
-    IMFMediaEvent *event;
+    IMFMediaEvent *event = NULL;
     PROPVARIANT param;
 
     if (topo_status == MF_TOPOSTATUS_INVALID)
index 80d6b8a66ba9d3ff392cd328612f6e2886dba2db..9de330e96beceb96a09bc60caf42d68177816f2d 100644 (file)
@@ -1818,7 +1818,7 @@ static HRESULT InstallerImpl_SummaryInformation(WORD wFlags,
     UINT ret;
     HRESULT hr;
     MSIHANDLE hsuminfo;
-    IDispatch *dispatch;
+    IDispatch *dispatch = NULL;
     VARIANTARG varg0, varg1;
 
     if (!(wFlags & DISPATCH_PROPERTYGET))
index 73fadfcbb74ef7150ed42e3eab77b2038197496f..fc3d7294dc378ce7e85b9b31458b376eaaaf0f4c 100644 (file)
@@ -269,7 +269,7 @@ static void small_sort(void *base, size_t nmemb, size_t size,
         int (CDECL *compar)(void *, const void *, const void *), void *context)
 {
     size_t e, i;
-    char *max, *p;
+    char *max, *p = NULL;
 
     for(e=nmemb; e>1; e--) {
         max = base;
index 0ac9632c8e607a3485375b7290b66757637a3030..95723b8c09de79a4c1faaf7faaa60e4196ee8488 100644 (file)
@@ -596,6 +596,9 @@ static xmlNodePtr XDR_E_ElementType(xmlNodePtr xdr, xmlNodePtr parent)
                         case ORDER_ONE:
                             xsd_child = xmlNewChild(xsd_base, NULL, xs_all, NULL);
                             break;
+                        default:
+                            xsd_child = NULL;
+                            ERR("Unhandled order enum %d\n", (int)order);
                     }
 
                     FOREACH_CHILD(xdr, xdr_child)
index fe185d403f29b203780317f2622fc0dcf69a08c8..d149588eba9729ad8da7ffb9ec99b2105b219347 100644 (file)
@@ -1808,7 +1808,7 @@ NTSTATUS WINAPI RtlIdnToUnicode( DWORD flags, const WCHAR *src, INT srclen, WCHA
     int i, buflen, start, end, out_label, out = 0;
     NTSTATUS status;
     UINT buffer[64];
-    WCHAR ch;
+    WCHAR ch = '\0';
 
     if (!src || srclen < -1) return STATUS_INVALID_PARAMETER;
     if (srclen == -1) srclen = wcslen( src ) + 1;
index c7e0674e083cec8b8c0adc84fbacf88e2fed7f52..7939716a4f5923aa6188e9744ccb06961a956f9c 100644 (file)
@@ -2174,7 +2174,8 @@ static RTL_USER_PROCESS_PARAMETERS *build_initial_params( void **module )
     static const WCHAR valueW[] = {'1',0};
     static const WCHAR pathW[] = {'P','A','T','H'};
     RTL_USER_PROCESS_PARAMETERS *params = NULL;
-    SIZE_T size, env_pos, env_size;
+    SIZE_T env_pos = 0;
+    SIZE_T size, env_size;
     WCHAR *dst, *image, *cmdline, *path, *bootstrap;
     WCHAR *env = get_initial_environment( &env_pos, &env_size );
     WCHAR *curdir = get_initial_directory();
index a536f829515892ba653b01ec5714d6cb89e93d32..550a33a2e54328595d9d245a3c6696725c04a5c3 100644 (file)
@@ -2517,7 +2517,7 @@ static HRESULT WINAPI DataCache_EnumCache(IOleCache2 *iface,
     DataCacheEntry *cache_entry;
     int i = 0, count = 0;
     STATDATA *data;
-    HRESULT hr;
+    HRESULT hr = E_FAIL;
 
     TRACE( "(%p, %p)\n", This, enum_stat );
 
index 228cfb14904c7e20bce32b1db03145947e3d885f..63dfad3c9f70985ee4a9a7186a1557320baf2f18 100644 (file)
@@ -1195,7 +1195,7 @@ static HRESULT create_scriptlet_instance(struct scriptlet_factory *factory, IDis
     struct script_host *factory_host, *host;
     struct scriptlet_instance *obj;
     IDispatch *script_dispatch;
-    HRESULT hres;
+    HRESULT hres = E_FAIL;
 
     if (!(obj = heap_alloc_zero(sizeof(*obj)))) return E_OUTOFMEMORY;
 
index 69c4f2a300795f2a5e4e1adaf28a68245a4a9b5c..92125524cf5dc85e5a91c530c6a32c4f153e38b2 100644 (file)
@@ -2041,7 +2041,7 @@ static inline BOOL is_element_type( unsigned char type )
 
 static HRESULT read_attributes_bin( struct reader *reader, WS_XML_ELEMENT_NODE *elem )
 {
-    WS_XML_ATTRIBUTE *attr;
+    WS_XML_ATTRIBUTE *attr = NULL;
     unsigned char type;
     HRESULT hr;
 
@@ -6424,7 +6424,7 @@ static HRESULT read_type_struct( struct reader *reader, WS_TYPE_MAPPING mapping,
                                  WS_HEAP *heap, void *ret, ULONG size, BOOL *found )
 {
     ULONG i, offset;
-    HRESULT hr;
+    HRESULT hr = E_FAIL;
     char *buf;
 
     if (!desc) return E_INVALIDARG;
index 3aae73779e9f4684268182a8ca2a282973d6fecf..b48dc3c546a823f2c1a260071cd4f4157088daf4 100644 (file)
@@ -941,6 +941,7 @@ BOOL WINAPI NtGdiGetAndSetDCDword( HDC hdc, UINT method, DWORD value, DWORD *pre
 
     default:
         WARN( "unknown method %u\n", method );
+        prev = 0;
         ret = FALSE;
         break;
     }
index 86554f21e1c5d4bd96f7ff9a020fc3ec1bf95bef..1dccdbec1f7972b9c7a513657b8d8945357350e3 100644 (file)
@@ -410,6 +410,7 @@ static BOOL init_region( WINEREGION *pReg, INT n )
 {
     n = max( n, RGN_DEFAULT_RECTS );
 
+    pReg->rects = NULL;
     if (n > RGN_DEFAULT_RECTS)
     {
         if (n > INT_MAX / sizeof(RECT)) return FALSE;
index 3a20b35da3b68d1ee51dbdeead898b0c68b99235..7238a47659d84b32b2deefaa55ba265a8358c46c 100644 (file)
@@ -2674,6 +2674,9 @@ static void check_fbo_compat(struct wined3d_caps_gl_ctx *ctx, struct wined3d_for
                     case WINED3D_GL_RES_TYPE_COUNT:
                         color = 0;
                         break;
+                    default:
+                        color = 0;
+                        ERR("Unhandled type enum %d\n", (int)type);
                 }
                 checkGLcall("Post-pixelshader blending check");
 
index 36fb41ac710cbe8e5c7cb13fc7ce25b844b31617..01b0b66a91a9b3274c8143a5c442c66042440a45 100644 (file)
@@ -2170,11 +2170,14 @@ void CDECL X11DRV_GetDC( HDC hdc, HWND hwnd, HWND top, const RECT *win_rect,
     }
     else
     {
+        Drawable top_window = X11DRV_get_whole_window( top );
+        escape.drawable = top_window;
+
         /* find the first ancestor that has a drawable */
         for (parent = hwnd; parent && parent != top; parent = GetAncestor( parent, GA_PARENT ))
             if ((escape.drawable = X11DRV_get_whole_window( parent ))) break;
 
-        if (escape.drawable)
+        if (escape.drawable != top_window)
         {
             POINT pt = { 0, 0 };
             MapWindowPoints( 0, parent, &pt, 1 );
@@ -2182,7 +2185,6 @@ void CDECL X11DRV_GetDC( HDC hdc, HWND hwnd, HWND top, const RECT *win_rect,
             OffsetRect( &escape.dc_rect, pt.x, pt.y );
             if (flags & DCX_CLIPCHILDREN) escape.mode = ClipByChildren;
         }
-        else escape.drawable = X11DRV_get_whole_window( top );
     }
 
     ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPSTR)&escape, 0, NULL );
index f1d43acad404a5897501a0726b4f04c53efa3387..00c62b4c0a0691fe5cab8af9bb5e878bc4580d02 100644 (file)
@@ -597,9 +597,17 @@ typedef struct WS(timeval)
 #  define FD_SETSIZE    64
 # endif
 
+# define FD_ZERO(set) { \
+    unsigned int __i; \
+    (((fd_set*)(set))->fd_count=0); \
+    for (__i = 0; __i < FD_SETSIZE; __i++) \
+    { \
+        (((fd_set*)(set))->fd_array[__i] = SOCKET_ERROR); \
+    } \
+}
+
 # define FD_CLR(fd, set)      __WS_FD_CLR((fd), (set), fd_set)
 # define FD_SET(fd, set)      __WS_FD_SET((fd), (set), fd_set)
-# define FD_ZERO(set)         (((fd_set*)(set))->fd_count=0)
 # define FD_ISSET(fd, set)    __WSAFDIsSet((SOCKET)(fd), (fd_set*)(set))
 
 #else
index d9580ff0e8790f39c884f937d9d896492d0673a1..a0b25fa703f957ee2b42718a0cf243ca523e42c5 100644 (file)
@@ -165,8 +165,11 @@ static int func_cmp( const void *func1, const void *func2 )
 {
     const ORDDEF *odp1 = *(const ORDDEF * const *)func1;
     const ORDDEF *odp2 = *(const ORDDEF * const *)func2;
-    return strcmp( odp1->name ? odp1->name : odp1->export_name,
-                   odp2->name ? odp2->name : odp2->export_name );
+    const char *name1 = odp1->name ? odp1->name : odp1->export_name;
+    const char *name2 = odp2->name ? odp2->name : odp2->export_name;
+    if ( !name1 || !name2 )
+      fatal_error("Unable to compare function names\n");
+    return strcmp( name1, name2 );
 }
 
 /* remove a name from a name table */
index c5ea8bfe51d9fc08c9bbf8a53ada1e7921606ca0..d0f5d9a1b54fb9d70646f04c0b5833f1b487201b 100644 (file)
@@ -503,7 +503,7 @@ static void do_field(const unsigned char* start, const unsigned char* end)
     const unsigned char*        ptr = start;
     const char*                 cstr;
     const struct p_string*      pstr;
-    int leaf_len, value;
+    int leaf_len, value = 0;
     struct full_value full_value;
 
     while (ptr < end)
@@ -811,7 +811,7 @@ static void do_field(const unsigned char* start, const unsigned char* end)
 static void codeview_dump_one_type(unsigned curr_type, const union codeview_type* type)
 {
     const union codeview_reftype* reftype = (const union codeview_reftype*)type;
-    int                 i, leaf_len, value;
+    int                 i, leaf_len, value = 0;
     unsigned int        j;
     const char*         str;