dlls/msi/string.c -- fix use of signed versus unsigned (RESEND)
Gerald Pfeifer
gerald at pfeifer.com
Wed Nov 14 15:19:04 CST 2007
Last one for today, promised. ;-)
Gerald
---------- Forwarded message ----------
From: Gerald Pfeifer <gerald at pfeifer.com>
To: <wine-patches at winehq.org>
Date: Sat, 3 Nov 2007 20:02:18 +0100 (CET)
Subject: dlls/msi/string.c -- fix use of signed versus unsigned
This was a bit more tricky, but I hope I got it right. Basically the
problem here was that we used a parameter/variable n of type UINT both
as a true unsigned (the return of the hash function) and as a true signed
variable (comparing against -1).
This removes the following three compiler diagnostics that I've been
seeing. In other words, this is also addressing very real issues!
string.c: In function 'msi_addstring':
string.c:208: warning: comparison of unsigned expression < 0 is always false
string.c: In function 'msi_addstringW':
string.c:260: warning: comparison of unsigned expression < 0 is always false
string.c: In function 'msi_string2idW':
string.c:400: warning: comparison between signed and unsigned
Gerald
ChangeLog:
Fix use of signed versus unsigned variables.
Index: string.c
===================================================================
RCS file: /home/wine/wine/dlls/msi/string.c,v
retrieving revision 1.32
diff -u -3 -p -r1.32 string.c
--- string.c 18 Oct 2007 13:00:56 -0000 1.32
+++ string.c 3 Nov 2007 18:58:04 -0000
@@ -179,7 +179,7 @@ static void set_st_entry( string_table *
st->freeslot = n + 1;
}
-static int msi_addstring( string_table *st, UINT n, const CHAR *data, int len, UINT refcount, enum StringPersistence persistence )
+static int msi_addstring( string_table *st, int n, const CHAR *data, int len, UINT refcount, enum StringPersistence persistence )
{
LPWSTR str;
int sz;
@@ -196,14 +196,16 @@ static int msi_addstring( string_table *
}
else
{
- if( ERROR_SUCCESS == msi_string2idA( st, data, &n ) )
+ UINT u;
+ if( ERROR_SUCCESS == msi_string2idA( st, data, &u ) )
{
if (persistence == StringPersistent)
- st->strings[n].persistent_refcount += refcount;
+ st->strings[u].persistent_refcount += refcount;
else
- st->strings[n].nonpersistent_refcount += refcount;
- return n;
+ st->strings[u].nonpersistent_refcount += refcount;
+ return u;
}
+
n = st_find_free_entry( st );
if( n < 0 )
return -1;
@@ -230,7 +232,7 @@ static int msi_addstring( string_table *
return n;
}
-int msi_addstringW( string_table *st, UINT n, const WCHAR *data, int len, UINT refcount, enum StringPersistence persistence )
+int msi_addstringW( string_table *st, INT n, const WCHAR *data, int len, UINT refcount, enum StringPersistence persistence )
{
LPWSTR str;
@@ -248,14 +250,16 @@ int msi_addstringW( string_table *st, UI
}
else
{
- if( ERROR_SUCCESS == msi_string2idW( st, data, &n ) )
+ UINT u;
+ if( ERROR_SUCCESS == msi_string2idW( st, data, &u ) )
{
if (persistence == StringPersistent)
- st->strings[n].persistent_refcount += refcount;
+ st->strings[u].persistent_refcount += refcount;
else
- st->strings[n].nonpersistent_refcount += refcount;
- return n;
+ st->strings[u].nonpersistent_refcount += refcount;
+ return u;
}
+
n = st_find_free_entry( st );
if( n < 0 )
return -1;
@@ -394,8 +398,9 @@ UINT msi_id2stringA( const string_table
*/
UINT msi_string2idW( const string_table *st, LPCWSTR str, UINT *id )
{
- UINT n, hash = msistring_makehash( str );
- msistring *se = st->strings;
+ UINT hash = msistring_makehash( str );
+ const msistring *se = st->strings;
+ INT n;
for (n = st->hash[hash]; n != -1; n = st->strings[n].hash_next )
{
Index: msipriv.h
===================================================================
RCS file: /home/wine/wine/dlls/msi/msipriv.h,v
retrieving revision 1.199
diff -u -3 -p -r1.199 msipriv.h
--- msipriv.h 1 Nov 2007 12:41:08 -0000 1.199
+++ msipriv.h 3 Nov 2007 18:58:05 -0000
@@ -613,7 +613,7 @@ enum StringPersistence
StringNonPersistent = 1
};
-extern BOOL msi_addstringW( string_table *st, UINT string_no, const WCHAR *data, int len, UINT refcount, enum StringPersistence persistence );
+extern BOOL msi_addstringW( string_table *st, INT string_no, const WCHAR *data, int len, UINT refcount, enum StringPersistence persistence );
extern UINT msi_id2stringW( const string_table *st, UINT string_no, LPWSTR buffer, UINT *sz );
extern UINT msi_id2stringA( const string_table *st, UINT string_no, LPSTR buffer, UINT *sz );
More information about the wine-patches
mailing list