OLE32/compobj: gcc 4.0 -Wpointer-sign fixes
Robert Shearman
rob at codeweavers.com
Mon Jul 4 20:35:18 CDT 2005
Mike McCormack wrote:
>Index: dlls/ole32/compobj.c
>===================================================================
>RCS file: /home/wine/wine/dlls/ole32/compobj.c,v
>retrieving revision 1.154
>diff -u -p -r1.154 compobj.c
>--- dlls/ole32/compobj.c 20 Jun 2005 14:18:04 -0000 1.154
>+++ dlls/ole32/compobj.c 4 Jul 2005 14:51:31 -0000
>@@ -787,6 +787,26 @@ HRESULT WINAPI CoCreateGuid(GUID *pguid)
> return UuidCreate(pguid);
> }
>
>+static LPBYTE validate_clsid_string( LPCSTR s )
>+{
>+ int i;
>+
>+ if (strlen(s) != 38)
>+ return NULL;
>+
>+ if ((s[0]!='{') || (s[9]!='-') || (s[14]!='-') || (s[19]!='-') || (s[24]!='-') || (s[37]!='}'))
>+ return NULL;
>+
>+ for (i=1; i<37; i++) {
>+ if ((i == 9)||(i == 14)||(i == 19)||(i == 24)) continue;
>+ if (!(((s[i] >= '0') && (s[i] <= '9')) ||
>+ ((s[i] >= 'a') && (s[i] <= 'f')) ||
>+ ((s[i] >= 'A') && (s[i] <= 'F'))))
>+ return NULL;
>+ }
>+ return (LPBYTE) s;
>+}
>+
> /******************************************************************************
> * CLSIDFromString [OLE32.@]
> * IIDFromString [OLE32.@]
>@@ -813,28 +833,16 @@ HRESULT WINAPI CoCreateGuid(GUID *pguid)
> */
> HRESULT WINAPI __CLSIDFromStringA(LPCSTR idstr, CLSID *id)
> {
>- const BYTE *s = (const BYTE *) idstr;
>- int i;
> BYTE table[256];
>+ LPBYTE s;
>+ int i;
>
>- if (!s)
>- s = "{00000000-0000-0000-0000-000000000000}";
>- else { /* validate the CLSID string */
>-
>- if (strlen(s) != 38)
>- return CO_E_CLASSSTRING;
>-
>- if ((s[0]!='{') || (s[9]!='-') || (s[14]!='-') || (s[19]!='-') || (s[24]!='-') || (s[37]!='}'))
>- return CO_E_CLASSSTRING;
>-
>- for (i=1; i<37; i++) {
>- if ((i == 9)||(i == 14)||(i == 19)||(i == 24)) continue;
>- if (!(((s[i] >= '0') && (s[i] <= '9')) ||
>- ((s[i] >= 'a') && (s[i] <= 'f')) ||
>- ((s[i] >= 'A') && (s[i] <= 'F'))))
>- return CO_E_CLASSSTRING;
>- }
>- }
>+ if (!idstr)
>+ idstr = "{00000000-0000-0000-0000-000000000000}";
>+
>+ s = validate_clsid_string( idstr );
>+ if( !s )
>+ return CO_E_CLASSSTRING;
>
> TRACE("%s -> %p\n", s, id);
>
I don't think there is any need to split the function into two as you
can just use 'idstr' directly, instead of 's'. Also, note that this
function will soon be converted into using WCHARs, but I don't think
that should change anything.
--
Rob Shearman
More information about the wine-devel
mailing list