dlls/comctl32/listview.c warning elimination
Gerald Pfeifer
gerald at pfeifer.com
Sun Nov 4 12:24:46 CST 2007
On Mon, 29 Oct 2007, Alexandre Julliard wrote:
>> Not a patch I am particularily proud of, but the best way I found to get
>> rid of
>>
>> listview.c:5043: warning: 'strW' might be used uninitialized in this function
>>
>> issued by GCC, and apart from the added cast it actually is simpler than
>> the original.
> It was done the way it is precisely to avoid the non-const cast, which
> triggers a warning too.
Hmm, I didn't see that other warning, but I can easily see that some
versions of GCC or other compilers would do so.
The only patch I can think of that avoid *both* warnings is the one
below. Not perfect, but I fair compromise. What do you think? Or
do you have any better idea that we might want to try?
Gerald
Index: dlls/comctl32/listview.c
===================================================================
RCS file: /home/wine/wine/dlls/comctl32/listview.c,v
retrieving revision 1.490
diff -u -3 -p -r1.490 listview.c
--- dlls/comctl32/listview.c 23 Oct 2007 18:16:28 -0000 1.490
+++ dlls/comctl32/listview.c 4 Nov 2007 18:21:34 -0000
@@ -5040,12 +5040,18 @@ static INT LISTVIEW_FindItemA(const LIST
BOOL hasText = lpFindInfo->flags & (LVFI_STRING | LVFI_PARTIAL);
LVFINDINFOW fiw;
INT res;
- LPWSTR strW;
memcpy(&fiw, lpFindInfo, sizeof(fiw));
- if (hasText) fiw.psz = strW = textdupTtoW((LPCWSTR)lpFindInfo->psz, FALSE);
- res = LISTVIEW_FindItemW(infoPtr, nStart, &fiw);
- if (hasText) textfreeT(strW, FALSE);
+
+ if (hasText)
+ {
+ LPWSTR strW;
+ fiw.psz = strW = textdupTtoW((LPCWSTR)lpFindInfo->psz, FALSE);
+ res = LISTVIEW_FindItemW(infoPtr, nStart, &fiw);
+ textfreeT(strW, FALSE);
+ } else
+ res = LISTVIEW_FindItemW(infoPtr, nStart, &fiw);
+
return res;
}
More information about the wine-devel
mailing list