"Dimitrie O. Paun" dpaun@rogers.com writes:
On April 15, 2004 7:54 pm, Alexandre Julliard wrote:
Error codes should not be based on suggestions, what you should do is write a small test program under Windows to find out the real codes.
Hopefully, this sort of thing will be easier once we have the testing framework in place. For example, it's difficult for me to run a test program on Windows, because I don't have (an easily accessible) one.
So maybe with the testing framework in place, people can start by submitting a test, waiting for results, and then submitting the implementation. Very XP-ish :), but also rather cool. One would be able to easily test a hypothesis in about 24h on a large number of different Windows versions, configurations, etc.
Once small detail missing: Paul has vanished off the web, so we don't actually have anything to run on the Windows boxes :(
I am not well enough versed in the Windows world to try to write a test-case, but if someone can point me at a framework for a basic prog that I can fill in bits of, then I will test it on the one platform I have access to - XP - and use the values from there.
I figured that *some* value, even guessed-at, was better than none - it would allow someone to distinguish between causes of failure. I completely agree that the correct values should be used when they are available - and hence I have now put WARNs in where the guessed-at values are for the moment.
Peter
Index: dlls/kernel/console.c =================================================================== RCS file: /home/wine/wine/dlls/kernel/console.c,v retrieving revision 1.30 diff -u -r1.30 console.c --- dlls/kernel/console.c 13 Apr 2004 21:16:26 -0000 1.30 +++ dlls/kernel/console.c 16 Apr 2004 09:55:24 -0000 @@ -1448,17 +1448,21 @@ { BOOL ret = TRUE;
- FIXME("(%p,%i) - no error checking or testing yet\n", func, add); - if (!func) { + TRACE("(%p,%i) - first arg being NULL is not allowed in WinME, Win98 or Win95\n", func, add); CONSOLE_IgnoreCtrlC = add; } else if (add) { struct ConsoleHandler* ch = HeapAlloc(GetProcessHeap(), 0, sizeof(struct ConsoleHandler));
- if (!ch) return FALSE; + if (!ch) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + WARN("SetLastError() used guessed-at value\n"); + return FALSE; + } ch->handler = func; RtlEnterCriticalSection(&CONSOLE_CritSect); ch->next = CONSOLE_Handlers; @@ -1467,34 +1471,39 @@ } else { - struct ConsoleHandler** ch; RtlEnterCriticalSection(&CONSOLE_CritSect); - for (ch = &CONSOLE_Handlers; *ch; *ch = (*ch)->next) - { - if ((*ch)->handler == func) break; - } - if (*ch) - { - struct ConsoleHandler* rch = *ch; + if (func == CONSOLE_DefaultHandler) + { + ERR("Attempt to remove default CtrlHandler %\n", func); + WARN("SetLastError() used guessed-at value\n"); + SetLastError(ERROR_FUNCTION_FAILED); + ret = FALSE; + } + else + { + struct ConsoleHandler* ch, * prev ; + prev = NULL; + for (ch = CONSOLE_Handlers; ch; prev = ch, ch = ch->next) + { + if (ch->handler == func) + { + if (ch == CONSOLE_Handlers) + CONSOLE_Handlers = ch->next; + else + prev->next = ch->next; + HeapFree(GetProcessHeap(), 0, ch); + break; + } + }
- /* sanity check */ - if (rch == &CONSOLE_DefaultConsoleHandler) - { - ERR("Who's trying to remove default handler???\n"); - ret = FALSE; - } - else - { - rch = *ch; - *ch = (*ch)->next; - HeapFree(GetProcessHeap(), 0, rch); - } - } - else - { - WARN("Attempt to remove non-installed CtrlHandler %p\n", func); - ret = FALSE; - } + if (! ch) + { + WARN("Attempt to remove non-installed CtrlHandler %p\n", func); + WARN("SetLastError() used guessed-at value\n"); + SetLastError(ERROR_INVALID_ADDRESS); + ret = FALSE; + } + } RtlLeaveCriticalSection(&CONSOLE_CritSect); } return ret;