We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4100 - errors and warnings after changeset 11917
Summary: errors and warnings after changeset 11917
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: HG 2.0
Hardware: All Windows (All)
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords: target-2.0.10
Depends on:
Blocks:
 
Reported: 2018-03-02 20:02 UTC by Ozkan Sezer
Modified: 2019-06-12 03:32 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ozkan Sezer 2018-03-02 20:02:37 UTC
http://hg.libsdl.org/SDL/rev/5ce3f8bf8381 resulted in an error and
two warnings when compiled with mingw.

1.  Error from SDL_windowstaskdialog.h:
In file included from src/video/windows/SDL_windowsmessagebox.c:29:0:
src/video/windows/SDL_windowstaskdialog.h:23:54: error: expected ')' before 'HWND'

This is fixed by removing unnecessary annotations:

diff --git a/src/video/windows/SDL_windowstaskdialog.h b/src/video/windows/SDL_windowstaskdialog.h
--- a/src/video/windows/SDL_windowstaskdialog.h
+++ b/src/video/windows/SDL_windowstaskdialog.h
@@ -20,7 +20,7 @@
 */
 #include <pshpack1.h>
 
-typedef HRESULT(CALLBACK *PFTASKDIALOGCALLBACK)(_In_ HWND hwnd, _In_ UINT msg, _In_ WPARAM wParam, _In_ LPARAM lParam, _In_ LONG_PTR lpRefData);
+typedef HRESULT(CALLBACK *PFTASKDIALOGCALLBACK)(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, LONG_PTR lpRefData);
 
 enum _TASKDIALOG_FLAGS
 {


2.  Warning from SDL_assert.c:
src/SDL_assert.c: In function 'SDL_ExitProcess':
src/SDL_assert.c:138:1: warning: 'noreturn' function does return

Indeed ExitProcess() is prototyped with DECLSPEC_NORETURN, but
TerminateProcess() is not.  This can be rectified by adding an
exit() call in there. Do NOTE, however, that requires building
with a libc:

diff --git a/src/SDL_assert.c b/src/SDL_assert.c
--- a/src/SDL_assert.c
+++ b/src/SDL_assert.c
@@ -127,7 +127,7 @@ static SDL_NORETURN void SDL_ExitProcess
        better to call TerminateProcess than ExitProcess"
        https://msdn.microsoft.com/en-us/library/windows/desktop/ms682658(v=vs.85).aspx */
     TerminateProcess(GetCurrentProcess(), exitcode);
-
+    exit(exitcode);
 #elif defined(__EMSCRIPTEN__)
     emscripten_cancel_main_loop();  /* this should "kill" the app. */
     emscripten_force_exit(exitcode);  /* this should "kill" the app. */


3.  Warning from SDL_windowsmessagebox.c:
src/video/windows/SDL_windowsmessagebox.c: In function 'WIN_ShowMessageBox':
src/video/windows/SDL_windowsmessagebox.c:513:9: warning: 'nCancelButton' may be used uninitialized in this function

My lazy solution was manually initializing nCancelButton to 0.
Please review the code yourself for a possible better / correct
fix.
diff --git a/src/video/windows/SDL_windowsmessagebox.c b/src/video/windows/SDL_windowsmessagebox.c
--- a/src/video/windows/SDL_windowsmessagebox.c
+++ b/src/video/windows/SDL_windowsmessagebox.c
@@ -560,6 +560,7 @@ WIN_ShowMessageBox(const SDL_MessageBoxD
     TaskConfig.cButtons = messageboxdata->numbuttons;
     pButtons = SDL_malloc(sizeof (TASKDIALOG_BUTTON) * messageboxdata->numbuttons);
     TaskConfig.nDefaultButton = 0;
+    nCancelButton = 0;
     for (i = 0; i < messageboxdata->numbuttons; i++)
     {
         pButton = &pButtons[messageboxdata->numbuttons-1-i];
Comment 1 Sam Lantinga 2018-03-03 06:54:26 UTC
Ryan, can you review the messagebox code? That logic for the cancel button looks wrong to me.

I've committed fixes for the warnings:
https://hg.libsdl.org/SDL/rev/c8b4a5166613

Thanks!
Comment 2 Ryan C. Gordon 2018-03-03 14:00:51 UTC
(In reply to Sam Lantinga from comment #1)
> I've committed fixes for the warnings:
> https://hg.libsdl.org/SDL/rev/c8b4a5166613

The SDL_NORETURN tells the static analyzer that SDL_assert() enforces the conditions it checks, so it can't be removed. I'll put in a hack for mingw.

--ryan.
Comment 3 Ryan C. Gordon 2019-05-18 18:48:54 UTC
Tagging a bunch of bugs with "target-2.0.10" so we have a clear list of things to address before a 2.0.10 release.

Please note that "addressing" one of these bugs might mean deciding to defer on it until after 2.0.10, or resolving it as WONTFIX, etc. This is just here to tell us we should look at it carefully, and soon.

If you have new information or feedback on this issue, this is a good time to add it to the conversation, as we're likely to be paying attention to this specific report in the next few days/weeks.

Thanks!

--ryan.
Comment 4 Ryan C. Gordon 2019-06-12 03:32:37 UTC
The noreturn thing is handled in https://hg.libsdl.org/SDL/rev/8a0e446a4cf9 ...this _should_ still placate MingW, please reopen if not!

--ryan.