[Commits] SDL: Fixed a bunch more compiler warnings in the 1.2 branch.

libsdl.org revision control commits-owner at libsdl.org
Thu Oct 13 13:40:51 PDT 2011


details:   http://hg.libsdl.org/SDL/rev/bf927e528813
changeset: 5988:bf927e528813
user:      Ryan C. Gordon <icculus at icculus.org>
date:      Thu Oct 13 16:38:05 2011 -0400
description:
Fixed a bunch more compiler warnings in the 1.2 branch.

diffstat:

 src/cdrom/beos/SDL_syscdrom.cc      |   2 --
 src/file/SDL_rwops.c                |   1 +
 src/video/SDL_bmp.c                 |   2 +-
 src/video/wincommon/SDL_sysevents.c |  27 ++++++++++++++++++++-------
 src/video/windx5/SDL_dx5video.c     |   3 ++-
 5 files changed, 24 insertions(+), 11 deletions(-)

diffs (105 lines):

diff -r 825e1072eac6 -r bf927e528813 src/cdrom/beos/SDL_syscdrom.cc
--- a/src/cdrom/beos/SDL_syscdrom.cc	Thu Oct 13 16:35:25 2011 -0400
+++ b/src/cdrom/beos/SDL_syscdrom.cc	Thu Oct 13 16:38:05 2011 -0400
@@ -150,8 +150,6 @@
 int  SDL_SYS_CDInit(void)
 {
 	char *SDLcdrom;
-	int raw_fd;
-	struct ide_ctrl_info info;
 
 	/* Fill in our driver capabilities */
 	SDL_CDcaps.Name = SDL_SYS_CDName;
diff -r 825e1072eac6 -r bf927e528813 src/file/SDL_rwops.c
--- a/src/file/SDL_rwops.c	Thu Oct 13 16:35:25 2011 -0400
+++ b/src/file/SDL_rwops.c	Thu Oct 13 16:38:05 2011 -0400
@@ -485,6 +485,7 @@
 	SDL_RWops *rwops = NULL;
 #ifdef HAVE_STDIO_H
 	FILE *fp = NULL;
+	(void) fp;
 #endif
 	if ( !file || !*file || !mode || !*mode ) {
 		SDL_SetError("SDL_RWFromFile(): No file or no mode specified");
diff -r 825e1072eac6 -r bf927e528813 src/video/SDL_bmp.c
--- a/src/video/SDL_bmp.c	Thu Oct 13 16:35:25 2011 -0400
+++ b/src/video/SDL_bmp.c	Thu Oct 13 16:38:05 2011 -0400
@@ -48,7 +48,7 @@
 SDL_Surface * SDL_LoadBMP_RW (SDL_RWops *src, int freesrc)
 {
 	SDL_bool was_error;
-	long fp_offset;
+	long fp_offset = 0;
 	int bmpPitch;
 	int i, pad;
 	SDL_Surface *surface;
diff -r 825e1072eac6 -r bf927e528813 src/video/wincommon/SDL_sysevents.c
--- a/src/video/wincommon/SDL_sysevents.c	Thu Oct 13 16:35:25 2011 -0400
+++ b/src/video/wincommon/SDL_sysevents.c	Thu Oct 13 16:38:05 2011 -0400
@@ -220,13 +220,13 @@
 static VOID CALLBACK
 TrackMouseTimerProc(HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime)
 {
-	RECT rect;
+	union { RECT rect; POINT pt; } rectpt;  /* prevent type-punning issue. */
 	POINT pt;
 
-	GetClientRect(hWnd, &rect);
-	MapWindowPoints(hWnd, NULL, (LPPOINT)&rect, 2);
+	GetClientRect(hWnd, &rectpt.rect);
+	MapWindowPoints(hWnd, NULL, &rectpt.pt, 2);
 	GetCursorPos(&pt);
-	if ( !PtInRect(&rect, pt) || (WindowFromPoint(pt) != hWnd) ) {
+	if ( !PtInRect(&rectpt.rect, pt) || (WindowFromPoint(pt) != hWnd) ) {
 		if ( !KillTimer(hWnd, idEvent) ) {
 			/* Error killing the timer! */
 		}
@@ -572,11 +572,24 @@
 
 		case WM_WINDOWPOSCHANGED: {
 			SDL_VideoDevice *this = current_video;
+			POINT pt;
 			int w, h;
 
 			GetClientRect(SDL_Window, &SDL_bounds);
-			ClientToScreen(SDL_Window, (LPPOINT)&SDL_bounds);
-			ClientToScreen(SDL_Window, (LPPOINT)&SDL_bounds+1);
+
+			/* avoiding type-punning here... */
+			pt.x = SDL_bounds.left;
+			pt.y = SDL_bounds.top;
+			ClientToScreen(SDL_Window, &pt);
+			SDL_bounds.left = pt.x;
+			SDL_bounds.top = pt.y;
+
+			pt.x = SDL_bounds.right;
+			pt.y = SDL_bounds.bottom;
+			ClientToScreen(SDL_Window, &pt);
+			SDL_bounds.right = pt.x;
+			SDL_bounds.bottom = pt.y;
+
 			if ( !SDL_resizing && !IsZoomed(SDL_Window) &&
 			     SDL_PublicSurface &&
 				!(SDL_PublicSurface->flags & SDL_FULLSCREEN) ) {
@@ -831,7 +844,7 @@
 
 	/* arg #3 should be const BYTE *, but cygwin lists it as PBYTE. */
 	if (ToAsciiEx(vkey, scancode, (PBYTE) keystate, (WORD*)chars, 0, GetKeyboardLayout(0)) == 1) {
-		return MultiByteToWideChar(codepage, 0, chars, 1, wchars, wsize);
+		return MultiByteToWideChar(codepage, 0, (LPCSTR) chars, 1, wchars, wsize);
 	}
 	return 0;
 }
diff -r 825e1072eac6 -r bf927e528813 src/video/windx5/SDL_dx5video.c
--- a/src/video/windx5/SDL_dx5video.c	Thu Oct 13 16:35:25 2011 -0400
+++ b/src/video/windx5/SDL_dx5video.c	Thu Oct 13 16:38:05 2011 -0400
@@ -1034,7 +1034,8 @@
 				int width, int height, int bpp, Uint32 flags)
 {
 	SDL_Surface *video;
-	int prev_w, prev_h;
+	int prev_w = -1;
+	int prev_h = -1;
 	HRESULT result;
 	DWORD sharemode;
 	DWORD style;


More information about the commits mailing list