[janitor] programs/wcmd -Wwrite-strings cleanup
Kevin Groeneveld
kgroeneveld at mcmaster.ca
Thu Oct 9 21:45:16 CDT 2003
Alexandre Julliard wrote:
> In some cases parameters to API functions are not declared const even
> though they really are const; some of these could be fixed. Notably,
> all the 16-bit ones can be freely changed since no external code
> depends on them. Some 32-bit ones can probably be changed too, like
> all the undocumented ones. Not sure how much this helps.
>
> In cases where the official prototype is broken but we can't fix it, I
> think a cast is better than creating a writable string. Of course this
> means making sure that the string really isn't modified by the
> function.
I have also stumbled across a case where the official declaration is a
constant string, but Windows modifies the string anyway, at least
temporarily. The string was changed back before the function returned.
In particular, BuildCommDCB's official declaration is:
BOOL BuildCommDCB(LPCSTR lpDef, LPDCB lpDCB)
However, if you pass a true constant string for lpDef in Windows 95 it
will crash because Windows tries to write to it.
This is why in the conformance test I wrote for BuildCommDCB I did not
use constant strings. When I did, the test would crash under Windows 95.
I am not sure if this has any other implications for wine, but it is an
interesting fact none the less. Maybe if native DLL's are used which
may have similar problems, problems could occur if wine used a true
constant string.
Kevin
More information about the wine-devel
mailing list