Browse Source

Fixed Visual Studio warning 4389

Sam Lantinga 2 years ago
parent
commit
0bd77a5b93

+ 5 - 5
src/audio/SDL_audio.c

@@ -666,7 +666,7 @@ static int SDLCALL SDL_RunAudio(void *devicep)
 
         /* Fill the current buffer with sound */
         if (!device->stream && SDL_AtomicGet(&device->enabled)) {
-            SDL_assert(data_len == device->spec.size);
+            SDL_assert((Uint32)data_len == device->spec.size);
             data = current_audio.impl.GetDeviceBuf(device);
         } else {
             /* if the device isn't enabled, we still write to the
@@ -700,13 +700,13 @@ static int SDLCALL SDL_RunAudio(void *devicep)
                 int got;
                 data = SDL_AtomicGet(&device->enabled) ? current_audio.impl.GetDeviceBuf(device) : NULL;
                 got = SDL_GetAudioStreamData(device->stream, data ? data : device->work_buffer, device->spec.size);
-                SDL_assert((got <= 0) || (got == device->spec.size));
+                SDL_assert((got <= 0) || ((Uint32)got == device->spec.size));
 
                 if (data == NULL) { /* device is having issues... */
                     const Uint32 delay = ((device->spec.samples * 1000) / device->spec.freq);
                     SDL_Delay(delay); /* wait for as long as this buffer would have played. Maybe device recovers later? */
                 } else {
-                    if (got != device->spec.size) {
+                    if ((Uint32)got != device->spec.size) {
                         SDL_memset(data, device->spec.silence, device->spec.size);
                     }
                     current_audio.impl.PlayDevice(device);
@@ -814,8 +814,8 @@ static int SDLCALL SDL_CaptureAudio(void *devicep)
 
             while (SDL_GetAudioStreamAvailable(device->stream) >= ((int)device->callbackspec.size)) {
                 const int got = SDL_GetAudioStreamData(device->stream, device->work_buffer, device->callbackspec.size);
-                SDL_assert((got < 0) || (got == device->callbackspec.size));
-                if (got != device->callbackspec.size) {
+                SDL_assert((got < 0) || ((Uint32)got == device->callbackspec.size));
+                if ((Uint32)got != device->callbackspec.size) {
                     SDL_memset(device->work_buffer, device->spec.silence, device->callbackspec.size);
                 }
 

+ 1 - 1
src/audio/directsound/SDL_directsound.c

@@ -328,7 +328,7 @@ static int DSOUND_CaptureFromDevice(_THIS, void *buffer, int buflen)
     DWORD junk, cursor, ptr1len, ptr2len;
     VOID *ptr1, *ptr2;
 
-    SDL_assert(buflen == this->spec.size);
+    SDL_assert((Uint32)buflen == this->spec.size);
 
     while (SDL_TRUE) {
         if (SDL_AtomicGet(&this->shutdown)) { /* in case the buffer froze... */

+ 1 - 1
src/audio/wasapi/SDL_wasapi.c

@@ -448,7 +448,7 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream)
     this->spec.freq = waveformat->nSamplesPerSec;  /* force sampling rate so our resampler kicks in, if necessary. */
 #else
     /* favor WASAPI's resampler over our own */
-    if (this->spec.freq != waveformat->nSamplesPerSec) {
+    if ((DWORD)this->spec.freq != waveformat->nSamplesPerSec) {
         streamflags |= (AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY);
         waveformat->nSamplesPerSec = this->spec.freq;
         waveformat->nAvgBytesPerSec = waveformat->nSamplesPerSec * waveformat->nChannels * (waveformat->wBitsPerSample / 8);

+ 4 - 3
src/joystick/SDL_gamepad.c

@@ -1472,14 +1472,15 @@ int SDL_AddGamepadMappingsFromRW(SDL_RWops *rw, int freerw)
     const char *platform = SDL_GetPlatform();
     int gamepads = 0;
     char *buf, *line, *line_end, *tmp, *comma, line_platform[64];
-    size_t db_size, platform_len;
+    Sint64 db_size;
+    size_t platform_len;
 
     if (rw == NULL) {
         return SDL_SetError("Invalid RWops");
     }
-    db_size = (size_t)SDL_RWsize(rw);
+    db_size = SDL_RWsize(rw);
 
-    buf = (char *)SDL_malloc(db_size + 1);
+    buf = (char *)SDL_malloc((size_t)db_size + 1);
     if (buf == NULL) {
         if (freerw) {
             SDL_RWclose(rw);

+ 1 - 1
src/libm/e_pow.c

@@ -139,7 +139,7 @@ double attribute_hidden __ieee754_pow(double x, double y)
 		k = (iy>>20)-0x3ff;	   /* exponent */
 		if(k>20) {
 		    j = ly>>(52-k);
-		    if((j<<(52-k))==ly) yisint = 2-(j&1);
+		    if(((u_int32_t)j<<(52-k))==ly) yisint = 2-(j&1);
 		} else if(ly==0) {
 		    j = iy>>(20-k);
 		    if((j<<(20-k))==iy) yisint = 2-(j&1);

+ 1 - 1
src/libm/e_sqrt.c

@@ -149,7 +149,7 @@ double attribute_hidden __ieee754_sqrt(double x)
 	    t  = s0;
 	    if((t<ix0)||((t==ix0)&&(t1<=ix1))) {
 		s1  = t1+r;
-		if(((t1&sign)==sign)&&(s1&sign)==0) s0 += 1;
+		if(((t1&sign)==(u_int32_t)sign)&&(s1&sign)==0) s0 += 1;
 		ix0 -= t;
 		if (ix1 < t1) ix0 -= 1;
 		ix1 -= t1;

+ 1 - 1
src/render/direct3d11/SDL_render_d3d11.c

@@ -1290,7 +1290,7 @@ static int D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Tex
     src = (const Uint8 *)pixels;
     dst = textureMemory.pData;
     length = w * bpp;
-    if (length == pitch && length == textureMemory.RowPitch) {
+    if (length == (UINT)pitch && length == textureMemory.RowPitch) {
         SDL_memcpy(dst, src, (size_t)length * h);
     } else {
         if (length > (UINT)pitch) {

+ 1 - 1
src/render/opengles2/SDL_render_gles2.c

@@ -1579,7 +1579,7 @@ static int GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoff
     /* Reformat the texture data into a tightly packed array */
     src_pitch = (size_t)width * bpp;
     src = (Uint8 *)pixels;
-    if (pitch != src_pitch) {
+    if ((size_t)pitch != src_pitch) {
         blob = (Uint8 *)SDL_malloc(src_pitch * height);
         if (blob == NULL) {
             return SDL_OutOfMemory();

+ 1 - 1
src/stdlib/SDL_string.c

@@ -576,7 +576,7 @@ SDL_utf8strlcpy(SDL_OUT_Z_CAP(dst_bytes) char *dst, const char *src, size_t dst_
                 c = (unsigned char)src[i];
                 trailing_bytes = UTF8_GetTrailingBytes(c);
                 if (trailing_bytes) {
-                    if (bytes - i != trailing_bytes + 1) {
+                    if ((bytes - i) != ((size_t)trailing_bytes + 1)) {
                         bytes = i;
                     }
 

+ 1 - 1
src/video/SDL_video.c

@@ -4698,7 +4698,7 @@ static SDL_bool SDL_IsMessageboxValidForDriver(const SDL_MessageBoxData *message
     if (window == NULL || SDL_GetWindowWMInfo(window, &info, SDL_SYSWM_CURRENT_VERSION) < 0) {
         return SDL_TRUE;
     } else {
-        return info.subsystem == drivertype;
+        return info.subsystem == (Uint32)drivertype;
     }
 }
 #endif

+ 1 - 1
src/video/windows/SDL_windowskeyboard.c

@@ -1673,7 +1673,7 @@ static void IME_RenderCandidateList(SDL_VideoData *videodata, HDC hdc)
             bottom = size.cy - listborder - listpadding - candmargin;
         }
 
-        if (i == videodata->ime_candsel) {
+        if ((DWORD)i == videodata->ime_candsel) {
             SelectObject(hdc, selpen);
             SelectObject(hdc, selbrush);
             SetTextColor(hdc, seltextcolor);

+ 1 - 1
src/video/yuv2rgb/yuv_rgb_sse_func.h

@@ -491,7 +491,7 @@ void SDL_TARGETING("sse2") SSE_FUNCTION_NAME(uint32_t width, uint32_t height,
 
 	/* Catch the right column, if needed */
 	{
-		int converted = (width & ~31);
+		uint32_t converted = (width & ~31);
 		if (fix_read_nv12) {
 			converted -= 32;
 		}