Fixed a bunch more compiler warnings in the 1.2 branch. SDL-1.2
authorRyan C. Gordon <icculus@icculus.org>
Thu, 13 Oct 2011 16:38:05 -0400
branchSDL-1.2
changeset 5988 bf927e528813
parent 5987 825e1072eac6
child 6047 54b2716f595d
Fixed a bunch more compiler warnings in the 1.2 branch.
src/cdrom/beos/SDL_syscdrom.cc
src/file/SDL_rwops.c
src/video/SDL_bmp.c
src/video/wincommon/SDL_sysevents.c
src/video/windx5/SDL_dx5video.c
--- 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;
--- 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");
--- 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;
--- 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;
 }
--- 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;