mirror of https://github.com/libsdl-org/SDL
Check standard error code return values as < 0 instead of == -1
This commit is contained in:
parent
46d9066a69
commit
037541a0e0
|
@ -1723,7 +1723,7 @@ SDL_AudioDeviceID SDL_OpenAudioDevice(SDL_AudioDeviceID devid, const SDL_AudioSp
|
|||
SDL_SetError("Device was already lost and can't accept new opens");
|
||||
} else if ((logdev = (SDL_LogicalAudioDevice *) SDL_calloc(1, sizeof (SDL_LogicalAudioDevice))) == NULL) {
|
||||
/* SDL_calloc already called SDL_OutOfMemory */
|
||||
} else if (OpenPhysicalAudioDevice(device, spec) == -1) { // if this is the first thing using this physical device, open at the OS level if necessary...
|
||||
} else if (OpenPhysicalAudioDevice(device, spec) < 0) { // if this is the first thing using this physical device, open at the OS level if necessary...
|
||||
SDL_free(logdev);
|
||||
} else {
|
||||
RefPhysicalAudioDevice(device); // unref'd on successful SDL_CloseAudioDevice
|
||||
|
@ -2267,7 +2267,7 @@ void SDL_DefaultAudioDeviceChanged(SDL_AudioDevice *new_default_device)
|
|||
|
||||
if (needs_migration) {
|
||||
// New default physical device not been opened yet? Open at the OS level...
|
||||
if (OpenPhysicalAudioDevice(new_default_device, &spec) == -1) {
|
||||
if (OpenPhysicalAudioDevice(new_default_device, &spec) < 0) {
|
||||
needs_migration = SDL_FALSE; // uhoh, just leave everything on the old default, nothing to be done.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -383,7 +383,7 @@ static int UpdateAudioStreamInputSpec(SDL_AudioStream *stream, const SDL_AudioSp
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (SDL_ResetAudioQueueHistory(stream->queue, SDL_GetResamplerHistoryFrames()) != 0) {
|
||||
if (SDL_ResetAudioQueueHistory(stream->queue, SDL_GetResamplerHistoryFrames()) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -428,7 +428,7 @@ SDL_AudioStream *SDL_CreateAudioStream(const SDL_AudioSpec *src_spec, const SDL_
|
|||
|
||||
OnAudioStreamCreated(retval);
|
||||
|
||||
if (SDL_SetAudioStreamFormat(retval, src_spec, dst_spec) == -1) {
|
||||
if (SDL_SetAudioStreamFormat(retval, src_spec, dst_spec) < 0) {
|
||||
SDL_DestroyAudioStream(retval);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1338,7 +1338,7 @@ int SDL_ConvertAudioSamples(const SDL_AudioSpec *src_spec, const Uint8 *src_data
|
|||
}
|
||||
}
|
||||
|
||||
if (retval == -1) {
|
||||
if (retval < 0) {
|
||||
SDL_free(dst);
|
||||
} else {
|
||||
*dst_data = dst;
|
||||
|
|
|
@ -703,14 +703,14 @@ static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
|
|||
|
||||
/* Initialize decoder with the values from the block header. */
|
||||
result = MS_ADPCM_DecodeBlockHeader(&state);
|
||||
if (result == -1) {
|
||||
if (result < 0) {
|
||||
SDL_free(state.output.data);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Decode the block data. It stores the samples directly in the output. */
|
||||
result = MS_ADPCM_DecodeBlockData(&state);
|
||||
if (result == -1) {
|
||||
if (result < 0) {
|
||||
/* Unexpected end. Stop decoding and return partial data if necessary. */
|
||||
if (file->trunchint == TruncVeryStrict || file->trunchint == TruncStrict) {
|
||||
SDL_free(state.output.data);
|
||||
|
@ -1105,7 +1105,7 @@ static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len
|
|||
result = IMA_ADPCM_DecodeBlockData(&state);
|
||||
}
|
||||
|
||||
if (result == -1) {
|
||||
if (result < 0) {
|
||||
/* Unexpected end. Stop decoding and return partial data if necessary. */
|
||||
if (file->trunchint == TruncVeryStrict || file->trunchint == TruncStrict) {
|
||||
SDL_free(state.output.data);
|
||||
|
@ -1860,7 +1860,7 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint
|
|||
}
|
||||
|
||||
result = WaveNextChunk(src, chunk);
|
||||
if (result == -1) {
|
||||
if (result < 0) {
|
||||
/* Unexpected EOF. Corrupt file or I/O issues. */
|
||||
if (file->trunchint == TruncVeryStrict) {
|
||||
return SDL_SetError("Unexpected end of WAVE file");
|
||||
|
@ -1985,7 +1985,7 @@ static int WaveLoad(SDL_IOStream *src, WaveFile *file, SDL_AudioSpec *spec, Uint
|
|||
|
||||
if (chunk->length > 0) {
|
||||
result = WaveReadChunkData(src, chunk);
|
||||
if (result == -1) {
|
||||
if (result < 0) {
|
||||
return -1;
|
||||
} else if (result == -2) {
|
||||
return SDL_SetError("Could not seek data of WAVE data chunk");
|
||||
|
|
|
@ -157,7 +157,7 @@ int WASAPI_ProxyToManagementThread(ManagementThreadTask task, void *userdata, in
|
|||
|
||||
static int ManagementThreadPrepare(void)
|
||||
{
|
||||
if (WASAPI_PlatformInit() == -1) {
|
||||
if (WASAPI_PlatformInit() < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -402,7 +402,7 @@ static SDL_bool RecoverWasapiDevice(SDL_AudioDevice *device)
|
|||
ResetWasapiDevice(device); // dump the lost device's handles.
|
||||
|
||||
// This handles a non-default device that simply had its format changed in the Windows Control Panel.
|
||||
if (ActivateWasapiDevice(device) == -1) {
|
||||
if (ActivateWasapiDevice(device) < 0) {
|
||||
WASAPI_DisconnectDevice(device);
|
||||
return SDL_FALSE;
|
||||
}
|
||||
|
|
|
@ -179,7 +179,7 @@ int WASAPI_ActivateDevice(SDL_AudioDevice *device)
|
|||
}
|
||||
|
||||
SDL_assert(device->hidden->client != NULL);
|
||||
if (WASAPI_PrepDevice(device) == -1) { // not async, fire it right away.
|
||||
if (WASAPI_PrepDevice(device) < 0) { // not async, fire it right away.
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -468,7 +468,7 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame,
|
|||
} else {
|
||||
frame->pixels = pixels;
|
||||
frame->pitch = (int) pitch;
|
||||
if (SDL_SetPointerPropertyWithCleanup(surfprops, PROP_SURFACE_IMFOBJS_POINTER, objs, CleanupIMF2DBuffer2, NULL) == -1) {
|
||||
if (SDL_SetPointerPropertyWithCleanup(surfprops, PROP_SURFACE_IMFOBJS_POINTER, objs, CleanupIMF2DBuffer2, NULL) < 0) {
|
||||
retval = -1;
|
||||
}
|
||||
}
|
||||
|
@ -480,7 +480,7 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame,
|
|||
} else {
|
||||
frame->pixels = pixels;
|
||||
frame->pitch = (int) pitch;
|
||||
if (SDL_SetPointerPropertyWithCleanup(surfprops, PROP_SURFACE_IMFOBJS_POINTER, objs, CleanupIMF2DBuffer, NULL) == -1) {
|
||||
if (SDL_SetPointerPropertyWithCleanup(surfprops, PROP_SURFACE_IMFOBJS_POINTER, objs, CleanupIMF2DBuffer, NULL) < 0) {
|
||||
retval = -1;
|
||||
}
|
||||
}
|
||||
|
@ -497,7 +497,7 @@ static int MEDIAFOUNDATION_AcquireFrame(SDL_Camera *device, SDL_Surface *frame,
|
|||
}
|
||||
frame->pixels = pixels;
|
||||
frame->pitch = (int) pitch;
|
||||
if (SDL_SetPointerPropertyWithCleanup(surfprops, PROP_SURFACE_IMFOBJS_POINTER, objs, CleanupIMFMediaBuffer, NULL) == -1) {
|
||||
if (SDL_SetPointerPropertyWithCleanup(surfprops, PROP_SURFACE_IMFOBJS_POINTER, objs, CleanupIMFMediaBuffer, NULL) < 0) {
|
||||
retval = -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -411,7 +411,7 @@ int SDL_CreateHapticEffect(SDL_Haptic *haptic, const SDL_HapticEffect *effect)
|
|||
if (haptic->effects[i].hweffect == NULL) {
|
||||
|
||||
/* Now let the backend create the real effect */
|
||||
if (SDL_SYS_HapticNewEffect(haptic, &haptic->effects[i], effect) != 0) {
|
||||
if (SDL_SYS_HapticNewEffect(haptic, &haptic->effects[i], effect) < 0) {
|
||||
return -1; /* Backend failed to create effect */
|
||||
}
|
||||
|
||||
|
|
|
@ -1303,7 +1303,7 @@ Uint32 SDL_hid_device_change_count(void)
|
|||
Uint32 counter = 0;
|
||||
|
||||
#ifndef SDL_HIDAPI_DISABLED
|
||||
if (SDL_hidapi_refcount == 0 && SDL_hid_init() != 0) {
|
||||
if (SDL_hidapi_refcount == 0 && SDL_hid_init() < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1414,7 +1414,7 @@ struct SDL_hid_device_info *SDL_hid_enumerate(unsigned short vendor_id, unsigned
|
|||
struct hid_device_info *dev;
|
||||
struct SDL_hid_device_info *devs = NULL, *last = NULL;
|
||||
|
||||
if (SDL_hidapi_refcount == 0 && SDL_hid_init() != 0) {
|
||||
if (SDL_hidapi_refcount == 0 && SDL_hid_init() < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1504,7 +1504,7 @@ SDL_hid_device *SDL_hid_open(unsigned short vendor_id, unsigned short product_id
|
|||
#if defined(HAVE_PLATFORM_BACKEND) || defined(HAVE_DRIVER_BACKEND) || defined(HAVE_LIBUSB)
|
||||
void *pDevice = NULL;
|
||||
|
||||
if (SDL_hidapi_refcount == 0 && SDL_hid_init() != 0) {
|
||||
if (SDL_hidapi_refcount == 0 && SDL_hid_init() < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1543,7 +1543,7 @@ SDL_hid_device *SDL_hid_open_path(const char *path)
|
|||
#if defined(HAVE_PLATFORM_BACKEND) || defined(HAVE_DRIVER_BACKEND) || defined(HAVE_LIBUSB)
|
||||
void *pDevice = NULL;
|
||||
|
||||
if (SDL_hidapi_refcount == 0 && SDL_hid_init() != 0) {
|
||||
if (SDL_hidapi_refcount == 0 && SDL_hid_init() < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -1079,7 +1079,7 @@ static int HIDAPI_DriverPS5_InternalSendJoystickEffect(SDL_DriverPS5_Context *ct
|
|||
SDL_memcpy(&data[report_size - sizeof(unCRC)], &unCRC, sizeof(unCRC));
|
||||
}
|
||||
|
||||
if (SDL_HIDAPI_LockRumble() != 0) {
|
||||
if (SDL_HIDAPI_LockRumble() < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -256,7 +256,7 @@ int SDL_HIDAPI_SendRumble(SDL_HIDAPI_Device *device, const Uint8 *data, int size
|
|||
return SDL_SetError("Tried to send rumble with invalid size");
|
||||
}
|
||||
|
||||
if (SDL_HIDAPI_LockRumble() != 0) {
|
||||
if (SDL_HIDAPI_LockRumble() < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ static int HIDAPI_DriverShield_SendCommand(SDL_HIDAPI_Device *device, Uint8 cmd,
|
|||
return SDL_SetError("Command data exceeds HID report size");
|
||||
}
|
||||
|
||||
if (SDL_HIDAPI_LockRumble() != 0) {
|
||||
if (SDL_HIDAPI_LockRumble() < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@ static SDL_bool WriteOutput(SDL_DriverWii_Context *ctx, const Uint8 *data, int s
|
|||
return SDL_hid_write(ctx->device->dev, data, size) >= 0;
|
||||
} else {
|
||||
/* Use the rumble thread for general asynchronous writes */
|
||||
if (SDL_HIDAPI_LockRumble() != 0) {
|
||||
if (SDL_HIDAPI_LockRumble() < 0) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
return SDL_HIDAPI_SendRumbleAndUnlock(ctx->device, data, size) >= 0;
|
||||
|
|
|
@ -235,7 +235,7 @@ static SDL_bool SendProtocolPacket(SDL_DriverXboxOne_Context *ctx, const Uint8 *
|
|||
|
||||
ctx->send_time = SDL_GetTicks();
|
||||
|
||||
if (SDL_HIDAPI_LockRumble() != 0) {
|
||||
if (SDL_HIDAPI_LockRumble() < 0) {
|
||||
return SDL_FALSE;
|
||||
}
|
||||
if (SDL_HIDAPI_SendRumbleAndUnlock(ctx->device, data, size) != size) {
|
||||
|
@ -470,7 +470,7 @@ static int HIDAPI_DriverXboxOne_UpdateRumble(SDL_DriverXboxOne_Context *ctx)
|
|||
/* We're no longer pending, even if we fail to send the rumble below */
|
||||
ctx->rumble_pending = SDL_FALSE;
|
||||
|
||||
if (SDL_HIDAPI_LockRumble() != 0) {
|
||||
if (SDL_HIDAPI_LockRumble() < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ SDL_AppResult SDL_InitMainCallbacks(int argc, char* argv[], SDL_AppInit_func app
|
|||
const SDL_AppResult rc = appinit(&SDL_main_appstate, argc, argv);
|
||||
if (SDL_AtomicCompareAndSwap(&apprc, SDL_APP_CONTINUE, rc) && (rc == SDL_APP_CONTINUE)) { // bounce if SDL_AppInit already said abort, otherwise...
|
||||
// make sure we definitely have events initialized, even if the app didn't do it.
|
||||
if (SDL_InitSubSystem(SDL_INIT_EVENTS) == -1) {
|
||||
if (SDL_InitSubSystem(SDL_INIT_EVENTS) < 0) {
|
||||
SDL_AtomicSet(&apprc, SDL_APP_FAILURE);
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -351,7 +351,7 @@ static int FlushRenderCommandsIfTextureNeeded(SDL_Texture *texture)
|
|||
|
||||
int SDL_FlushRenderer(SDL_Renderer *renderer)
|
||||
{
|
||||
if (FlushRenderCommands(renderer) == -1) {
|
||||
if (FlushRenderCommands(renderer) < 0) {
|
||||
return -1;
|
||||
}
|
||||
renderer->InvalidateCachedState(renderer);
|
||||
|
@ -1001,7 +1001,7 @@ SDL_Renderer *SDL_CreateRendererWithProperties(SDL_PropertiesID props)
|
|||
#else
|
||||
const int rc = SDL_SetError("SDL not built with software renderer");
|
||||
#endif
|
||||
if (rc == -1) {
|
||||
if (rc < 0) {
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
|
@ -1034,7 +1034,7 @@ SDL_Renderer *SDL_CreateRendererWithProperties(SDL_PropertiesID props)
|
|||
}
|
||||
}
|
||||
|
||||
if (rc == -1) {
|
||||
if (rc < 0) {
|
||||
if (!name || !attempted) {
|
||||
SDL_SetError("Couldn't find matching render driver");
|
||||
}
|
||||
|
|
|
@ -1228,7 +1228,7 @@ EGLSurface SDL_EGL_CreateSurface(SDL_VideoDevice *_this, SDL_Window *window, Nat
|
|||
|
||||
EGLSurface surface;
|
||||
|
||||
if (SDL_EGL_ChooseConfig(_this) != 0) {
|
||||
if (SDL_EGL_ChooseConfig(_this) < 0) {
|
||||
return EGL_NO_SURFACE;
|
||||
}
|
||||
|
||||
|
@ -1319,7 +1319,7 @@ SDL_EGL_CreateOffscreenSurface(SDL_VideoDevice *_this, int width, int height)
|
|||
attributes[1] = width;
|
||||
attributes[3] = height;
|
||||
|
||||
if (SDL_EGL_ChooseConfig(_this) != 0) {
|
||||
if (SDL_EGL_ChooseConfig(_this) < 0) {
|
||||
return EGL_NO_SURFACE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1174,7 +1174,7 @@ int SDL_ConvertPixels_RGB_to_YUV(int width, int height,
|
|||
|
||||
/* convert src/src_format to tmp/XBGR2101010 */
|
||||
ret = SDL_ConvertPixelsAndColorspace(width, height, src_format, src_colorspace, src_properties, src, src_pitch, SDL_PIXELFORMAT_XBGR2101010, dst_colorspace, dst_properties, tmp, tmp_pitch);
|
||||
if (ret == -1) {
|
||||
if (ret < 0) {
|
||||
SDL_free(tmp);
|
||||
return ret;
|
||||
}
|
||||
|
@ -1198,7 +1198,7 @@ int SDL_ConvertPixels_RGB_to_YUV(int width, int height,
|
|||
|
||||
/* convert src/src_format to tmp/ARGB8888 */
|
||||
ret = SDL_ConvertPixelsAndColorspace(width, height, src_format, src_colorspace, src_properties, src, src_pitch, SDL_PIXELFORMAT_ARGB8888, dst_colorspace, dst_properties, tmp, tmp_pitch);
|
||||
if (ret == -1) {
|
||||
if (ret < 0) {
|
||||
SDL_free(tmp);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
|
|||
}
|
||||
|
||||
/* Load the wave file into memory */
|
||||
if (SDL_LoadWAV(filename, &wave.spec, &wave.sound, &wave.soundlen) == -1) {
|
||||
if (SDL_LoadWAV(filename, &wave.spec, &wave.sound, &wave.soundlen) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError());
|
||||
SDL_free(filename);
|
||||
return SDL_APP_FAILURE;
|
||||
|
|
|
@ -167,7 +167,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
/* Load the wave file into memory */
|
||||
if (SDL_LoadWAV(filename, &spec, &sound, &soundlen) == -1) {
|
||||
if (SDL_LoadWAV(filename, &spec, &sound, &soundlen) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError());
|
||||
quit(1);
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv)
|
|||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create an audio stream for playback: %s!\n", SDL_GetError());
|
||||
SDL_free(devices);
|
||||
return SDL_APP_FAILURE;
|
||||
} else if (SDL_BindAudioStream(device, stream_out) == -1) {
|
||||
} else if (SDL_BindAudioStream(device, stream_out) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't bind an audio stream for playback: %s!\n", SDL_GetError());
|
||||
SDL_free(devices);
|
||||
return SDL_APP_FAILURE;
|
||||
|
@ -137,7 +137,7 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv)
|
|||
if (!stream_in) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create an audio stream for recording: %s!\n", SDL_GetError());
|
||||
return SDL_APP_FAILURE;
|
||||
} else if (SDL_BindAudioStream(device, stream_in) == -1) {
|
||||
} else if (SDL_BindAudioStream(device, stream_in) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't bind an audio stream for recording: %s!\n", SDL_GetError());
|
||||
return SDL_APP_FAILURE;
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ int main(int argc, char *argv[])
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (SDL_Init(0) == -1) {
|
||||
if (SDL_Init(0) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
|
@ -130,19 +130,19 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
|
||||
/* !!! FIXME: put this in a subroutine and make it test more thoroughly (and put it in testautomation). */
|
||||
if (SDL_CreateDirectory("testfilesystem-test") == -1) {
|
||||
if (SDL_CreateDirectory("testfilesystem-test") < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_CreateDirectory('testfilesystem-test') failed: %s", SDL_GetError());
|
||||
} else if (SDL_CreateDirectory("testfilesystem-test/1") == -1) {
|
||||
} else if (SDL_CreateDirectory("testfilesystem-test/1") < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_CreateDirectory('testfilesystem-test/1') failed: %s", SDL_GetError());
|
||||
} else if (SDL_CreateDirectory("testfilesystem-test/1") == -1) { /* THIS SHOULD NOT FAIL! Making a directory that already exists should succeed here. */
|
||||
} else if (SDL_CreateDirectory("testfilesystem-test/1") < 0) { /* THIS SHOULD NOT FAIL! Making a directory that already exists should succeed here. */
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_CreateDirectory('testfilesystem-test/1') failed: %s", SDL_GetError());
|
||||
} else if (SDL_RenamePath("testfilesystem-test/1", "testfilesystem-test/2") == -1) {
|
||||
} else if (SDL_RenamePath("testfilesystem-test/1", "testfilesystem-test/2") < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_RenamePath('testfilesystem-test/1', 'testfilesystem-test/2') failed: %s", SDL_GetError());
|
||||
} else if (SDL_RemovePath("testfilesystem-test/2") == -1) {
|
||||
} else if (SDL_RemovePath("testfilesystem-test/2") < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_RemovePath('testfilesystem-test/2') failed: %s", SDL_GetError());
|
||||
} else if (SDL_RemovePath("testfilesystem-test") == -1) {
|
||||
} else if (SDL_RemovePath("testfilesystem-test") < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_RemovePath('testfilesystem-test') failed: %s", SDL_GetError());
|
||||
} else if (SDL_RemovePath("testfilesystem-test") == -1) { /* THIS SHOULD NOT FAIL! Removing a directory that is already gone should succeed here. */
|
||||
} else if (SDL_RemovePath("testfilesystem-test") < 0) { /* THIS SHOULD NOT FAIL! Removing a directory that is already gone should succeed here. */
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_RemovePath('testfilesystem-test') failed: %s", SDL_GetError());
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
for (i = 0; i < state->num_windows; i++) {
|
||||
if (SDL_SetWindowHitTest(state->windows[i], hitTest, NULL) == -1) {
|
||||
if (SDL_SetWindowHitTest(state->windows[i], hitTest, NULL) < 0) {
|
||||
SDL_Log("Enabling hit-testing failed for window %d: %s", i, SDL_GetError());
|
||||
SDL_Quit();
|
||||
return 1;
|
||||
|
|
|
@ -126,7 +126,7 @@ int main(int argc, char *argv[])
|
|||
haptic = SDL_OpenHapticFromJoystick(joystick);
|
||||
if (haptic) {
|
||||
SDL_Log("Joy Haptic Opened\n");
|
||||
if (SDL_InitHapticRumble(haptic) != 0) {
|
||||
if (SDL_InitHapticRumble(haptic) < 0) {
|
||||
SDL_Log("Could not init Rumble!: %s\n", SDL_GetError());
|
||||
SDL_CloseHaptic(haptic);
|
||||
haptic = NULL;
|
||||
|
|
|
@ -361,7 +361,7 @@ static int unifont_load_texture(Uint32 textureID)
|
|||
}
|
||||
unifontTexture[UNIFONT_NUM_TEXTURES * i + textureID] = tex;
|
||||
SDL_SetTextureBlendMode(tex, SDL_BLENDMODE_BLEND);
|
||||
if (SDL_UpdateTexture(tex, NULL, textureRGBA, UNIFONT_TEXTURE_PITCH) != 0) {
|
||||
if (SDL_UpdateTexture(tex, NULL, textureRGBA, UNIFONT_TEXTURE_PITCH) < 0) {
|
||||
SDL_Log("unifont error: Failed to update texture %" SDL_PRIu32 " data for renderer %d.\n", textureID, i);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,7 +185,7 @@ int main(int argc, char **argv)
|
|||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Don't see any specific audio playback devices!");
|
||||
} else {
|
||||
/* Load the wave file into memory */
|
||||
if (SDL_LoadWAV(filename, &spec, &sound, &soundlen) == -1) {
|
||||
if (SDL_LoadWAV(filename, &spec, &sound, &soundlen) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename,
|
||||
SDL_GetError());
|
||||
} else {
|
||||
|
|
|
@ -95,13 +95,13 @@ int main(int argc, char **argv)
|
|||
goto end;
|
||||
}
|
||||
|
||||
if (SDL_Init(SDL_INIT_AUDIO) == -1) {
|
||||
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_Init() failed: %s\n", SDL_GetError());
|
||||
ret = 2;
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (SDL_LoadWAV(file_in, &spec, &data, &len) == -1) {
|
||||
if (SDL_LoadWAV(file_in, &spec, &data, &len) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "failed to load %s: %s\n", file_in, SDL_GetError());
|
||||
ret = 3;
|
||||
goto end;
|
||||
|
@ -141,7 +141,7 @@ int main(int argc, char **argv)
|
|||
SDL_WriteU32LE(io, dst_len); /* size */
|
||||
SDL_WriteIO(io, dst_buf, dst_len);
|
||||
|
||||
if (SDL_CloseIO(io) == -1) {
|
||||
if (SDL_CloseIO(io) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "closing '%s' failed: %s\n", file_out, SDL_GetError());
|
||||
ret = 6;
|
||||
goto end;
|
||||
|
|
|
@ -136,12 +136,12 @@ int main(int argc, char **argv)
|
|||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Rumble not supported!\n");
|
||||
return 1;
|
||||
}
|
||||
if (SDL_InitHapticRumble(haptic) != 0) {
|
||||
if (SDL_InitHapticRumble(haptic) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to initialize rumble: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
SDL_Log("Playing 2 second rumble at 0.5 magnitude.\n");
|
||||
if (SDL_PlayHapticRumble(haptic, 0.5, 5000) != 0) {
|
||||
if (SDL_PlayHapticRumble(haptic, 0.5, 5000) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ int main(int argc, char **argv)
|
|||
SDL_StopHapticRumble(haptic);
|
||||
SDL_Delay(2000);
|
||||
SDL_Log("Playing 2 second rumble at 0.3 magnitude.\n");
|
||||
if (SDL_PlayHapticRumble(haptic, 0.3f, 5000) != 0) {
|
||||
if (SDL_PlayHapticRumble(haptic, 0.3f, 5000) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to play rumble: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -196,7 +196,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
SDL_Log("Testing audio device: %s\n", devname);
|
||||
|
||||
if (SDL_GetAudioDeviceFormat(devices[i], &spec, NULL) != 0) {
|
||||
if (SDL_GetAudioDeviceFormat(devices[i], &spec, NULL) < 0) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_GetAudioDeviceFormat() failed: %s\n", SDL_GetError());
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ static void tryOpenURL(const char *url)
|
|||
int main(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
if (SDL_Init(SDL_INIT_VIDEO) == -1) {
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
|
||||
SDL_Log("SDL_Init failed: %s\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue