[SDL2] pointer boolean (#8523)

This commit is contained in:
Sylvain Becker 2023-11-10 15:30:56 +01:00 committed by GitHub
parent 4a3a9f3ad8
commit a14b948b6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
394 changed files with 2564 additions and 2559 deletions

View file

@ -383,7 +383,7 @@ main(int argc, char *argv[])
/* Initialize test framework */
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO | SDL_INIT_AUDIO);
if (state == NULL) {
if (!state) {
return 1;
}
@ -446,7 +446,7 @@ main(int argc, char *argv[])
/* Create the windows, initialize the renderers, and load the textures */
sprites =
(SDL_Texture **) SDL_malloc(state->num_windows * sizeof(*sprites));
if (sprites == NULL) {
if (!sprites) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
quit(2);
}
@ -461,7 +461,7 @@ main(int argc, char *argv[])
soundname = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav");
if (soundname == NULL) {
if (!soundname) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
quit(1);
}

View file

@ -118,7 +118,7 @@ initializeTextures(SDL_Renderer *renderer)
/* load the ship */
bmp_surface = SDL_LoadBMP("ship.bmp");
if (bmp_surface == NULL) {
if (!bmp_surface) {
fatalError("could not ship.bmp");
}
/* set blue to transparent on the ship */
@ -127,7 +127,7 @@ initializeTextures(SDL_Renderer *renderer)
/* create ship texture from surface */
ship = SDL_CreateTextureFromSurface(renderer, bmp_surface);
if (ship == NULL) {
if (!ship) {
fatalError("could not create ship texture");
}
SDL_SetTextureBlendMode(ship, SDL_BLENDMODE_BLEND);
@ -140,12 +140,12 @@ initializeTextures(SDL_Renderer *renderer)
/* load the space background */
bmp_surface = SDL_LoadBMP("space.bmp");
if (bmp_surface == NULL) {
if (!bmp_surface) {
fatalError("could not load space.bmp");
}
/* create space texture from surface */
space = SDL_CreateTextureFromSurface(renderer, bmp_surface);
if (space == NULL) {
if (!space) {
fatalError("could not create space texture");
}
SDL_FreeSurface(bmp_surface);
@ -179,7 +179,7 @@ main(int argc, char *argv[])
printf("There are %d joysticks available\n", SDL_NumJoysticks());
printf("Default joystick (index 0) is %s\n", SDL_JoystickName(0));
accelerometer = SDL_JoystickOpen(0);
if (accelerometer == NULL) {
if (!accelerometer) {
fatalError("Could not open joystick (accelerometer)");
}
printf("joystick number of axis = %d\n",

View file

@ -334,7 +334,7 @@ initializeTexture()
to format passed into OpenGL */
bmp_surface = SDL_LoadBMP("stroke.bmp");
if (bmp_surface == NULL) {
if (!bmp_surface) {
fatalError("could not load stroke.bmp");
}

View file

@ -108,7 +108,7 @@ initializeTexture(SDL_Renderer *renderer)
SDL_Surface *bmp_surface;
/* load the bmp */
bmp_surface = SDL_LoadBMP("icon.bmp");
if (bmp_surface == NULL) {
if (!bmp_surface) {
fatalError("could not load bmp");
}
/* set white to transparent on the happyface */
@ -117,7 +117,7 @@ initializeTexture(SDL_Renderer *renderer)
/* convert RGBA surface to texture */
texture = SDL_CreateTextureFromSurface(renderer, bmp_surface);
if (texture == NULL) {
if (!texture) {
fatalError("could not create texture");
}
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);

View file

@ -165,7 +165,7 @@ loadFont(void)
{
SDL_Surface *surface = SDL_LoadBMP("kromasky_16x16.bmp");
if (surface == NULL) {
if (!surface) {
printf("Error loading bitmap: %s\n", SDL_GetError());
return 0;
} else {
@ -183,7 +183,7 @@ loadFont(void)
SDL_BlitSurface(surface, NULL, converted, NULL);
/* create our texture */
texture = SDL_CreateTextureFromSurface(renderer, converted);
if (texture == NULL) {
if (!texture) {
printf("texture creation failed: %s\n", SDL_GetError());
} else {
/* set blend mode for our texture */

View file

@ -58,11 +58,11 @@ main(int argc, char *argv[])
/* create window and renderer */
window = SDL_CreateWindow(NULL, 0, 0, 320, 480, SDL_WINDOW_ALLOW_HIGHDPI);
if (window == NULL) {
if (!window) {
fatalError("Could not initialize Window");
}
renderer = SDL_CreateRenderer(window, -1, 0);
if (renderer == NULL) {
if (!renderer) {
fatalError("Could not create renderer");
}

View file

@ -57,13 +57,13 @@ initializeTexture(SDL_Renderer *renderer)
{
SDL_Surface *bmp_surface;
bmp_surface = SDL_LoadBMP("stroke.bmp");
if (bmp_surface == NULL) {
if (!bmp_surface) {
fatalError("could not load stroke.bmp");
}
brush =
SDL_CreateTextureFromSurface(renderer, bmp_surface);
SDL_FreeSurface(bmp_surface);
if (brush == NULL) {
if (!brush) {
fatalError("could not create brush texture");
}
/* additive blending -- laying strokes on top of eachother makes them brighter */

View file

@ -14,7 +14,7 @@ int main(int argc, char *argv[]) {
640, 480,
SDL_WINDOW_SHOWN
);
if (window == NULL) {
if (!window) {
fprintf(stderr, "could not create window: %s\n", SDL_GetError());
return 1;
}

View file

@ -533,7 +533,7 @@ void SDL_GetVersion(SDL_version *ver)
static SDL_bool check_hint = SDL_TRUE;
static SDL_bool legacy_version = SDL_FALSE;
if (ver == NULL) {
if (!ver) {
return;
}

View file

@ -114,11 +114,11 @@ static void SDL_GenerateAssertionReport(void)
const SDL_assert_data *item = triggered_assertions;
/* only do this if the app hasn't assigned an assertion handler. */
if ((item != NULL) && (assertion_handler != SDL_PromptAssertion)) {
if ((item) && (assertion_handler != SDL_PromptAssertion)) {
debug_print("\n\nSDL assertion report.\n");
debug_print("All SDL assertions between last init/quit:\n\n");
while (item != NULL) {
while (item) {
debug_print(
"'%s'\n"
" * %s (%s:%d)\n"
@ -206,7 +206,7 @@ static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data,
/* let env. variable override, so unit tests won't block in a GUI. */
envr = SDL_getenv("SDL_ASSERT");
if (envr != NULL) {
if (envr) {
if (message != stack_buf) {
SDL_free(message);
}
@ -342,9 +342,9 @@ SDL_assert_state SDL_ReportAssertion(SDL_assert_data *data, const char *func, co
#ifndef SDL_THREADS_DISABLED
static SDL_SpinLock spinlock = 0;
SDL_AtomicLock(&spinlock);
if (assertion_mutex == NULL) { /* never called SDL_Init()? */
if (!assertion_mutex) { /* never called SDL_Init()? */
assertion_mutex = SDL_CreateMutex();
if (assertion_mutex == NULL) {
if (!assertion_mutex) {
SDL_AtomicUnlock(&spinlock);
return SDL_ASSERTION_IGNORE; /* oh well, I guess. */
}
@ -409,7 +409,7 @@ void SDL_AssertionsQuit(void)
#if SDL_ASSERT_LEVEL > 0
SDL_GenerateAssertionReport();
#ifndef SDL_THREADS_DISABLED
if (assertion_mutex != NULL) {
if (assertion_mutex) {
SDL_DestroyMutex(assertion_mutex);
assertion_mutex = NULL;
}
@ -437,7 +437,7 @@ void SDL_ResetAssertionReport(void)
{
SDL_assert_data *next = NULL;
SDL_assert_data *item;
for (item = triggered_assertions; item != NULL; item = next) {
for (item = triggered_assertions; item; item = next) {
next = (SDL_assert_data *)item->next;
item->always_ignore = SDL_FALSE;
item->trigger_count = 0;
@ -454,7 +454,7 @@ SDL_AssertionHandler SDL_GetDefaultAssertionHandler(void)
SDL_AssertionHandler SDL_GetAssertionHandler(void **userdata)
{
if (userdata != NULL) {
if (userdata) {
*userdata = assertion_userdata;
}
return assertion_handler;

View file

@ -54,7 +54,7 @@ SDL_DataQueue *SDL_NewDataQueue(const size_t _packetlen, const size_t initialsla
{
SDL_DataQueue *queue = (SDL_DataQueue *)SDL_calloc(1, sizeof(SDL_DataQueue));
if (queue == NULL) {
if (!queue) {
SDL_OutOfMemory();
} else {
const size_t packetlen = _packetlen ? _packetlen : 1024;
@ -101,7 +101,7 @@ void SDL_ClearDataQueue(SDL_DataQueue *queue, const size_t slack)
SDL_DataQueuePacket *prev = NULL;
size_t i;
if (queue == NULL) {
if (!queue) {
return;
}
@ -144,16 +144,16 @@ static SDL_DataQueuePacket *AllocateDataQueuePacket(SDL_DataQueue *queue)
{
SDL_DataQueuePacket *packet;
SDL_assert(queue != NULL);
SDL_assert(queue);
packet = queue->pool;
if (packet != NULL) {
if (packet) {
/* we have one available in the pool. */
queue->pool = packet->next;
} else {
/* Have to allocate a new one! */
packet = (SDL_DataQueuePacket *)SDL_malloc(sizeof(SDL_DataQueuePacket) + queue->packet_size);
if (packet == NULL) {
if (!packet) {
return NULL;
}
}
@ -163,7 +163,7 @@ static SDL_DataQueuePacket *AllocateDataQueuePacket(SDL_DataQueue *queue)
packet->next = NULL;
SDL_assert((queue->head != NULL) == (queue->queued_bytes != 0));
if (queue->tail == NULL) {
if (!queue->tail) {
queue->head = packet;
} else {
queue->tail->next = packet;
@ -182,7 +182,7 @@ int SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *_data, const size_t _
size_t origlen;
size_t datalen;
if (queue == NULL) {
if (!queue) {
return SDL_InvalidParamError("queue");
}
@ -194,13 +194,13 @@ int SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *_data, const size_t _
while (len > 0) {
SDL_DataQueuePacket *packet = queue->tail;
SDL_assert(packet == NULL || (packet->datalen <= packet_size));
if (packet == NULL || (packet->datalen >= packet_size)) {
SDL_assert(!packet || (packet->datalen <= packet_size));
if (!packet || (packet->datalen >= packet_size)) {
/* tail packet missing or completely full; we need a new packet. */
packet = AllocateDataQueuePacket(queue);
if (packet == NULL) {
if (!packet) {
/* uhoh, reset so we've queued nothing new, free what we can. */
if (origtail == NULL) {
if (!origtail) {
packet = queue->head; /* whole queue. */
} else {
packet = origtail->next; /* what we added to existing queue. */
@ -238,7 +238,7 @@ SDL_PeekIntoDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len)
Uint8 *ptr = buf;
SDL_DataQueuePacket *packet;
if (queue == NULL) {
if (!queue) {
return 0;
}
@ -267,7 +267,7 @@ SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len)
Uint8 *ptr = buf;
SDL_DataQueuePacket *packet;
if (queue == NULL) {
if (!queue) {
return 0;
}
@ -286,7 +286,7 @@ SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len)
if (packet->startpos == packet->datalen) { /* packet is done, put it in the pool. */
queue->head = packet->next;
SDL_assert((packet->next != NULL) || (packet == queue->tail));
SDL_assert((packet->next) || (packet == queue->tail));
packet->next = queue->pool;
queue->pool = packet;
}
@ -294,7 +294,7 @@ SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len)
SDL_assert((queue->head != NULL) == (queue->queued_bytes != 0));
if (queue->head == NULL) {
if (!queue->head) {
queue->tail = NULL; /* in case we drained the queue entirely. */
}

View file

@ -28,7 +28,7 @@
int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
{
/* Ignore call if invalid format pointer was passed */
if (fmt != NULL) {
if (fmt) {
va_list ap;
int result;
SDL_error *error = SDL_GetErrBuf();

View file

@ -29,7 +29,7 @@ void SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID)
static const char k_rgchHexToASCII[] = "0123456789abcdef";
int i;
if ((pszGUID == NULL) || (cbGUID <= 0)) {
if ((!pszGUID) || (cbGUID <= 0)) {
return;
}

View file

@ -51,7 +51,7 @@ SDL_bool SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPr
SDL_Hint *hint;
SDL_HintWatch *entry;
if (name == NULL) {
if (!name) {
return SDL_FALSE;
}
@ -66,7 +66,7 @@ SDL_bool SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPr
return SDL_FALSE;
}
if (hint->value != value &&
(value == NULL || !hint->value || SDL_strcmp(hint->value, value) != 0)) {
(!value || !hint->value || SDL_strcmp(hint->value, value) != 0)) {
for (entry = hint->callbacks; entry;) {
/* Save the next entry in case this one is deleted */
SDL_HintWatch *next = entry->next;
@ -83,7 +83,7 @@ SDL_bool SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPr
/* Couldn't find the hint, add a new one */
hint = (SDL_Hint *)SDL_malloc(sizeof(*hint));
if (hint == NULL) {
if (!hint) {
return SDL_FALSE;
}
hint->name = SDL_strdup(name);
@ -101,16 +101,16 @@ SDL_bool SDL_ResetHint(const char *name)
SDL_Hint *hint;
SDL_HintWatch *entry;
if (name == NULL) {
if (!name) {
return SDL_FALSE;
}
env = SDL_getenv(name);
for (hint = SDL_hints; hint; hint = hint->next) {
if (SDL_strcmp(name, hint->name) == 0) {
if ((env == NULL && hint->value != NULL) ||
(env != NULL && hint->value == NULL) ||
(env != NULL && SDL_strcmp(env, hint->value) != 0)) {
if ((!env && hint->value) ||
(env && !hint->value) ||
(env && SDL_strcmp(env, hint->value) != 0)) {
for (entry = hint->callbacks; entry;) {
/* Save the next entry in case this one is deleted */
SDL_HintWatch *next = entry->next;
@ -135,9 +135,9 @@ void SDL_ResetHints(void)
for (hint = SDL_hints; hint; hint = hint->next) {
env = SDL_getenv(hint->name);
if ((env == NULL && hint->value != NULL) ||
(env != NULL && hint->value == NULL) ||
(env != NULL && SDL_strcmp(env, hint->value) != 0)) {
if ((!env && hint->value) ||
(env && !hint->value) ||
(env && SDL_strcmp(env, hint->value) != 0)) {
for (entry = hint->callbacks; entry;) {
/* Save the next entry in case this one is deleted */
SDL_HintWatch *next = entry->next;
@ -164,7 +164,7 @@ const char *SDL_GetHint(const char *name)
env = SDL_getenv(name);
for (hint = SDL_hints; hint; hint = hint->next) {
if (SDL_strcmp(name, hint->name) == 0) {
if (env == NULL || hint->priority == SDL_HINT_OVERRIDE) {
if (!env || hint->priority == SDL_HINT_OVERRIDE) {
return hint->value;
}
break;
@ -175,7 +175,7 @@ const char *SDL_GetHint(const char *name)
SDL_bool SDL_GetStringBoolean(const char *value, SDL_bool default_value)
{
if (value == NULL || !*value) {
if (!value || !*value) {
return default_value;
}
if (*value == '0' || SDL_strcasecmp(value, "false") == 0) {
@ -196,7 +196,7 @@ void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *user
SDL_HintWatch *entry;
const char *value;
if (name == NULL || !*name) {
if (!name || !*name) {
SDL_InvalidParamError("name");
return;
}
@ -208,7 +208,7 @@ void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *user
SDL_DelHintCallback(name, callback, userdata);
entry = (SDL_HintWatch *)SDL_malloc(sizeof(*entry));
if (entry == NULL) {
if (!entry) {
SDL_OutOfMemory();
return;
}
@ -220,10 +220,10 @@ void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *user
break;
}
}
if (hint == NULL) {
if (!hint) {
/* Need to add a hint entry for this watcher */
hint = (SDL_Hint *)SDL_malloc(sizeof(*hint));
if (hint == NULL) {
if (!hint) {
SDL_OutOfMemory();
SDL_free(entry);
return;

View file

@ -28,7 +28,7 @@ int SDL_ListAdd(SDL_ListNode **head, void *ent)
{
SDL_ListNode *node = SDL_malloc(sizeof(*node));
if (node == NULL) {
if (!node) {
return SDL_OutOfMemory();
}
@ -44,7 +44,7 @@ void SDL_ListPop(SDL_ListNode **head, void **ent)
SDL_ListNode **ptr = head;
/* Invalid or empty */
if (head == NULL || *head == NULL) {
if (!head || !*head) {
return;
}

View file

@ -106,7 +106,7 @@ static int SDL_android_priority[SDL_NUM_LOG_PRIORITIES] = {
void SDL_LogInit(void)
{
if (log_function_mutex == NULL) {
if (!log_function_mutex) {
/* if this fails we'll try to continue without it. */
log_function_mutex = SDL_CreateMutex();
}
@ -299,7 +299,7 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va
return;
}
if (log_function_mutex == NULL) {
if (!log_function_mutex) {
/* this mutex creation can race if you log from two threads at startup. You should have called SDL_Init first! */
log_function_mutex = SDL_CreateMutex();
}
@ -317,7 +317,7 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va
if (len >= sizeof(stack_buf) && SDL_size_add_overflow(len, 1, &len_plus_term) == 0) {
/* Allocate exactly what we need, including the zero-terminator */
message = (char *)SDL_malloc(len_plus_term);
if (message == NULL) {
if (!message) {
return;
}
va_copy(aq, ap);
@ -453,7 +453,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
{
FILE *pFile;
pFile = fopen("SDL_Log.txt", "a");
if (pFile != NULL) {
if (pFile) {
(void)fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
(void)fclose(pFile);
}
@ -462,7 +462,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
{
FILE *pFile;
pFile = fopen("ux0:/data/SDL_Log.txt", "a");
if (pFile != NULL) {
if (pFile) {
(void)fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
(void)fclose(pFile);
}
@ -471,7 +471,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
{
FILE *pFile;
pFile = fopen("sdmc:/3ds/SDL_Log.txt", "a");
if (pFile != NULL) {
if (pFile) {
(void)fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
(void)fclose(pFile);
}

View file

@ -67,7 +67,7 @@ SDL_bool SDL_AtomicTryLock(SDL_SpinLock *lock)
/* Terrible terrible damage */
static SDL_mutex *_spinlock_mutex;
if (_spinlock_mutex == NULL) {
if (!_spinlock_mutex) {
/* Race condition on first lock... */
_spinlock_mutex = SDL_CreateMutex();
}

View file

@ -962,7 +962,7 @@ int SDL_AudioInit(const char *driver_name)
}
}
driver_attempt = (driver_attempt_end != NULL) ? (driver_attempt_end + 1) : NULL;
driver_attempt = (driver_attempt_end) ? (driver_attempt_end + 1) : NULL;
}
} else {
for (i = 0; (!initialized) && (bootstrap[i]); ++i) {

View file

@ -266,7 +266,7 @@ int SDL_ConvertAudio(SDL_AudioCVT *cvt)
/* !!! FIXME: (actually, we can't...len_cvt needs to be updated. Grr.) */
/* Make sure there's data to convert */
if (cvt->buf == NULL) {
if (!cvt->buf) {
return SDL_SetError("No buffer allocated for conversion");
}
@ -517,7 +517,7 @@ static void SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioF
/* we keep no streaming state here, so pad with silence on both ends. */
padding = (float *)SDL_calloc(paddingsamples ? paddingsamples : 1, sizeof(float));
if (padding == NULL) {
if (!padding) {
SDL_OutOfMemory();
return;
}
@ -614,7 +614,7 @@ static int SDL_BuildAudioResampleCVT(SDL_AudioCVT *cvt, const int dst_channels,
}
filter = ChooseCVTResampler(dst_channels);
if (filter == NULL) {
if (!filter) {
return SDL_SetError("No conversion available for these rates");
}
@ -687,7 +687,7 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
SDL_AudioFilter channel_converter = NULL;
/* Sanity check target pointer */
if (cvt == NULL) {
if (!cvt) {
return SDL_InvalidParamError("cvt");
}
@ -782,7 +782,7 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
SDL_assert(dst_channels <= SDL_arraysize(channel_converters[0]));
channel_converter = channel_converters[src_channels - 1][dst_channels - 1];
if ((channel_converter == NULL) != (src_channels == dst_channels)) {
if ((!channel_converter) != (src_channels == dst_channels)) {
/* All combinations of supported channel counts should have been handled by now, but let's be defensive */
return SDL_SetError("Invalid channel combination");
} else if (channel_converter != NULL) {
@ -878,7 +878,7 @@ static Uint8 *EnsureStreamBufferSize(SDL_AudioStream *stream, int newlen)
ptr = stream->work_buffer_base;
} else {
ptr = (Uint8 *)SDL_realloc(stream->work_buffer_base, (size_t)newlen + 32);
if (ptr == NULL) {
if (!ptr) {
SDL_OutOfMemory();
return NULL;
}
@ -950,12 +950,12 @@ static SDL_bool SetupLibSampleRateResampling(SDL_AudioStream *stream)
if (SRC_available) {
state = SRC_src_new(SRC_converter, stream->pre_resample_channels, &result);
if (state == NULL) {
if (!state) {
SDL_SetError("src_new() failed: %s", SRC_src_strerror(result));
}
}
if (state == NULL) {
if (!state) {
SDL_CleanupAudioStreamResampler_SRC(stream);
return SDL_FALSE;
}
@ -1027,7 +1027,7 @@ SDL_AudioStream *SDL_NewAudioStream(const SDL_AudioFormat src_format,
}
retval = (SDL_AudioStream *)SDL_calloc(1, sizeof(SDL_AudioStream));
if (retval == NULL) {
if (!retval) {
SDL_OutOfMemory();
return NULL;
}
@ -1053,7 +1053,7 @@ SDL_AudioStream *SDL_NewAudioStream(const SDL_AudioFormat src_format,
retval->resampler_padding_samples = ResamplerPadding(retval->src_rate, retval->dst_rate) * pre_resample_channels;
retval->resampler_padding = (float *)SDL_calloc(retval->resampler_padding_samples ? retval->resampler_padding_samples : 1, sizeof(float));
if (retval->resampler_padding == NULL) {
if (!retval->resampler_padding) {
SDL_FreeAudioStream(retval);
SDL_OutOfMemory();
return NULL;
@ -1062,7 +1062,7 @@ SDL_AudioStream *SDL_NewAudioStream(const SDL_AudioFormat src_format,
retval->staging_buffer_size = ((retval->resampler_padding_samples / retval->pre_resample_channels) * retval->src_sample_frame_size);
if (retval->staging_buffer_size > 0) {
retval->staging_buffer = (Uint8 *)SDL_malloc(retval->staging_buffer_size);
if (retval->staging_buffer == NULL) {
if (!retval->staging_buffer) {
SDL_FreeAudioStream(retval);
SDL_OutOfMemory();
return NULL;
@ -1169,7 +1169,7 @@ static int SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf,
#endif
workbuf = EnsureStreamBufferSize(stream, workbuflen);
if (workbuf == NULL) {
if (!workbuf) {
return -1; /* probably out of memory. */
}
@ -1260,10 +1260,10 @@ int SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len)
SDL_Log("AUDIOSTREAM: wants to put %d preconverted bytes\n", buflen);
#endif
if (stream == NULL) {
if (!stream) {
return SDL_InvalidParamError("stream");
}
if (buf == NULL) {
if (!buf) {
return SDL_InvalidParamError("buf");
}
if (len == 0) {
@ -1315,7 +1315,7 @@ int SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len)
int SDL_AudioStreamFlush(SDL_AudioStream *stream)
{
if (stream == NULL) {
if (!stream) {
return SDL_InvalidParamError("stream");
}
@ -1373,10 +1373,10 @@ int SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len)
SDL_Log("AUDIOSTREAM: want to get %d converted bytes\n", len);
#endif
if (stream == NULL) {
if (!stream) {
return SDL_InvalidParamError("stream");
}
if (buf == NULL) {
if (!buf) {
return SDL_InvalidParamError("buf");
}
if (len <= 0) {
@ -1397,7 +1397,7 @@ int SDL_AudioStreamAvailable(SDL_AudioStream *stream)
void SDL_AudioStreamClear(SDL_AudioStream *stream)
{
if (stream == NULL) {
if (!stream) {
SDL_InvalidParamError("stream");
} else {
SDL_ClearDataQueue(stream->queue, (size_t)stream->packetlen * 2);

View file

@ -81,16 +81,16 @@ static void SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int cla
const char *audiodev;
char audiopath[1024];
if (test == NULL) {
if (!test) {
test = test_stub;
}
/* Figure out what our audio device is */
audiodev = SDL_getenv("SDL_PATH_DSP");
if (audiodev == NULL) {
if (!audiodev) {
audiodev = SDL_getenv("AUDIODEV");
}
if (audiodev == NULL) {
if (!audiodev) {
if (classic) {
audiodev = _PATH_DEV_AUDIO;
} else {

View file

@ -264,7 +264,7 @@ static void WaveDebugDumpFormat(WaveFile *file, Uint32 rifflen, Uint32 fmtlen, U
int res;
dumpstr = SDL_malloc(bufsize);
if (dumpstr == NULL) {
if (!dumpstr) {
return;
}
dumpstr[0] = 0;
@ -441,7 +441,7 @@ static int MS_ADPCM_Init(WaveFile *file, size_t datalength)
coeffdata = (MS_ADPCM_CoeffData *)SDL_malloc(sizeof(MS_ADPCM_CoeffData) + coeffcount * 4);
file->decoderdata = coeffdata; /* Freed in cleanup. */
if (coeffdata == NULL) {
if (!coeffdata) {
return SDL_OutOfMemory();
}
coeffdata->coeff = &coeffdata->aligndummy;
@ -684,7 +684,7 @@ static int MS_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
state.output.pos = 0;
state.output.size = outputsize / sizeof(Sint16);
state.output.data = (Sint16 *)SDL_calloc(1, outputsize);
if (state.output.data == NULL) {
if (!state.output.data) {
return SDL_OutOfMemory();
}
@ -1075,12 +1075,12 @@ static int IMA_ADPCM_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len
state.output.pos = 0;
state.output.size = outputsize / sizeof(Sint16);
state.output.data = (Sint16 *)SDL_malloc(outputsize);
if (state.output.data == NULL) {
if (!state.output.data) {
return SDL_OutOfMemory();
}
cstate = (Sint8 *)SDL_calloc(state.channels, sizeof(Sint8));
if (cstate == NULL) {
if (!cstate) {
SDL_free(state.output.data);
return SDL_OutOfMemory();
}
@ -1235,7 +1235,7 @@ static int LAW_Decode(WaveFile *file, Uint8 **audio_buf, Uint32 *audio_len)
/* 1 to avoid allocating zero bytes, to keep static analysis happy. */
src = (Uint8 *)SDL_realloc(chunk->data, expanded_len ? expanded_len : 1);
if (src == NULL) {
if (!src) {
return SDL_OutOfMemory();
}
chunk->data = NULL;
@ -1366,7 +1366,7 @@ static int PCM_ConvertSint24ToSint32(WaveFile *file, Uint8 **audio_buf, Uint32 *
/* 1 to avoid allocating zero bytes, to keep static analysis happy. */
ptr = (Uint8 *)SDL_realloc(chunk->data, expanded_len ? expanded_len : 1);
if (ptr == NULL) {
if (!ptr) {
return SDL_OutOfMemory();
}
@ -1442,7 +1442,7 @@ static WaveRiffSizeHint WaveGetRiffSizeHint()
{
const char *hint = SDL_GetHint(SDL_HINT_WAVE_RIFF_CHUNK_SIZE);
if (hint != NULL) {
if (hint) {
if (SDL_strcmp(hint, "force") == 0) {
return RiffSizeForce;
} else if (SDL_strcmp(hint, "ignore") == 0) {
@ -1461,7 +1461,7 @@ static WaveTruncationHint WaveGetTruncationHint()
{
const char *hint = SDL_GetHint(SDL_HINT_WAVE_TRUNCATION);
if (hint != NULL) {
if (hint) {
if (SDL_strcmp(hint, "verystrict") == 0) {
return TruncVeryStrict;
} else if (SDL_strcmp(hint, "strict") == 0) {
@ -1480,7 +1480,7 @@ static WaveFactChunkHint WaveGetFactChunkHint()
{
const char *hint = SDL_GetHint(SDL_HINT_WAVE_FACT_CHUNK);
if (hint != NULL) {
if (hint) {
if (SDL_strcmp(hint, "truncate") == 0) {
return FactTruncate;
} else if (SDL_strcmp(hint, "strict") == 0) {
@ -1497,7 +1497,7 @@ static WaveFactChunkHint WaveGetFactChunkHint()
static void WaveFreeChunkData(WaveChunk *chunk)
{
if (chunk->data != NULL) {
if (chunk->data) {
SDL_free(chunk->data);
chunk->data = NULL;
}
@ -1546,7 +1546,7 @@ static int WaveReadPartialChunkData(SDL_RWops *src, WaveChunk *chunk, size_t len
if (length > 0) {
chunk->data = (Uint8 *)SDL_malloc(length);
if (chunk->data == NULL) {
if (!chunk->data) {
return SDL_OutOfMemory();
}
@ -1612,7 +1612,7 @@ static int WaveReadFormat(WaveFile *file)
return SDL_SetError("Data of WAVE fmt chunk too big");
}
fmtsrc = SDL_RWFromConstMem(chunk->data, (int)chunk->size);
if (fmtsrc == NULL) {
if (!fmtsrc) {
return SDL_OutOfMemory();
}
@ -1787,7 +1787,7 @@ static int WaveLoad(SDL_RWops *src, WaveFile *file, SDL_AudioSpec *spec, Uint8 *
SDL_zero(datachunk);
envchunkcountlimit = SDL_getenv("SDL_WAVE_CHUNK_LIMIT");
if (envchunkcountlimit != NULL) {
if (envchunkcountlimit) {
unsigned int count;
if (SDL_sscanf(envchunkcountlimit, "%u", &count) == 1) {
chunkcountlimit = count <= SDL_MAX_UINT32 ? count : SDL_MAX_UINT32;
@ -2085,16 +2085,16 @@ SDL_AudioSpec *SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec,
SDL_zero(file);
/* Make sure we are passed a valid data source */
if (src == NULL) {
if (!src) {
/* Error may come from RWops. */
return NULL;
} else if (spec == NULL) {
} else if (!spec) {
SDL_InvalidParamError("spec");
return NULL;
} else if (audio_buf == NULL) {
} else if (!audio_buf) {
SDL_InvalidParamError("audio_buf");
return NULL;
} else if (audio_len == NULL) {
} else if (!audio_len) {
SDL_InvalidParamError("audio_len");
return NULL;
}

View file

@ -77,8 +77,8 @@ static int aaudio_OpenDevice(_THIS, const char *devname)
aaudio_result_t res;
LOGI(__func__);
SDL_assert((captureDevice == NULL) || !iscapture);
SDL_assert((audioDevice == NULL) || iscapture);
SDL_assert((!captureDevice) || !iscapture);
SDL_assert((!audioDevice) || iscapture);
if (iscapture) {
if (!Android_JNI_RequestPermission("android.permission.RECORD_AUDIO")) {
@ -94,14 +94,14 @@ static int aaudio_OpenDevice(_THIS, const char *devname)
}
this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
private = this->hidden;
ctx.AAudioStreamBuilder_setSampleRate(ctx.builder, this->spec.freq);
ctx.AAudioStreamBuilder_setChannelCount(ctx.builder, this->spec.channels);
if(devname != NULL) {
if(devname) {
int aaudio_device_id = SDL_atoi(devname);
LOGI("Opening device id %d", aaudio_device_id);
ctx.AAudioStreamBuilder_setDeviceId(ctx.builder, aaudio_device_id);
@ -153,7 +153,7 @@ static int aaudio_OpenDevice(_THIS, const char *devname)
if (!iscapture) {
private->mixlen = this->spec.size;
private->mixbuf = (Uint8 *)SDL_malloc(private->mixlen);
if (private->mixbuf == NULL) {
if (!private->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(private->mixbuf, this->spec.silence, this->spec.size);
@ -285,7 +285,7 @@ static SDL_bool aaudio_Init(SDL_AudioDriverImpl *impl)
SDL_zero(ctx);
ctx.handle = SDL_LoadObject(LIB_AAUDIO_SO);
if (ctx.handle == NULL) {
if (!ctx.handle) {
LOGI("SDL couldn't find " LIB_AAUDIO_SO);
goto failure;
}
@ -300,7 +300,7 @@ static SDL_bool aaudio_Init(SDL_AudioDriverImpl *impl)
goto failure;
}
if (ctx.builder == NULL) {
if (!ctx.builder) {
LOGI("SDL Failed AAudio_createStreamBuilder - builder NULL");
goto failure;
}
@ -344,7 +344,7 @@ void aaudio_PauseDevices(void)
{
/* TODO: Handle multiple devices? */
struct SDL_PrivateAudioData *private;
if (audioDevice != NULL && audioDevice->hidden != NULL) {
if (audioDevice && audioDevice->hidden) {
private = (struct SDL_PrivateAudioData *)audioDevice->hidden;
if (private->stream) {
@ -365,7 +365,7 @@ void aaudio_PauseDevices(void)
}
}
if (captureDevice != NULL && captureDevice->hidden != NULL) {
if (captureDevice && captureDevice->hidden) {
private = (struct SDL_PrivateAudioData *)captureDevice->hidden;
if (private->stream) {
@ -393,7 +393,7 @@ void aaudio_ResumeDevices(void)
{
/* TODO: Handle multiple devices? */
struct SDL_PrivateAudioData *private;
if (audioDevice != NULL && audioDevice->hidden != NULL) {
if (audioDevice && audioDevice->hidden) {
private = (struct SDL_PrivateAudioData *)audioDevice->hidden;
if (private->resume) {
@ -411,7 +411,7 @@ void aaudio_ResumeDevices(void)
}
}
if (captureDevice != NULL && captureDevice->hidden != NULL) {
if (captureDevice && captureDevice->hidden) {
private = (struct SDL_PrivateAudioData *)captureDevice->hidden;
if (private->resume) {
@ -441,7 +441,7 @@ SDL_bool aaudio_DetectBrokenPlayState(void)
int64_t framePosition, timeNanoseconds;
aaudio_result_t res;
if (audioDevice == NULL || !audioDevice->hidden) {
if (!audioDevice || !audioDevice->hidden) {
return SDL_FALSE;
}

View file

@ -98,7 +98,7 @@ static void *alsa_handle = NULL;
static int load_alsa_sym(const char *fn, void **addr)
{
*addr = SDL_LoadFunction(alsa_handle, fn);
if (*addr == NULL) {
if (!*addr) {
/* Don't call SDL_SetError(): SDL_LoadFunction already did. */
return 0;
}
@ -166,7 +166,7 @@ static int load_alsa_syms(void)
static void UnloadALSALibrary(void)
{
if (alsa_handle != NULL) {
if (alsa_handle) {
SDL_UnloadObject(alsa_handle);
alsa_handle = NULL;
}
@ -175,9 +175,9 @@ static void UnloadALSALibrary(void)
static int LoadALSALibrary(void)
{
int retval = 0;
if (alsa_handle == NULL) {
if (!alsa_handle) {
alsa_handle = SDL_LoadObject(alsa_library);
if (alsa_handle == NULL) {
if (!alsa_handle) {
retval = -1;
/* Don't call SDL_SetError(): SDL_LoadObject already did. */
} else {
@ -208,13 +208,13 @@ static const char *get_audio_device(void *handle, const int channels)
{
const char *device;
if (handle != NULL) {
if (handle) {
return (const char *)handle;
}
/* !!! FIXME: we also check "SDL_AUDIO_DEVICE_NAME" at the higher level. */
device = SDL_getenv("AUDIODEV"); /* Is there a standard variable name? */
if (device != NULL) {
if (device) {
return device;
}
@ -539,7 +539,7 @@ static int ALSA_OpenDevice(_THIS, const char *devname)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@ -687,7 +687,7 @@ static int ALSA_OpenDevice(_THIS, const char *devname)
if (!iscapture) {
this->hidden->mixlen = this->spec.size;
this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->hidden->mixlen);
if (this->hidden->mixbuf == NULL) {
if (!this->hidden->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden->mixbuf, this->spec.silence, this->hidden->mixlen);
@ -717,7 +717,7 @@ static void add_device(const int iscapture, const char *name, void *hint, ALSA_D
char *handle = NULL;
char *ptr;
if (dev == NULL) {
if (!dev) {
return;
}
@ -727,7 +727,7 @@ static void add_device(const int iscapture, const char *name, void *hint, ALSA_D
Make sure not to free the storage associated with desc in this case */
if (hint) {
desc = ALSA_snd_device_name_get_hint(hint, "DESC");
if (desc == NULL) {
if (!desc) {
SDL_free(dev);
return;
}
@ -735,20 +735,20 @@ static void add_device(const int iscapture, const char *name, void *hint, ALSA_D
desc = (char *)name;
}
SDL_assert(name != NULL);
SDL_assert(name);
/* some strings have newlines, like "HDA NVidia, HDMI 0\nHDMI Audio Output".
just chop the extra lines off, this seems to get a reasonable device
name without extra details. */
ptr = SDL_strchr(desc, '\n');
if (ptr != NULL) {
if (ptr) {
*ptr = '\0';
}
/*printf("ALSA: adding %s device '%s' (%s)\n", iscapture ? "capture" : "output", name, desc);*/
handle = SDL_strdup(name);
if (handle == NULL) {
if (!handle) {
if (hint) {
free(desc);
}
@ -800,7 +800,7 @@ static void ALSA_HotplugIteration(void)
if we can find a preferred prefix for the system. */
for (i = 0; hints[i]; i++) {
char *name = ALSA_snd_device_name_get_hint(hints[i], "NAME");
if (name == NULL) {
if (!name) {
continue;
}
@ -829,20 +829,20 @@ static void ALSA_HotplugIteration(void)
char *name;
/* if we didn't find a device name prefix we like at all... */
if ((match == NULL) && (defaultdev != i)) {
if ((!match) && (defaultdev != i)) {
continue; /* ...skip anything that isn't the default device. */
}
name = ALSA_snd_device_name_get_hint(hints[i], "NAME");
if (name == NULL) {
if (!name) {
continue;
}
/* only want physical hardware interfaces */
if (match == NULL || (SDL_strncmp(name, match, match_len) == 0)) {
if (!match || (SDL_strncmp(name, match, match_len) == 0)) {
char *ioid = ALSA_snd_device_name_get_hint(hints[i], "IOID");
const SDL_bool isoutput = (ioid == NULL) || (SDL_strcmp(ioid, "Output") == 0);
const SDL_bool isinput = (ioid == NULL) || (SDL_strcmp(ioid, "Input") == 0);
const SDL_bool isoutput = (!ioid) || (SDL_strcmp(ioid, "Output") == 0);
const SDL_bool isinput = (!ioid) || (SDL_strcmp(ioid, "Input") == 0);
SDL_bool have_output = SDL_FALSE;
SDL_bool have_input = SDL_FALSE;
@ -940,7 +940,7 @@ static void ALSA_Deinitialize(void)
ALSA_Device *next;
#if SDL_ALSA_HOTPLUG_THREAD
if (ALSA_hotplug_thread != NULL) {
if (ALSA_hotplug_thread) {
SDL_AtomicSet(&ALSA_hotplug_shutdown, 1);
SDL_WaitThread(ALSA_hotplug_thread, NULL);
ALSA_hotplug_thread = NULL;

View file

@ -41,8 +41,8 @@ static int ANDROIDAUDIO_OpenDevice(_THIS, const char *devname)
SDL_AudioFormat test_format;
SDL_bool iscapture = this->iscapture;
SDL_assert((captureDevice == NULL) || !iscapture);
SDL_assert((audioDevice == NULL) || iscapture);
SDL_assert((!captureDevice) || !iscapture);
SDL_assert((!audioDevice) || iscapture);
if (iscapture) {
captureDevice = this;
@ -51,7 +51,7 @@ static int ANDROIDAUDIO_OpenDevice(_THIS, const char *devname)
}
this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
@ -71,7 +71,7 @@ static int ANDROIDAUDIO_OpenDevice(_THIS, const char *devname)
{
int audio_device_id = 0;
if (devname != NULL) {
if (devname) {
audio_device_id = SDL_atoi(devname);
}
if (Android_JNI_OpenAudioDevice(iscapture, audio_device_id, &this->spec) < 0) {
@ -149,7 +149,7 @@ void ANDROIDAUDIO_PauseDevices(void)
{
/* TODO: Handle multiple devices? */
struct SDL_PrivateAudioData *private;
if (audioDevice != NULL && audioDevice->hidden != NULL) {
if (audioDevice && audioDevice->hidden) {
private = (struct SDL_PrivateAudioData *)audioDevice->hidden;
if (SDL_AtomicGet(&audioDevice->paused)) {
/* The device is already paused, leave it alone */
@ -161,7 +161,7 @@ void ANDROIDAUDIO_PauseDevices(void)
}
}
if (captureDevice != NULL && captureDevice->hidden != NULL) {
if (captureDevice && captureDevice->hidden) {
private = (struct SDL_PrivateAudioData *)captureDevice->hidden;
if (SDL_AtomicGet(&captureDevice->paused)) {
/* The device is already paused, leave it alone */
@ -179,7 +179,7 @@ void ANDROIDAUDIO_ResumeDevices(void)
{
/* TODO: Handle multiple devices? */
struct SDL_PrivateAudioData *private;
if (audioDevice != NULL && audioDevice->hidden != NULL) {
if (audioDevice && audioDevice->hidden) {
private = (struct SDL_PrivateAudioData *)audioDevice->hidden;
if (private->resume) {
SDL_AtomicSet(&audioDevice->paused, 0);
@ -188,7 +188,7 @@ void ANDROIDAUDIO_ResumeDevices(void)
}
}
if (captureDevice != NULL && captureDevice->hidden != NULL) {
if (captureDevice && captureDevice->hidden) {
private = (struct SDL_PrivateAudioData *)captureDevice->hidden;
if (private->resume) {
SDL_AtomicSet(&captureDevice->paused, 0);

View file

@ -88,7 +88,7 @@ static struct
static void UnloadARTSLibrary()
{
if (arts_handle != NULL) {
if (arts_handle) {
SDL_UnloadObject(arts_handle);
arts_handle = NULL;
}
@ -98,9 +98,9 @@ static int LoadARTSLibrary(void)
{
int i, retval = -1;
if (arts_handle == NULL) {
if (!arts_handle) {
arts_handle = SDL_LoadObject(arts_library);
if (arts_handle != NULL) {
if (arts_handle) {
retval = 0;
for (i = 0; i < SDL_arraysize(arts_functions); ++i) {
*arts_functions[i].func =
@ -214,7 +214,7 @@ static int ARTS_OpenDevice(_THIS, const char *devname)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@ -281,7 +281,7 @@ static int ARTS_OpenDevice(_THIS, const char *devname)
/* Allocate mixing buffer */
this->hidden->mixlen = this->spec.size;
this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen);
if (this->hidden->mixbuf == NULL) {
if (!this->hidden->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);

View file

@ -64,7 +64,7 @@ static void DSOUND_Unload(void)
pDirectSoundCaptureCreate8 = NULL;
pDirectSoundCaptureEnumerateW = NULL;
if (DSoundDLL != NULL) {
if (DSoundDLL) {
SDL_UnloadObject(DSoundDLL);
DSoundDLL = NULL;
}
@ -77,7 +77,7 @@ static int DSOUND_Load(void)
DSOUND_Unload();
DSoundDLL = SDL_LoadObject("DSOUND.DLL");
if (DSoundDLL == NULL) {
if (!DSoundDLL) {
SDL_SetError("DirectSound: failed to load DSOUND.DLL");
} else {
/* Now make sure we have DirectX 8 or better... */
@ -172,7 +172,7 @@ static BOOL CALLBACK FindAllDevs(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVO
const int iscapture = (int)((size_t)data);
if (guid != NULL) { /* skip default device */
char *str = WIN_LookupAudioDeviceName(desc, guid);
if (str != NULL) {
if (str) {
LPGUID cpyguid = (LPGUID)SDL_malloc(sizeof(GUID));
SDL_memcpy(cpyguid, guid, sizeof(GUID));
@ -354,7 +354,7 @@ static int DSOUND_CaptureFromDevice(_THIS, void *buffer, int buflen)
}
SDL_assert(ptr1len == this->spec.size);
SDL_assert(ptr2 == NULL);
SDL_assert(!ptr2);
SDL_assert(ptr2len == 0);
SDL_memcpy(buffer, ptr1, ptr1len);
@ -379,18 +379,18 @@ static void DSOUND_FlushCapture(_THIS)
static void DSOUND_CloseDevice(_THIS)
{
if (this->hidden->mixbuf != NULL) {
if (this->hidden->mixbuf) {
IDirectSoundBuffer_Stop(this->hidden->mixbuf);
IDirectSoundBuffer_Release(this->hidden->mixbuf);
}
if (this->hidden->sound != NULL) {
if (this->hidden->sound) {
IDirectSound_Release(this->hidden->sound);
}
if (this->hidden->capturebuf != NULL) {
if (this->hidden->capturebuf) {
IDirectSoundCaptureBuffer_Stop(this->hidden->capturebuf);
IDirectSoundCaptureBuffer_Release(this->hidden->capturebuf);
}
if (this->hidden->capture != NULL) {
if (this->hidden->capture) {
IDirectSoundCapture_Release(this->hidden->capture);
}
SDL_free(this->hidden);
@ -493,7 +493,7 @@ static int DSOUND_OpenDevice(_THIS, const char *devname)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);

View file

@ -98,7 +98,7 @@ static void DISKAUDIO_FlushCapture(_THIS)
static void DISKAUDIO_CloseDevice(_THIS)
{
if (_this->hidden->io != NULL) {
if (_this->hidden->io) {
SDL_RWclose(_this->hidden->io);
}
SDL_free(_this->hidden->mixbuf);
@ -107,9 +107,9 @@ static void DISKAUDIO_CloseDevice(_THIS)
static const char *get_filename(const SDL_bool iscapture, const char *devname)
{
if (devname == NULL) {
if (!devname) {
devname = SDL_getenv(iscapture ? DISKENVR_INFILE : DISKENVR_OUTFILE);
if (devname == NULL) {
if (!devname) {
devname = iscapture ? DISKDEFAULT_INFILE : DISKDEFAULT_OUTFILE;
}
}
@ -126,12 +126,12 @@ static int DISKAUDIO_OpenDevice(_THIS, const char *devname)
_this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc(sizeof(*_this->hidden));
if (_this->hidden == NULL) {
if (!_this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(_this->hidden);
if (envr != NULL) {
if (envr) {
_this->hidden->io_delay = SDL_atoi(envr);
} else {
_this->hidden->io_delay = ((_this->spec.samples * 1000) / _this->spec.freq);
@ -139,14 +139,14 @@ static int DISKAUDIO_OpenDevice(_THIS, const char *devname)
/* Open the audio device */
_this->hidden->io = SDL_RWFromFile(fname, iscapture ? "rb" : "wb");
if (_this->hidden->io == NULL) {
if (!_this->hidden->io) {
return -1;
}
/* Allocate mixing buffer */
if (!iscapture) {
_this->hidden->mixbuf = (Uint8 *)SDL_malloc(_this->spec.size);
if (_this->hidden->mixbuf == NULL) {
if (!_this->hidden->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(_this->hidden->mixbuf, _this->spec.silence, _this->spec.size);

View file

@ -67,9 +67,9 @@ static int DSP_OpenDevice(_THIS, const char *devname)
/* We don't care what the devname is...we'll try to open anything. */
/* ...but default to first name in the list... */
if (devname == NULL) {
if (!devname) {
devname = SDL_GetAudioDeviceName(0, iscapture);
if (devname == NULL) {
if (!devname) {
return SDL_SetError("No such audio device");
}
}
@ -86,7 +86,7 @@ static int DSP_OpenDevice(_THIS, const char *devname)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@ -228,7 +228,7 @@ static int DSP_OpenDevice(_THIS, const char *devname)
if (!iscapture) {
this->hidden->mixlen = this->spec.size;
this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->hidden->mixlen);
if (this->hidden->mixbuf == NULL) {
if (!this->hidden->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);

View file

@ -70,7 +70,7 @@ static void HandleAudioProcess(_THIS)
return;
}
if (this->stream == NULL) { /* no conversion necessary. */
if (!this->stream) { /* no conversion necessary. */
SDL_assert(this->spec.size == stream_len);
callback(this->callbackspec.userdata, this->work_buffer, stream_len);
} else { /* streaming/converting */
@ -130,7 +130,7 @@ static void HandleCaptureProcess(_THIS)
/* okay, we've got an interleaved float32 array in C now. */
if (this->stream == NULL) { /* no conversion necessary. */
if (!this->stream) { /* no conversion necessary. */
SDL_assert(this->spec.size == stream_len);
callback(this->callbackspec.userdata, this->work_buffer, stream_len);
} else { /* streaming/converting */

View file

@ -66,7 +66,7 @@ static struct
static void UnloadESDLibrary()
{
if (esd_handle != NULL) {
if (esd_handle) {
SDL_UnloadObject(esd_handle);
esd_handle = NULL;
}
@ -76,7 +76,7 @@ static int LoadESDLibrary(void)
{
int i, retval = -1;
if (esd_handle == NULL) {
if (!esd_handle) {
esd_handle = SDL_LoadObject(esd_library);
if (esd_handle) {
retval = 0;
@ -185,7 +185,7 @@ static char *get_progname(void)
if (fp != NULL) {
if (fgets(temp, sizeof(temp) - 1, fp)) {
progname = SDL_strrchr(temp, '/');
if (progname == NULL) {
if (!progname) {
progname = temp;
} else {
progname = progname + 1;
@ -206,7 +206,7 @@ static int ESD_OpenDevice(_THIS, const char *devname)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@ -264,7 +264,7 @@ static int ESD_OpenDevice(_THIS, const char *devname)
/* Allocate mixing buffer */
this->hidden->mixlen = this->spec.size;
this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen);
if (this->hidden->mixbuf == NULL) {
if (!this->hidden->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);

View file

@ -79,7 +79,7 @@ static struct
static void UnloadFusionSoundLibrary()
{
if (fs_handle != NULL) {
if (fs_handle) {
SDL_UnloadObject(fs_handle);
fs_handle = NULL;
}
@ -89,9 +89,9 @@ static int LoadFusionSoundLibrary(void)
{
int i, retval = -1;
if (fs_handle == NULL) {
if (!fs_handle) {
fs_handle = SDL_LoadObject(fs_library);
if (fs_handle != NULL) {
if (fs_handle) {
retval = 0;
for (i = 0; i < SDL_arraysize(fs_functions); ++i) {
*fs_functions[i].func =
@ -175,7 +175,7 @@ static int SDL_FS_OpenDevice(_THIS, const char *devname)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@ -250,7 +250,7 @@ static int SDL_FS_OpenDevice(_THIS, const char *devname)
/* Allocate mixing buffer */
this->hidden->mixlen = this->spec.size;
this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen);
if (this->hidden->mixbuf == NULL) {
if (!this->hidden->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);

View file

@ -59,7 +59,7 @@ static void FillSound(void *device, void *stream, size_t len,
} else {
SDL_assert(audio->spec.size == len);
if (audio->stream == NULL) { /* no conversion necessary. */
if (!audio->stream) { /* no conversion necessary. */
callback(audio->callbackspec.userdata, (Uint8 *) stream, len);
} else { /* streaming/converting */
const int stream_len = audio->callbackspec.size;

View file

@ -58,7 +58,7 @@ static void *jack_handle = NULL;
static int load_jack_sym(const char *fn, void **addr)
{
*addr = SDL_LoadFunction(jack_handle, fn);
if (*addr == NULL) {
if (!*addr) {
/* Don't call SDL_SetError(): SDL_LoadFunction already did. */
return 0;
}
@ -73,7 +73,7 @@ static int load_jack_sym(const char *fn, void **addr)
static void UnloadJackLibrary(void)
{
if (jack_handle != NULL) {
if (jack_handle) {
SDL_UnloadObject(jack_handle);
jack_handle = NULL;
}
@ -82,9 +82,9 @@ static void UnloadJackLibrary(void)
static int LoadJackLibrary(void)
{
int retval = 0;
if (jack_handle == NULL) {
if (!jack_handle) {
jack_handle = SDL_LoadObject(jack_library);
if (jack_handle == NULL) {
if (!jack_handle) {
retval = -1;
/* Don't call SDL_SetError(): SDL_LoadObject already did. */
} else {
@ -341,7 +341,7 @@ static int JACK_OpenDevice(_THIS, const char *devname)
/* Build SDL's ports, which we will connect to the device ports. */
this->hidden->sdlports = (jack_port_t **)SDL_calloc(channels, sizeof(jack_port_t *));
if (this->hidden->sdlports == NULL) {
if (!this->hidden->sdlports) {
SDL_free(audio_ports);
return SDL_OutOfMemory();
}
@ -400,7 +400,7 @@ static SDL_bool JACK_Init(SDL_AudioDriverImpl *impl)
/* Make sure a JACK server is running and available. */
jack_status_t status;
jack_client_t *client = JACK_jack_client_open("SDL", JackNoStartServer, &status, NULL);
if (client == NULL) {
if (!client) {
UnloadJackLibrary();
return SDL_FALSE;
}

View file

@ -89,7 +89,7 @@ static int N3DSAUDIO_OpenDevice(_THIS, const char *devname)
float mix[12];
this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
@ -127,14 +127,14 @@ static int N3DSAUDIO_OpenDevice(_THIS, const char *devname)
this->hidden->mixlen = this->spec.size;
this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->spec.size);
if (this->hidden->mixbuf == NULL) {
if (!this->hidden->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
data_vaddr = (Uint8 *)linearAlloc(this->hidden->mixlen * NUM_BUFFERS);
if (data_vaddr == NULL) {
if (!data_vaddr) {
return SDL_OutOfMemory();
}

View file

@ -62,7 +62,7 @@ static void nacl_audio_callback(void* stream, uint32_t buffer_size, PP_TimeDelta
} else {
SDL_assert(_this->spec.size == len);
if (_this->stream == NULL) { /* no conversion necessary. */
if (!_this->stream) { /* no conversion necessary. */
callback(_this->callbackspec.userdata, stream, len);
} else { /* streaming/converting */
const int stream_len = _this->callbackspec.size;
@ -103,7 +103,7 @@ static int NACLAUDIO_OpenDevice(_THIS, const char *devname)
const PPB_AudioConfig *ppb_audiocfg = PSInterfaceAudioConfig();
private = (SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*private));
if (private == NULL) {
if (!private) {
return SDL_OutOfMemory();
}

View file

@ -59,7 +59,7 @@ static void *nas_handle = NULL;
static int load_nas_sym(const char *fn, void **addr)
{
*addr = SDL_LoadFunction(nas_handle, fn);
if (*addr == NULL) {
if (!*addr) {
return 0;
}
return 1;
@ -94,7 +94,7 @@ static int load_nas_syms(void)
static void UnloadNASLibrary(void)
{
if (nas_handle != NULL) {
if (nas_handle) {
SDL_UnloadObject(nas_handle);
nas_handle = NULL;
}
@ -103,9 +103,9 @@ static void UnloadNASLibrary(void)
static int LoadNASLibrary(void)
{
int retval = 0;
if (nas_handle == NULL) {
if (!nas_handle) {
nas_handle = SDL_LoadObject(nas_library);
if (nas_handle == NULL) {
if (!nas_handle) {
/* Copy error string so we can use it in a new SDL_SetError(). */
const char *origerr = SDL_GetError();
const size_t len = SDL_strlen(origerr) + 1;
@ -305,7 +305,7 @@ static int NAS_OpenDevice(_THIS, const char *devname)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@ -389,7 +389,7 @@ static int NAS_OpenDevice(_THIS, const char *devname)
if (!iscapture) {
this->hidden->mixlen = this->spec.size;
this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen);
if (this->hidden->mixbuf == NULL) {
if (!this->hidden->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
@ -410,7 +410,7 @@ static SDL_bool NAS_Init(SDL_AudioDriverImpl * impl)
return SDL_FALSE;
} else {
AuServer *aud = NAS_AuOpenServer("", 0, NULL, 0, NULL, NULL);
if (aud == NULL) {
if (!aud) {
SDL_SetError("NAS: AuOpenServer() failed (no audio server?)");
return SDL_FALSE;
}

View file

@ -202,16 +202,16 @@ static int NETBSDAUDIO_OpenDevice(_THIS, const char *devname)
/* We don't care what the devname is...we'll try to open anything. */
/* ...but default to first name in the list... */
if (devname == NULL) {
if (!devname) {
devname = SDL_GetAudioDeviceName(0, iscapture);
if (devname == NULL) {
if (!devname) {
return SDL_SetError("No such audio device");
}
}
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@ -296,7 +296,7 @@ static int NETBSDAUDIO_OpenDevice(_THIS, const char *devname)
/* Allocate mixing buffer */
this->hidden->mixlen = this->spec.size;
this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->hidden->mixlen);
if (this->hidden->mixbuf == NULL) {
if (!this->hidden->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);

View file

@ -320,7 +320,7 @@ static int openslES_CreatePCMRecorder(_THIS)
/* Create the sound buffers */
audiodata->mixbuff = (Uint8 *)SDL_malloc(NUM_BUFFERS * this->spec.size);
if (audiodata->mixbuff == NULL) {
if (!audiodata->mixbuff) {
LOGE("mixbuffer allocate - out of memory");
goto failed;
}
@ -566,7 +566,7 @@ static int openslES_CreatePCMPlayer(_THIS)
/* Create the sound buffers */
audiodata->mixbuff = (Uint8 *)SDL_malloc(NUM_BUFFERS * this->spec.size);
if (audiodata->mixbuff == NULL) {
if (!audiodata->mixbuff) {
LOGE("mixbuffer allocate - out of memory");
goto failed;
}
@ -591,7 +591,7 @@ failed:
static int openslES_OpenDevice(_THIS, const char *devname)
{
this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}

View file

@ -43,7 +43,7 @@ static ULONG _getEnvULong(const char *name, ULONG ulMax, ULONG ulDefault)
char* end;
char* envval = SDL_getenv(name);
if (envval == NULL)
if (!envval)
return ulDefault;
ulValue = SDL_strtoul(envval, &end, 10);
@ -351,7 +351,7 @@ static void OS2_CloseDevice(_THIS)
debug_os2("Enter");
if (pAData == NULL)
if (!pAData)
return;
pAData->ulState = 2;
@ -429,7 +429,7 @@ static int OS2_OpenDevice(_THIS, const char *devname)
}
pAData = (SDL_PrivateAudioData *) SDL_calloc(1, sizeof(struct SDL_PrivateAudioData));
if (pAData == NULL)
if (!pAData)
return SDL_OutOfMemory();
_this->hidden = pAData;

View file

@ -78,11 +78,11 @@ static int OpenUserDefinedDevice(char *path, int maxlen, int flags)
if ((audiodev = SDL_getenv("SDL_PATH_DSP")) == NULL) {
audiodev = SDL_getenv("AUDIODEV");
}
if (audiodev == NULL) {
if (!audiodev) {
return -1;
}
fd = open(audiodev, flags, 0);
if (path != NULL) {
if (path) {
SDL_strlcpy(path, audiodev, maxlen);
path[maxlen - 1] = '\0';
}
@ -110,7 +110,7 @@ static int OpenAudioPath(char *path, int maxlen, int flags, int classic)
if (stat(audiopath, &sb) == 0) {
fd = open(audiopath, flags, 0);
if (fd >= 0) {
if (path != NULL) {
if (path) {
SDL_strlcpy(path, audiopath, maxlen);
}
return fd;
@ -232,7 +232,7 @@ static int PAUDIO_OpenDevice(_THIS, const char *devname)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@ -403,7 +403,7 @@ static int PAUDIO_OpenDevice(_THIS, const char *devname)
/* Allocate mixing buffer */
this->hidden->mixlen = this->spec.size;
this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen);
if (this->hidden->mixbuf == NULL) {
if (!this->hidden->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
@ -445,7 +445,7 @@ static int PAUDIO_OpenDevice(_THIS, const char *devname)
}
/* Check to see if we need to use SDL_IOReady() workaround */
if (workaround != NULL) {
if (workaround) {
this->hidden->frame_ticks = (float) (this->spec.samples * 1000) /
this->spec.freq;
this->hidden->next_frame = SDL_GetTicks() + this->hidden->frame_ticks;

View file

@ -129,7 +129,7 @@ static void *pipewire_handle = NULL;
static int pipewire_dlsym(const char *fn, void **addr)
{
*addr = SDL_LoadFunction(pipewire_handle, fn);
if (*addr == NULL) {
if (!*addr) {
/* Don't call SDL_SetError(): SDL_LoadFunction already did. */
return 0;
}
@ -145,7 +145,7 @@ static int pipewire_dlsym(const char *fn, void **addr)
static int load_pipewire_library()
{
pipewire_handle = SDL_LoadObject(pipewire_library);
return pipewire_handle != NULL ? 0 : -1;
return pipewire_handle ? 0 : -1;
}
static void unload_pipewire_library()
@ -347,10 +347,10 @@ static void io_list_sort()
/* Find and move the default nodes to the beginning of the list */
spa_list_for_each_safe (n, temp, &hotplug_io_list, link) {
if (pipewire_default_sink_id != NULL && SDL_strcmp(n->path, pipewire_default_sink_id) == 0) {
if (pipewire_default_sink_id && SDL_strcmp(n->path, pipewire_default_sink_id) == 0) {
default_sink = n;
spa_list_remove(&n->link);
} else if (pipewire_default_source_id != NULL && SDL_strcmp(n->path, pipewire_default_source_id) == 0) {
} else if (pipewire_default_source_id && SDL_strcmp(n->path, pipewire_default_source_id) == 0) {
default_source = n;
spa_list_remove(&n->link);
}
@ -442,7 +442,7 @@ static void *node_object_new(Uint32 id, const char *type, Uint32 version, const
/* Create the proxy object */
proxy = pw_registry_bind(hotplug_registry, id, type, version, sizeof(struct node_object));
if (proxy == NULL) {
if (!proxy) {
SDL_SetError("Pipewire: Failed to create proxy object (%i)", errno);
return NULL;
}
@ -648,15 +648,15 @@ static int metadata_property(void *object, Uint32 subject, const char *key, cons
{
struct node_object *node = object;
if (subject == PW_ID_CORE && key != NULL && value != NULL) {
if (subject == PW_ID_CORE && key && value) {
if (!SDL_strcmp(key, "default.audio.sink")) {
if (pipewire_default_sink_id != NULL) {
if (pipewire_default_sink_id) {
SDL_free(pipewire_default_sink_id);
}
pipewire_default_sink_id = get_name_from_json(value);
node->persist = SDL_TRUE;
} else if (!SDL_strcmp(key, "default.audio.source")) {
if (pipewire_default_source_id != NULL) {
if (pipewire_default_source_id) {
SDL_free(pipewire_default_source_id);
}
pipewire_default_source_id = get_name_from_json(value);
@ -701,7 +701,7 @@ static void registry_event_global_callback(void *object, uint32_t id, uint32_t p
if (node_desc && node_path) {
node = node_object_new(id, type, version, &interface_node_events, &interface_core_events);
if (node == NULL) {
if (!node) {
SDL_SetError("Pipewire: Failed to allocate interface node");
return;
}
@ -710,7 +710,7 @@ static void registry_event_global_callback(void *object, uint32_t id, uint32_t p
desc_buffer_len = SDL_strlen(node_desc) + 1;
path_buffer_len = SDL_strlen(node_path) + 1;
node->userdata = io = SDL_calloc(1, sizeof(struct io_node) + desc_buffer_len + path_buffer_len);
if (io == NULL) {
if (!io) {
node_object_destroy(node);
SDL_OutOfMemory();
return;
@ -731,7 +731,7 @@ static void registry_event_global_callback(void *object, uint32_t id, uint32_t p
}
} else if (!SDL_strcmp(type, PW_TYPE_INTERFACE_Metadata)) {
node = node_object_new(id, type, version, &metadata_node_events, &metadata_core_events);
if (node == NULL) {
if (!node) {
SDL_SetError("Pipewire: Failed to allocate metadata node");
return;
}
@ -759,22 +759,22 @@ static int hotplug_loop_init()
spa_list_init(&hotplug_io_list);
hotplug_loop = PIPEWIRE_pw_thread_loop_new("SDLAudioHotplug", NULL);
if (hotplug_loop == NULL) {
if (!hotplug_loop) {
return SDL_SetError("Pipewire: Failed to create hotplug detection loop (%i)", errno);
}
hotplug_context = PIPEWIRE_pw_context_new(PIPEWIRE_pw_thread_loop_get_loop(hotplug_loop), NULL, 0);
if (hotplug_context == NULL) {
if (!hotplug_context) {
return SDL_SetError("Pipewire: Failed to create hotplug detection context (%i)", errno);
}
hotplug_core = PIPEWIRE_pw_context_connect(hotplug_context, NULL, 0);
if (hotplug_core == NULL) {
if (!hotplug_core) {
return SDL_SetError("Pipewire: Failed to connect hotplug detection context (%i)", errno);
}
hotplug_registry = pw_core_get_registry(hotplug_core, PW_VERSION_REGISTRY, 0);
if (hotplug_registry == NULL) {
if (!hotplug_registry) {
return SDL_SetError("Pipewire: Failed to acquire hotplug detection registry (%i)", errno);
}
@ -806,11 +806,11 @@ static void hotplug_loop_destroy()
hotplug_init_complete = SDL_FALSE;
hotplug_events_enabled = SDL_FALSE;
if (pipewire_default_sink_id != NULL) {
if (pipewire_default_sink_id) {
SDL_free(pipewire_default_sink_id);
pipewire_default_sink_id = NULL;
}
if (pipewire_default_source_id != NULL) {
if (pipewire_default_source_id) {
SDL_free(pipewire_default_source_id);
pipewire_default_source_id = NULL;
}
@ -961,7 +961,7 @@ static void output_callback(void *data)
/* See if a buffer is available */
pw_buf = PIPEWIRE_pw_stream_dequeue_buffer(stream);
if (pw_buf == NULL) {
if (!pw_buf) {
return;
}
@ -1025,13 +1025,13 @@ static void input_callback(void *data)
}
pw_buf = PIPEWIRE_pw_stream_dequeue_buffer(stream);
if (pw_buf == NULL) {
if (!pw_buf) {
return;
}
spa_buf = pw_buf->buffer;
(src = (Uint8 *)spa_buf->datas[0].data);
if (src == NULL) {
if (!src) {
return;
}
@ -1079,7 +1079,7 @@ static void stream_add_buffer_callback(void *data, struct pw_buffer *buffer)
this->spec.samples = buffer->buffer->datas[0].maxsize / this->hidden->stride;
this->spec.size = buffer->buffer->datas[0].maxsize;
}
} else if (this->hidden->buffer == NULL) {
} else if (!this->hidden->buffer) {
/*
* The latency of source nodes can change, so buffering is always required.
*
@ -1137,7 +1137,7 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname)
struct SDL_PrivateAudioData *priv;
struct pw_properties *props;
const char *app_name, *stream_name, *stream_role, *error;
Uint32 node_id = this->handle == NULL ? PW_ID_ANY : PW_HANDLE_TO_ID(this->handle);
Uint32 node_id = !this->handle ? PW_ID_ANY : PW_HANDLE_TO_ID(this->handle);
SDL_bool iscapture = this->iscapture;
int res;
@ -1146,15 +1146,15 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname)
/* Get the hints for the application name, stream name and role */
app_name = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_APP_NAME);
if (app_name == NULL || *app_name == '\0') {
if (!app_name || *app_name == '\0') {
app_name = SDL_GetHint(SDL_HINT_APP_NAME);
if (app_name == NULL || *app_name == '\0') {
if (!app_name || *app_name == '\0') {
app_name = "SDL Application";
}
}
stream_name = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_STREAM_NAME);
if (stream_name == NULL || *stream_name == '\0') {
if (!stream_name || *stream_name == '\0') {
stream_name = "Audio Stream";
}
@ -1163,20 +1163,20 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname)
* but 'Game' seems more appropriate for the majority of SDL applications.
*/
stream_role = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_STREAM_ROLE);
if (stream_role == NULL || *stream_role == '\0') {
if (!stream_role || *stream_role == '\0') {
stream_role = "Game";
}
/* Initialize the Pipewire stream info from the SDL audio spec */
initialize_spa_info(&this->spec, &spa_info);
params = spa_format_audio_raw_build(&b, SPA_PARAM_EnumFormat, &spa_info);
if (params == NULL) {
if (!params) {
return SDL_SetError("Pipewire: Failed to set audio format parameters");
}
priv = SDL_calloc(1, sizeof(struct SDL_PrivateAudioData));
this->hidden = priv;
if (priv == NULL) {
if (!priv) {
return SDL_OutOfMemory();
}
@ -1190,23 +1190,23 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname)
(void)SDL_snprintf(thread_name, sizeof(thread_name), "SDLAudio%c%ld", (iscapture) ? 'C' : 'P', (long)this->handle);
priv->loop = PIPEWIRE_pw_thread_loop_new(thread_name, NULL);
if (priv->loop == NULL) {
if (!priv->loop) {
return SDL_SetError("Pipewire: Failed to create stream loop (%i)", errno);
}
/* Load the realtime module so Pipewire can set the loop thread to the appropriate priority. */
props = PIPEWIRE_pw_properties_new(PW_KEY_CONFIG_NAME, "client-rt.conf", NULL);
if (props == NULL) {
if (!props) {
return SDL_SetError("Pipewire: Failed to create stream context properties (%i)", errno);
}
priv->context = PIPEWIRE_pw_context_new(PIPEWIRE_pw_thread_loop_get_loop(priv->loop), props, 0);
if (priv->context == NULL) {
if (!priv->context) {
return SDL_SetError("Pipewire: Failed to create stream context (%i)", errno);
}
props = PIPEWIRE_pw_properties_new(NULL, NULL);
if (props == NULL) {
if (!props) {
return SDL_SetError("Pipewire: Failed to create stream properties (%i)", errno);
}
@ -1232,7 +1232,7 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname)
PIPEWIRE_pw_thread_loop_lock(hotplug_loop);
node = io_list_get_by_id(node_id);
if (node != NULL) {
if (node) {
PIPEWIRE_pw_properties_set(props, PW_KEY_TARGET_OBJECT, node->path);
}
PIPEWIRE_pw_thread_loop_unlock(hotplug_loop);
@ -1244,7 +1244,7 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname)
/* Create the new stream */
priv->stream = PIPEWIRE_pw_stream_new_simple(PIPEWIRE_pw_thread_loop_get_loop(priv->loop), stream_name, props,
iscapture ? &stream_input_events : &stream_output_events, this);
if (priv->stream == NULL) {
if (!priv->stream) {
return SDL_SetError("Pipewire: Failed to create stream (%i)", errno);
}
@ -1272,7 +1272,7 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname)
}
/* If this is a capture stream, make sure the intermediate buffer was successfully allocated. */
if (iscapture && priv->buffer == NULL) {
if (iscapture && !priv->buffer) {
return SDL_SetError("Pipewire: Failed to allocate source buffer");
}
@ -1313,13 +1313,13 @@ static int PIPEWIRE_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int is
PIPEWIRE_pw_thread_loop_lock(hotplug_loop);
if (iscapture) {
if (pipewire_default_source_id == NULL) {
if (!pipewire_default_source_id) {
ret = SDL_SetError("PipeWire could not find a default source");
goto failed;
}
target = pipewire_default_source_id;
} else {
if (pipewire_default_sink_id == NULL) {
if (!pipewire_default_sink_id) {
ret = SDL_SetError("PipeWire could not find a default sink");
goto failed;
}
@ -1327,12 +1327,12 @@ static int PIPEWIRE_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int is
}
node = io_list_get_by_path(target);
if (node == NULL) {
if (!node) {
ret = SDL_SetError("PipeWire device list is out of sync with defaults");
goto failed;
}
if (name != NULL) {
if (name) {
*name = SDL_strdup(node->name);
}
SDL_copyp(spec, &node->spec);

View file

@ -42,7 +42,7 @@ static int PS2AUDIO_OpenDevice(_THIS, const char *devname)
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@ -90,7 +90,7 @@ static int PS2AUDIO_OpenDevice(_THIS, const char *devname)
64, so spec->size should be a multiple of 64 as well. */
mixlen = this->spec.size * NUM_BUFFERS;
this->hidden->rawbuf = (Uint8 *)memalign(64, mixlen);
if (this->hidden->rawbuf == NULL) {
if (!this->hidden->rawbuf) {
return SDL_SetError("Couldn't allocate mixing buffer");
}
@ -129,7 +129,7 @@ static void PS2AUDIO_CloseDevice(_THIS)
this->hidden->channel = -1;
}
if (this->hidden->rawbuf != NULL) {
if (this->hidden->rawbuf) {
free(this->hidden->rawbuf);
this->hidden->rawbuf = NULL;
}

View file

@ -52,7 +52,7 @@ static int PSPAUDIO_OpenDevice(_THIS, const char *devname)
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@ -108,7 +108,7 @@ static int PSPAUDIO_OpenDevice(_THIS, const char *devname)
64, so spec->size should be a multiple of 64 as well. */
mixlen = this->spec.size * NUM_BUFFERS;
this->hidden->rawbuf = (Uint8 *)memalign(64, mixlen);
if (this->hidden->rawbuf == NULL) {
if (!this->hidden->rawbuf) {
return SDL_SetError("Couldn't allocate mixing buffer");
}
@ -156,7 +156,7 @@ static void PSPAUDIO_CloseDevice(_THIS)
this->hidden->channel = -1;
}
if (this->hidden->rawbuf != NULL) {
if (this->hidden->rawbuf) {
free(this->hidden->rawbuf);
this->hidden->rawbuf = NULL;
}

View file

@ -125,7 +125,7 @@ static void *pulseaudio_handle = NULL;
static int load_pulseaudio_sym(const char *fn, void **addr)
{
*addr = SDL_LoadFunction(pulseaudio_handle, fn);
if (*addr == NULL) {
if (!*addr) {
/* Don't call SDL_SetError(): SDL_LoadFunction already did. */
return 0;
}
@ -140,7 +140,7 @@ static int load_pulseaudio_sym(const char *fn, void **addr)
static void UnloadPulseAudioLibrary(void)
{
if (pulseaudio_handle != NULL) {
if (pulseaudio_handle) {
SDL_UnloadObject(pulseaudio_handle);
pulseaudio_handle = NULL;
}
@ -149,9 +149,9 @@ static void UnloadPulseAudioLibrary(void)
static int LoadPulseAudioLibrary(void)
{
int retval = 0;
if (pulseaudio_handle == NULL) {
if (!pulseaudio_handle) {
pulseaudio_handle = SDL_LoadObject(pulseaudio_library);
if (pulseaudio_handle == NULL) {
if (!pulseaudio_handle) {
retval = -1;
/* Don't call SDL_SetError(): SDL_LoadObject already did. */
} else {
@ -257,7 +257,7 @@ static const char *getAppName(void)
} else {
const char *verstr = PULSEAUDIO_pa_get_library_version();
retval = "SDL Application"; /* the "oh well" default. */
if (verstr != NULL) {
if (verstr) {
int maj, min, patch;
if (SDL_sscanf(verstr, "%d.%d.%d", &maj, &min, &patch) == 3) {
if (squashVersion(maj, min, patch) >= squashVersion(0, 9, 15)) {
@ -275,7 +275,7 @@ static const char *getAppName(void)
static void WaitForPulseOperation(pa_operation *o)
{
/* This checks for NO errors currently. Either fix that, check results elsewhere, or do things you don't care about. */
SDL_assert(pulseaudio_threaded_mainloop != NULL);
SDL_assert(pulseaudio_threaded_mainloop);
if (o) {
while (PULSEAUDIO_pa_operation_get_state(o) == PA_OPERATION_RUNNING) {
PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop); /* this releases the lock and blocks on an internal condition variable. */
@ -286,7 +286,7 @@ static void WaitForPulseOperation(pa_operation *o)
static void DisconnectFromPulseServer(void)
{
if (pulseaudio_threaded_mainloop != NULL) {
if (pulseaudio_threaded_mainloop) {
PULSEAUDIO_pa_threaded_mainloop_stop(pulseaudio_threaded_mainloop);
}
if (pulseaudio_context) {
@ -294,7 +294,7 @@ static void DisconnectFromPulseServer(void)
PULSEAUDIO_pa_context_unref(pulseaudio_context);
pulseaudio_context = NULL;
}
if (pulseaudio_threaded_mainloop != NULL) {
if (pulseaudio_threaded_mainloop) {
PULSEAUDIO_pa_threaded_mainloop_free(pulseaudio_threaded_mainloop);
pulseaudio_threaded_mainloop = NULL;
}
@ -310,8 +310,8 @@ static int ConnectToPulseServer(void)
pa_mainloop_api *mainloop_api = NULL;
int state = 0;
SDL_assert(pulseaudio_threaded_mainloop == NULL);
SDL_assert(pulseaudio_context == NULL);
SDL_assert(!pulseaudio_threaded_mainloop);
SDL_assert(!pulseaudio_context);
/* Set up a new main loop */
if (!(pulseaudio_threaded_mainloop = PULSEAUDIO_pa_threaded_mainloop_new())) {
@ -334,7 +334,7 @@ static int ConnectToPulseServer(void)
SDL_assert(mainloop_api); /* this never fails, right? */
pulseaudio_context = PULSEAUDIO_pa_context_new(mainloop_api, getAppName());
if (pulseaudio_context == NULL) {
if (!pulseaudio_context) {
SDL_SetError("pa_context_new() failed");
goto failed;
}
@ -445,7 +445,7 @@ static int PULSEAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop);
while (SDL_AtomicGet(&this->enabled)) {
if (h->capturebuf != NULL) {
if (h->capturebuf) {
const int cpy = SDL_min(buflen, h->capturelen);
SDL_memcpy(buffer, h->capturebuf, cpy);
/*printf("PULSEAUDIO: fed %d captured bytes\n", cpy);*/
@ -478,7 +478,7 @@ static int PULSEAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen)
PULSEAUDIO_pa_stream_peek(h->stream, &data, &nbytes);
SDL_assert(nbytes > 0);
/* If data == NULL, then the buffer had a hole, ignore that */
if (data == NULL) {
if (!data) {
PULSEAUDIO_pa_stream_drop(h->stream); /* drop this fragment. */
} else {
/* store this fragment's data, start feeding it to SDL. */
@ -501,7 +501,7 @@ static void PULSEAUDIO_FlushCapture(_THIS)
PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop);
if (h->capturebuf != NULL) {
if (h->capturebuf) {
PULSEAUDIO_pa_stream_drop(h->stream);
h->capturebuf = NULL;
h->capturelen = 0;
@ -530,7 +530,7 @@ static void PULSEAUDIO_CloseDevice(_THIS)
PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop);
if (this->hidden->stream) {
if (this->hidden->capturebuf != NULL) {
if (this->hidden->capturebuf) {
PULSEAUDIO_pa_stream_drop(this->hidden->stream);
}
PULSEAUDIO_pa_stream_disconnect(this->hidden->stream);
@ -566,7 +566,7 @@ static SDL_bool FindDeviceName(struct SDL_PrivateAudioData *h, const SDL_bool is
{
const uint32_t idx = ((uint32_t)((intptr_t)handle)) - 1;
if (handle == NULL) { /* NULL == default device. */
if (!handle) { /* NULL == default device. */
return SDL_TRUE;
}
@ -596,12 +596,12 @@ static int PULSEAUDIO_OpenDevice(_THIS, const char *devname)
int format = PA_SAMPLE_INVALID;
int retval = 0;
SDL_assert(pulseaudio_threaded_mainloop != NULL);
SDL_assert(pulseaudio_context != NULL);
SDL_assert(pulseaudio_threaded_mainloop);
SDL_assert(pulseaudio_context);
/* Initialize all variables that we clean on shutdown */
h = this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@ -651,7 +651,7 @@ static int PULSEAUDIO_OpenDevice(_THIS, const char *devname)
if (!iscapture) {
h->mixlen = this->spec.size;
h->mixbuf = (Uint8 *)SDL_malloc(h->mixlen);
if (h->mixbuf == NULL) {
if (!h->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(h->mixbuf, this->spec.silence, this->spec.size);
@ -686,7 +686,7 @@ static int PULSEAUDIO_OpenDevice(_THIS, const char *devname)
&pacmap /* channel map */
);
if (h->stream == NULL) {
if (!h->stream) {
retval = SDL_SetError("Could not set up PulseAudio stream");
} else {
int rc;
@ -694,7 +694,7 @@ static int PULSEAUDIO_OpenDevice(_THIS, const char *devname)
PULSEAUDIO_pa_stream_set_state_callback(h->stream, PulseStreamStateChangeCallback, NULL);
/* now that we have multi-device support, don't move a stream from
a device that was unplugged to something else, unless we're default. */
if (h->device_name != NULL) {
if (h->device_name) {
flags |= PA_STREAM_DONT_MOVE;
}
@ -772,8 +772,8 @@ static void SinkInfoCallback(pa_context *c, const pa_sink_info *i, int is_last,
SDL_AddAudioDevice(SDL_FALSE, i->description, &spec, (void *)((intptr_t)i->index + 1));
}
if (default_sink_path != NULL && SDL_strcmp(i->name, default_sink_path) == 0) {
if (default_sink_name != NULL) {
if (default_sink_path && SDL_strcmp(i->name, default_sink_path) == 0) {
if (default_sink_name) {
SDL_free(default_sink_name);
}
default_sink_name = SDL_strdup(i->description);
@ -803,8 +803,8 @@ static void SourceInfoCallback(pa_context *c, const pa_source_info *i, int is_la
SDL_AddAudioDevice(SDL_TRUE, i->description, &spec, (void *)((intptr_t)i->index + 1));
}
if (default_source_path != NULL && SDL_strcmp(i->name, default_source_path) == 0) {
if (default_source_name != NULL) {
if (default_source_path && SDL_strcmp(i->name, default_source_path) == 0) {
if (default_source_name) {
SDL_free(default_source_name);
}
default_source_name = SDL_strdup(i->description);
@ -909,12 +909,12 @@ static int PULSEAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int
char *target;
if (iscapture) {
if (default_source_name == NULL) {
if (!default_source_name) {
return SDL_SetError("PulseAudio could not find a default source");
}
target = default_source_name;
} else {
if (default_sink_name == NULL) {
if (!default_sink_name) {
return SDL_SetError("PulseAudio could not find a default sink");
}
target = default_sink_name;
@ -923,7 +923,7 @@ static int PULSEAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int
numdevices = SDL_GetNumAudioDevices(iscapture);
for (i = 0; i < numdevices; i += 1) {
if (SDL_strcmp(SDL_GetAudioDeviceName(i, iscapture), target) == 0) {
if (name != NULL) {
if (name) {
*name = SDL_strdup(target);
}
SDL_GetAudioDeviceSpec(i, iscapture, spec);

View file

@ -232,7 +232,7 @@ static Uint8 *QSA_GetDeviceBuf(_THIS)
static void QSA_CloseDevice(_THIS)
{
if (this->hidden->audio_handle != NULL) {
if (this->hidden->audio_handle) {
#if _NTO_VERSION < 710
if (!this->iscapture) {
/* Finish playing available samples */
@ -267,14 +267,14 @@ static int QSA_OpenDevice(_THIS, const char *devname)
(sizeof
(struct
SDL_PrivateAudioData)));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
/* Initialize channel transfer parameters to default */
QSA_InitAudioParams(&cparams);
if (device != NULL) {
if (device) {
/* Open requested audio device */
this->hidden->deviceno = device->deviceno;
this->hidden->cardno = device->cardno;
@ -387,7 +387,7 @@ static int QSA_OpenDevice(_THIS, const char *devname)
*/
this->hidden->pcm_buf =
(Uint8 *) SDL_malloc(this->hidden->pcm_len);
if (this->hidden->pcm_buf == NULL) {
if (!this->hidden->pcm_buf) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden->pcm_buf, this->spec.silence,

View file

@ -73,7 +73,7 @@ static void *sndio_handle = NULL;
static int load_sndio_sym(const char *fn, void **addr)
{
*addr = SDL_LoadFunction(sndio_handle, fn);
if (*addr == NULL) {
if (!*addr) {
/* Don't call SDL_SetError(): SDL_LoadFunction already did. */
return 0;
}
@ -113,7 +113,7 @@ static int load_sndio_syms(void)
static void UnloadSNDIOLibrary(void)
{
if (sndio_handle != NULL) {
if (sndio_handle) {
SDL_UnloadObject(sndio_handle);
sndio_handle = NULL;
}
@ -122,9 +122,9 @@ static void UnloadSNDIOLibrary(void)
static int LoadSNDIOLibrary(void)
{
int retval = 0;
if (sndio_handle == NULL) {
if (!sndio_handle) {
sndio_handle = SDL_LoadObject(sndio_library);
if (sndio_handle == NULL) {
if (!sndio_handle) {
retval = -1;
/* Don't call SDL_SetError(): SDL_LoadObject already did. */
} else {
@ -211,10 +211,10 @@ static Uint8 *SNDIO_GetDeviceBuf(_THIS)
static void SNDIO_CloseDevice(_THIS)
{
if (this->hidden->pfd != NULL) {
if (this->hidden->pfd) {
SDL_free(this->hidden->pfd);
}
if (this->hidden->dev != NULL) {
if (this->hidden->dev) {
SNDIO_sio_stop(this->hidden->dev);
SNDIO_sio_close(this->hidden->dev);
}
@ -230,7 +230,7 @@ static int SNDIO_OpenDevice(_THIS, const char *devname)
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@ -238,16 +238,16 @@ static int SNDIO_OpenDevice(_THIS, const char *devname)
this->hidden->mixlen = this->spec.size;
/* Capture devices must be non-blocking for SNDIO_FlushCapture */
this->hidden->dev = SNDIO_sio_open(devname != NULL ? devname : SIO_DEVANY,
this->hidden->dev = SNDIO_sio_open(devname ? devname : SIO_DEVANY,
iscapture ? SIO_REC : SIO_PLAY, iscapture);
if (this->hidden->dev == NULL) {
if (!this->hidden->dev) {
return SDL_SetError("sio_open() failed");
}
/* Allocate the pollfd array for capture devices */
if (iscapture) {
this->hidden->pfd = SDL_malloc(sizeof(struct pollfd) * SNDIO_sio_nfds(this->hidden->dev));
if (this->hidden->pfd == NULL) {
if (!this->hidden->pfd) {
return SDL_OutOfMemory();
}
}
@ -315,7 +315,7 @@ static int SNDIO_OpenDevice(_THIS, const char *devname)
/* Allocate mixing buffer */
this->hidden->mixlen = this->spec.size;
this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->hidden->mixlen);
if (this->hidden->mixbuf == NULL) {
if (!this->hidden->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden->mixbuf, this->spec.silence, this->hidden->mixlen);

View file

@ -194,16 +194,16 @@ static int SUNAUDIO_OpenDevice(_THIS, const char *devname)
/* We don't care what the devname is...we'll try to open anything. */
/* ...but default to first name in the list... */
if (devname == NULL) {
if (!devname) {
devname = SDL_GetAudioDeviceName(0, iscapture);
if (devname == NULL) {
if (!devname) {
return SDL_SetError("No such audio device");
}
}
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@ -305,7 +305,7 @@ static int SUNAUDIO_OpenDevice(_THIS, const char *devname)
(this->spec.freq / 8);
this->hidden->frequency = 8;
this->hidden->ulaw_buf = (Uint8 *) SDL_malloc(this->hidden->fragsize);
if (this->hidden->ulaw_buf == NULL) {
if (!this->hidden->ulaw_buf) {
return SDL_OutOfMemory();
}
this->spec.channels = 1;
@ -325,7 +325,7 @@ static int SUNAUDIO_OpenDevice(_THIS, const char *devname)
/* Allocate mixing buffer */
this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->spec.size);
if (this->hidden->mixbuf == NULL) {
if (!this->hidden->mixbuf) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);

View file

@ -67,7 +67,7 @@ static int VITAAUD_OpenDevice(_THIS, const char *devname)
this->hidden = (struct SDL_PrivateAudioData *)
SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_memset(this->hidden, 0, sizeof(*this->hidden));
@ -98,7 +98,7 @@ static int VITAAUD_OpenDevice(_THIS, const char *devname)
64, so spec->size should be a multiple of 64 as well. */
mixlen = this->spec.size * NUM_BUFFERS;
this->hidden->rawbuf = (Uint8 *)memalign(64, mixlen);
if (this->hidden->rawbuf == NULL) {
if (!this->hidden->rawbuf) {
return SDL_SetError("Couldn't allocate mixing buffer");
}
@ -162,7 +162,7 @@ static void VITAAUD_CloseDevice(_THIS)
this->hidden->port = -1;
}
if (!this->iscapture && this->hidden->rawbuf != NULL) {
if (!this->iscapture && this->hidden->rawbuf) {
free(this->hidden->rawbuf); /* this uses memalign(), not SDL_malloc(). */
this->hidden->rawbuf = NULL;
}

View file

@ -114,7 +114,7 @@ static int UpdateAudioStream(_THIS, const SDL_AudioSpec *oldspec)
/* make sure our scratch buffer can cover the new device spec. */
if (this->spec.size > this->work_buffer_len) {
Uint8 *ptr = (Uint8 *)SDL_realloc(this->work_buffer, this->spec.size);
if (ptr == NULL) {
if (!ptr) {
return SDL_OutOfMemory();
}
this->work_buffer = ptr;
@ -181,7 +181,7 @@ static Uint8 *WASAPI_GetDeviceBuf(_THIS)
if (!WasapiFailed(this, IAudioRenderClient_GetBuffer(this->hidden->render, this->spec.samples, &buffer))) {
return (Uint8 *)buffer;
}
SDL_assert(buffer == NULL);
SDL_assert(!buffer);
}
return (Uint8 *)buffer;
@ -189,7 +189,7 @@ static Uint8 *WASAPI_GetDeviceBuf(_THIS)
static void WASAPI_PlayDevice(_THIS)
{
if (this->hidden->render != NULL) { /* definitely activated? */
if (this->hidden->render) { /* definitely activated? */
/* WasapiFailed() will mark the device for reacquisition or removal elsewhere. */
WasapiFailed(this, IAudioRenderClient_ReleaseBuffer(this->hidden->render, this->spec.samples, 0));
}
@ -407,7 +407,7 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream)
HRESULT ret = S_OK;
DWORD streamflags = 0;
SDL_assert(client != NULL);
SDL_assert(client);
#if defined(__WINRT__) || defined(__GDK__) /* CreateEventEx() arrived in Vista, so we need an #ifdef for XP. */
this->hidden->event = CreateEventEx(NULL, NULL, 0, EVENT_ALL_ACCESS);
@ -415,7 +415,7 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream)
this->hidden->event = CreateEventW(NULL, 0, 0, NULL);
#endif
if (this->hidden->event == NULL) {
if (!this->hidden->event) {
return WIN_SetError("WASAPI can't create an event handle");
}
@ -424,7 +424,7 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream)
return WIN_SetErrorFromHRESULT("WASAPI can't determine mix format", ret);
}
SDL_assert(waveformat != NULL);
SDL_assert(waveformat);
this->hidden->waveformat = waveformat;
this->spec.channels = (Uint8)waveformat->nChannels;
@ -502,7 +502,7 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream)
return WIN_SetErrorFromHRESULT("WASAPI can't get capture client service", ret);
}
SDL_assert(capture != NULL);
SDL_assert(capture);
this->hidden->capture = capture;
ret = IAudioClient_Start(client);
if (FAILED(ret)) {
@ -516,7 +516,7 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream)
return WIN_SetErrorFromHRESULT("WASAPI can't get render client service", ret);
}
SDL_assert(render != NULL);
SDL_assert(render);
this->hidden->render = render;
ret = IAudioClient_Start(client);
if (FAILED(ret)) {
@ -537,7 +537,7 @@ static int WASAPI_OpenDevice(_THIS, const char *devname)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);

View file

@ -120,11 +120,11 @@ int WASAPI_ActivateDevice(_THIS, const SDL_bool isrecovery)
IMMDevice_Release(device);
if (FAILED(ret)) {
SDL_assert(this->hidden->client == NULL);
SDL_assert(!this->hidden->client);
return WIN_SetErrorFromHRESULT("WASAPI can't activate audio endpoint", ret);
}
SDL_assert(this->hidden->client != NULL);
SDL_assert(this->hidden->client);
if (WASAPI_PrepDevice(this, isrecovery) == -1) { /* not async, fire it right away. */
return -1;
}

View file

@ -405,7 +405,7 @@ static void WASAPI_AddDevice(const SDL_bool iscapture, const char *devname, WAVE
}
devidlist = (DevIdList *)SDL_malloc(sizeof(*devidlist));
if (devidlist == NULL) {
if (!devidlist) {
return; /* oh well. */
}

View file

@ -279,7 +279,7 @@ static int WINMM_OpenDevice(_THIS, const char *devname)
UINT devId = WAVE_MAPPER; /* WAVE_MAPPER == choose system's default */
UINT i;
if (handle != NULL) { /* specific device requested? */
if (handle) { /* specific device requested? */
/* -1 because we increment the original value to avoid NULL. */
const size_t val = ((size_t) handle) - 1;
devId = (UINT) val;
@ -287,7 +287,7 @@ static int WINMM_OpenDevice(_THIS, const char *devname)
/* Initialize all variables that we clean on shutdown */
this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden));
if (this->hidden == NULL) {
if (!this->hidden) {
return SDL_OutOfMemory();
}
SDL_zerop(this->hidden);
@ -365,14 +365,14 @@ static int WINMM_OpenDevice(_THIS, const char *devname)
/* Create the audio buffer semaphore */
this->hidden->audio_sem = CreateSemaphore(NULL, iscapture ? 0 : NUM_BUFFERS - 1, NUM_BUFFERS, NULL);
if (this->hidden->audio_sem == NULL) {
if (!this->hidden->audio_sem) {
return SDL_SetError("Couldn't create semaphore");
}
/* Create the sound buffers */
this->hidden->mixbuf =
(Uint8 *) SDL_malloc(NUM_BUFFERS * this->spec.size);
if (this->hidden->mixbuf == NULL) {
if (!this->hidden->mixbuf) {
return SDL_OutOfMemory();
}

View file

@ -420,12 +420,12 @@ JNIEnv *Android_JNI_GetEnv(void)
{
/* Get JNIEnv from the Thread local storage */
JNIEnv *env = pthread_getspecific(mThreadKey);
if (env == NULL) {
if (!env) {
/* If it fails, try to attach ! (e.g the thread isn't created with SDL_CreateThread() */
int status;
/* There should be a JVM */
if (mJavaVM == NULL) {
if (!mJavaVM) {
__android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed, there is no JavaVM");
return NULL;
}
@ -454,7 +454,7 @@ int Android_JNI_SetupThread(void)
int status;
/* There should be a JVM */
if (mJavaVM == NULL) {
if (!mJavaVM) {
__android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed, there is no JavaVM");
return 0;
}
@ -480,7 +480,7 @@ static void Android_JNI_ThreadDestroyed(void *value)
{
/* The thread is being destroyed, detach it from the Java VM and set the mThreadKey value to NULL as required */
JNIEnv *env = (JNIEnv *)value;
if (env != NULL) {
if (env) {
(*mJavaVM)->DetachCurrentThread(mJavaVM);
Android_JNI_SetEnv(NULL);
}
@ -506,7 +506,7 @@ static void Android_JNI_CreateKey_once(void)
static void register_methods(JNIEnv *env, const char *classname, JNINativeMethod *methods, int nb)
{
jclass clazz = (*env)->FindClass(env, classname);
if (clazz == NULL || (*env)->RegisterNatives(env, clazz, methods, nb) < 0) {
if (!clazz || (*env)->RegisterNatives(env, clazz, methods, nb) < 0) {
__android_log_print(ANDROID_LOG_ERROR, "SDL", "Failed to register methods of %s", classname);
return;
}
@ -566,28 +566,28 @@ JNIEXPORT void JNICALL SDL_JAVA_INTERFACE(nativeSetupJNI)(JNIEnv *env, jclass cl
/* Save JNIEnv of SDLActivity */
Android_JNI_SetEnv(env);
if (mJavaVM == NULL) {
if (!mJavaVM) {
__android_log_print(ANDROID_LOG_ERROR, "SDL", "failed to found a JavaVM");
}
/* Use a mutex to prevent concurrency issues between Java Activity and Native thread code, when using 'Android_Window'.
* (Eg. Java sending Touch events, while native code is destroying the main SDL_Window. )
*/
if (Android_ActivityMutex == NULL) {
if (!Android_ActivityMutex) {
Android_ActivityMutex = SDL_CreateMutex(); /* Could this be created twice if onCreate() is called a second time ? */
}
if (Android_ActivityMutex == NULL) {
if (!Android_ActivityMutex) {
__android_log_print(ANDROID_LOG_ERROR, "SDL", "failed to create Android_ActivityMutex mutex");
}
Android_PauseSem = SDL_CreateSemaphore(0);
if (Android_PauseSem == NULL) {
if (!Android_PauseSem) {
__android_log_print(ANDROID_LOG_ERROR, "SDL", "failed to create Android_PauseSem semaphore");
}
Android_ResumeSem = SDL_CreateSemaphore(0);
if (Android_ResumeSem == NULL) {
if (!Android_ResumeSem) {
__android_log_print(ANDROID_LOG_ERROR, "SDL", "failed to create Android_ResumeSem semaphore");
}
@ -1557,7 +1557,7 @@ int Android_JNI_OpenAudioDevice(int iscapture, int device_id, SDL_AudioSpec *spe
__android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDL audio: opening device for output");
result = (*env)->CallStaticObjectMethod(env, mAudioManagerClass, midAudioOpen, spec->freq, audioformat, spec->channels, spec->samples, device_id);
}
if (result == NULL) {
if (!result) {
/* Error during audio initialization, error printed from Java */
return SDL_SetError("Java-side initialization failed");
}
@ -1618,7 +1618,7 @@ int Android_JNI_OpenAudioDevice(int iscapture, int device_id, SDL_AudioSpec *spe
return SDL_SetError("Unexpected audio format from Java: %d\n", audioformat);
}
if (jbufobj == NULL) {
if (!jbufobj) {
__android_log_print(ANDROID_LOG_WARN, "SDL", "SDL audio: could not allocate an audio buffer");
return SDL_OutOfMemory();
}
@ -1910,7 +1910,7 @@ static void Internal_Android_Create_AssetManager()
javaAssetManagerRef = (*env)->NewGlobalRef(env, javaAssetManager);
asset_manager = AAssetManager_fromJava(env, javaAssetManagerRef);
if (asset_manager == NULL) {
if (!asset_manager) {
(*env)->DeleteGlobalRef(env, javaAssetManagerRef);
Android_JNI_ExceptionOccurred(SDL_TRUE);
}
@ -1934,16 +1934,16 @@ int Android_JNI_FileOpen(SDL_RWops *ctx,
AAsset *asset = NULL;
ctx->hidden.androidio.asset = NULL;
if (asset_manager == NULL) {
if (!asset_manager) {
Internal_Android_Create_AssetManager();
}
if (asset_manager == NULL) {
if (!asset_manager) {
return SDL_SetError("Couldn't create asset manager");
}
asset = AAssetManager_open(asset_manager, fileName, AASSET_MODE_UNKNOWN);
if (asset == NULL) {
if (!asset) {
return SDL_SetError("Couldn't open asset '%s'", fileName);
}
@ -2022,7 +2022,7 @@ char *Android_JNI_GetClipboardText(void)
(*env)->DeleteLocalRef(env, string);
}
return (text == NULL) ? SDL_strdup("") : text;
return (!text) ? SDL_strdup("") : text;
}
SDL_bool Android_JNI_HasClipboardText(void)
@ -2343,7 +2343,7 @@ void *SDL_AndroidGetActivity(void)
/* See SDL_system.h for caveats on using this function. */
JNIEnv *env = Android_JNI_GetEnv();
if (env == NULL) {
if (!env) {
return NULL;
}
@ -2397,7 +2397,7 @@ const char *SDL_AndroidGetInternalStoragePath(void)
{
static char *s_AndroidInternalFilesPath = NULL;
if (s_AndroidInternalFilesPath == NULL) {
if (!s_AndroidInternalFilesPath) {
struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__);
jmethodID mid;
jobject context;
@ -2490,7 +2490,7 @@ const char *SDL_AndroidGetExternalStoragePath(void)
{
static char *s_AndroidExternalFilesPath = NULL;
if (s_AndroidExternalFilesPath == NULL) {
if (!s_AndroidExternalFilesPath) {
struct LocalReferenceHolder refs = LocalReferenceHolder_Setup(__FUNCTION__);
jmethodID mid;
jobject context;
@ -2646,16 +2646,16 @@ int Android_JNI_GetLocale(char *buf, size_t buflen)
/* Need to re-create the asset manager if locale has changed (SDL_LOCALECHANGED) */
Internal_Android_Destroy_AssetManager();
if (asset_manager == NULL) {
if (!asset_manager) {
Internal_Android_Create_AssetManager();
}
if (asset_manager == NULL) {
if (!asset_manager) {
return -1;
}
cfg = AConfiguration_new();
if (cfg == NULL) {
if (!cfg) {
return -1;
}

View file

@ -88,7 +88,7 @@ static void kbd_cleanup(void)
{
struct mouse_info mData;
SDL_EVDEV_keyboard_state *kbd = kbd_cleanup_state;
if (kbd == NULL) {
if (!kbd) {
return;
}
kbd_cleanup_state = NULL;
@ -179,7 +179,7 @@ static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state *kbd)
{
int tabidx, signum;
if (kbd_cleanup_state != NULL) {
if (kbd_cleanup_state) {
return;
}
kbd_cleanup_state = kbd;
@ -231,7 +231,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void)
SDL_zero(mData);
mData.operation = MOUSE_HIDE;
kbd = (SDL_EVDEV_keyboard_state *)SDL_calloc(1, sizeof(SDL_EVDEV_keyboard_state));
if (kbd == NULL) {
if (!kbd) {
return NULL;
}
@ -297,7 +297,7 @@ void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd)
{
struct mouse_info mData;
if (kbd == NULL) {
if (!kbd) {
return;
}
SDL_zero(mData);
@ -487,7 +487,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *kbd, unsigned int keycode,
unsigned int final_key_state;
unsigned int map_from_key_sym;
if (kbd == NULL) {
if (!kbd) {
return;
}

View file

@ -99,7 +99,7 @@ static int LoadDBUSSyms(void)
static void UnloadDBUSLibrary(void)
{
if (dbus_handle != NULL) {
if (dbus_handle) {
SDL_UnloadObject(dbus_handle);
dbus_handle = NULL;
}
@ -108,9 +108,9 @@ static void UnloadDBUSLibrary(void)
static int LoadDBUSLibrary(void)
{
int retval = 0;
if (dbus_handle == NULL) {
if (!dbus_handle) {
dbus_handle = SDL_LoadObject(dbus_library);
if (dbus_handle == NULL) {
if (!dbus_handle) {
retval = -1;
/* Don't call SDL_SetError(): SDL_LoadObject already did. */
} else {
@ -202,7 +202,7 @@ void SDL_DBus_Quit(void)
SDL_DBusContext *SDL_DBus_GetContext(void)
{
if (dbus_handle == NULL || !dbus.session_conn) {
if (!dbus_handle || !dbus.session_conn) {
SDL_DBus_Init();
}
@ -363,7 +363,7 @@ SDL_bool SDL_DBus_QueryProperty(const char *node, const char *path, const char *
void SDL_DBus_ScreensaverTickle(void)
{
if (screensaver_cookie == 0 && inhibit_handle == NULL) { /* no need to tickle if we're inhibiting. */
if (screensaver_cookie == 0 && !inhibit_handle) { /* no need to tickle if we're inhibiting. */
/* org.gnome.ScreenSaver is the legacy interface, but it'll either do nothing or just be a second harmless tickle on newer systems, so we leave it for now. */
SDL_DBus_CallVoidMethod("org.gnome.ScreenSaver", "/org/gnome/ScreenSaver", "org.gnome.ScreenSaver", "SimulateUserActivity", DBUS_TYPE_INVALID);
SDL_DBus_CallVoidMethod("org.freedesktop.ScreenSaver", "/org/freedesktop/ScreenSaver", "org.freedesktop.ScreenSaver", "SimulateUserActivity", DBUS_TYPE_INVALID);
@ -411,7 +411,7 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
{
const char *default_inhibit_reason = "Playing a game";
if ((inhibit && (screensaver_cookie != 0 || inhibit_handle != NULL)) || (!inhibit && (screensaver_cookie == 0 && inhibit_handle == NULL))) {
if ((inhibit && (screensaver_cookie != 0 || inhibit_handle)) || (!inhibit && (screensaver_cookie == 0 && !inhibit_handle))) {
return SDL_TRUE;
}
@ -435,12 +435,12 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
const char *key = "reason";
const char *reply = NULL;
const char *reason = SDL_GetHint(SDL_HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME);
if (reason == NULL || !reason[0]) {
if (!reason || !reason[0]) {
reason = default_inhibit_reason;
}
msg = dbus.message_new_method_call(bus_name, path, interface, "Inhibit");
if (msg == NULL) {
if (!msg) {
return SDL_FALSE;
}
@ -477,10 +477,10 @@ SDL_bool SDL_DBus_ScreensaverInhibit(SDL_bool inhibit)
if (inhibit) {
const char *app = SDL_GetHint(SDL_HINT_APP_NAME);
const char *reason = SDL_GetHint(SDL_HINT_SCREENSAVER_INHIBIT_ACTIVITY_NAME);
if (app == NULL || !app[0]) {
if (!app || !app[0]) {
app = "My SDL application";
}
if (reason == NULL || !reason[0]) {
if (!reason || !reason[0]) {
reason = default_inhibit_reason;
}

View file

@ -162,9 +162,9 @@ static void SDL_EVDEV_UpdateKeyboardMute(void)
int SDL_EVDEV_Init(void)
{
if (_this == NULL) {
if (!_this) {
_this = (SDL_EVDEV_PrivateData *)SDL_calloc(1, sizeof(*_this));
if (_this == NULL) {
if (!_this) {
return SDL_OutOfMemory();
}
@ -226,7 +226,7 @@ int SDL_EVDEV_Init(void)
void SDL_EVDEV_Quit(void)
{
if (_this == NULL) {
if (!_this) {
return;
}
@ -239,14 +239,14 @@ void SDL_EVDEV_Quit(void)
#endif /* SDL_USE_LIBUDEV */
/* Remove existing devices */
while (_this->first != NULL) {
while (_this->first) {
SDL_EVDEV_device_removed(_this->first->path);
}
SDL_EVDEV_kbd_quit(_this->kbd);
SDL_assert(_this->first == NULL);
SDL_assert(_this->last == NULL);
SDL_assert(!_this->first);
SDL_assert(!_this->last);
SDL_assert(_this->num_devices == 0);
SDL_free(_this);
@ -258,7 +258,7 @@ void SDL_EVDEV_Quit(void)
static void SDL_EVDEV_udev_callback(SDL_UDEV_deviceevent udev_event, int udev_class,
const char *dev_path)
{
if (dev_path == NULL) {
if (!dev_path) {
return;
}
@ -296,7 +296,7 @@ int SDL_EVDEV_GetDeviceCount(int device_class)
SDL_evdevlist_item *item;
int count = 0;
for (item = _this->first; item != NULL; item = item->next) {
for (item = _this->first; item; item = item->next) {
if ((item->udev_class & device_class) == device_class) {
++count;
}
@ -326,7 +326,7 @@ void SDL_EVDEV_Poll(void)
mouse = SDL_GetMouse();
for (item = _this->first; item != NULL; item = item->next) {
for (item = _this->first; item; item = item->next) {
while ((len = read(item->fd, events, sizeof(events))) > 0) {
len /= sizeof(events[0]);
for (i = 0; i < len; ++i) {
@ -625,7 +625,7 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
}
item->touchscreen_data = SDL_calloc(1, sizeof(*item->touchscreen_data));
if (item->touchscreen_data == NULL) {
if (!item->touchscreen_data) {
return SDL_OutOfMemory();
}
@ -636,7 +636,7 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
}
item->touchscreen_data->name = SDL_strdup(name);
if (item->touchscreen_data->name == NULL) {
if (!item->touchscreen_data->name) {
SDL_free(item->touchscreen_data);
return SDL_OutOfMemory();
}
@ -691,7 +691,7 @@ static int SDL_EVDEV_init_touchscreen(SDL_evdevlist_item *item, int udev_class)
item->touchscreen_data->slots = SDL_calloc(
item->touchscreen_data->max_slots,
sizeof(*item->touchscreen_data->slots));
if (item->touchscreen_data->slots == NULL) {
if (!item->touchscreen_data->slots) {
SDL_free(item->touchscreen_data->name);
SDL_free(item->touchscreen_data);
return SDL_OutOfMemory();
@ -752,7 +752,7 @@ static void SDL_EVDEV_sync_device(SDL_evdevlist_item *item)
sizeof(*mt_req_values) * item->touchscreen_data->max_slots;
mt_req_code = SDL_calloc(1, mt_req_size);
if (mt_req_code == NULL) {
if (!mt_req_code) {
return;
}
@ -858,14 +858,14 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
unsigned long relbit[NBITS(REL_MAX)] = { 0 };
/* Check to make sure it's not already in list. */
for (item = _this->first; item != NULL; item = item->next) {
for (item = _this->first; item; item = item->next) {
if (SDL_strcmp(dev_path, item->path) == 0) {
return -1; /* already have this one */
}
}
item = (SDL_evdevlist_item *)SDL_calloc(1, sizeof(SDL_evdevlist_item));
if (item == NULL) {
if (!item) {
return SDL_OutOfMemory();
}
@ -876,7 +876,7 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
}
item->path = SDL_strdup(dev_path);
if (item->path == NULL) {
if (!item->path) {
close(item->fd);
SDL_free(item);
return SDL_OutOfMemory();
@ -910,7 +910,7 @@ static int SDL_EVDEV_device_added(const char *dev_path, int udev_class)
}
}
if (_this->last == NULL) {
if (!_this->last) {
_this->first = _this->last = item;
} else {
_this->last->next = item;
@ -929,10 +929,10 @@ static int SDL_EVDEV_device_removed(const char *dev_path)
SDL_evdevlist_item *item;
SDL_evdevlist_item *prev = NULL;
for (item = _this->first; item != NULL; item = item->next) {
for (item = _this->first; item; item = item->next) {
/* found it, remove it. */
if (SDL_strcmp(dev_path, item->path) == 0) {
if (prev != NULL) {
if (prev) {
prev->next = item->next;
} else {
SDL_assert(_this->first == item);

View file

@ -174,7 +174,7 @@ static int fatal_signals[] = {
static void kbd_cleanup(void)
{
SDL_EVDEV_keyboard_state *kbd = kbd_cleanup_state;
if (kbd == NULL) {
if (!kbd) {
return;
}
kbd_cleanup_state = NULL;
@ -259,7 +259,7 @@ static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state *kbd)
{
int tabidx, signum;
if (kbd_cleanup_state != NULL) {
if (kbd_cleanup_state) {
return;
}
kbd_cleanup_state = kbd;
@ -385,7 +385,7 @@ static int kbd_vt_init(int console_fd)
vt_release_signal = find_free_signal(kbd_vt_release_signal_action);
vt_acquire_signal = find_free_signal(kbd_vt_acquire_signal_action);
if (!vt_release_signal || !vt_acquire_signal ) {
if (!vt_release_signal || !vt_acquire_signal) {
kbd_vt_quit(console_fd);
return -1;
}
@ -429,7 +429,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void)
char shift_state[sizeof(long)] = { TIOCL_GETSHIFTSTATE, 0 };
kbd = (SDL_EVDEV_keyboard_state *)SDL_calloc(1, sizeof(*kbd));
if (kbd == NULL) {
if (!kbd) {
return NULL;
}
@ -465,7 +465,7 @@ SDL_EVDEV_keyboard_state *SDL_EVDEV_kbd_init(void)
void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted)
{
if (state == NULL) {
if (!state) {
return;
}
@ -499,7 +499,7 @@ void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted)
void SDL_EVDEV_kbd_set_vt_switch_callbacks(SDL_EVDEV_keyboard_state *state, void (*release_callback)(void*), void *release_callback_data, void (*acquire_callback)(void*), void *acquire_callback_data)
{
if (state == NULL) {
if (!state) {
return;
}
@ -520,7 +520,7 @@ void SDL_EVDEV_kbd_update(SDL_EVDEV_keyboard_state *state)
void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state)
{
if (state == NULL) {
if (!state) {
return;
}
@ -893,7 +893,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode
unsigned short *key_map;
unsigned short keysym;
if (state == NULL) {
if (!state) {
return;
}
@ -901,7 +901,7 @@ void SDL_EVDEV_kbd_keycode(SDL_EVDEV_keyboard_state *state, unsigned int keycode
shift_final = (state->shift_state | state->slockstate) ^ state->lockstate;
key_map = state->key_maps[shift_final];
if (key_map == NULL) {
if (!key_map) {
/* Unsupported shift state (e.g. ctrl = 4, alt = 8), just reset to the default state */
state->shift_state = 0;
state->slockstate = 0;

View file

@ -438,7 +438,7 @@ void SDL_Fcitx_UpdateTextRect(const SDL_Rect *rect)
}
focused_win = SDL_GetKeyboardFocus();
if (focused_win == NULL) {
if (!focused_win) {
return;
}

View file

@ -112,7 +112,7 @@ static SDL_bool IBus_EnterVariant(DBusConnection *conn, DBusMessageIter *iter, S
}
dbus->message_iter_get_basic(inside, &struct_id);
if (struct_id == NULL || SDL_strncmp(struct_id, struct_id, id_size) != 0) {
if (!struct_id || SDL_strncmp(struct_id, struct_id, id_size) != 0) {
return SDL_FALSE;
}
return SDL_TRUE;
@ -306,7 +306,7 @@ static char *IBus_ReadAddressFromFile(const char *file_path)
FILE *addr_file;
addr_file = fopen(file_path, "r");
if (addr_file == NULL) {
if (!addr_file) {
return NULL;
}
@ -351,7 +351,7 @@ static char *IBus_GetDBusAddressFilename(void)
}
dbus = SDL_DBus_GetContext();
if (dbus == NULL) {
if (!dbus) {
return NULL;
}
@ -365,7 +365,7 @@ static char *IBus_GetDBusAddressFilename(void)
and look up the address from a filepath using all those bits, eek. */
disp_env = SDL_getenv("DISPLAY");
if (disp_env == NULL || !*disp_env) {
if (!disp_env || !*disp_env) {
display = SDL_strdup(":0.0");
} else {
display = SDL_strdup(disp_env);
@ -375,7 +375,7 @@ static char *IBus_GetDBusAddressFilename(void)
disp_num = SDL_strrchr(display, ':');
screen_num = SDL_strrchr(display, '.');
if (disp_num == NULL) {
if (!disp_num) {
SDL_free(display);
return NULL;
}
@ -389,7 +389,7 @@ static char *IBus_GetDBusAddressFilename(void)
if (!*host) {
const char *session = SDL_getenv("XDG_SESSION_TYPE");
if (session != NULL && SDL_strcmp(session, "wayland") == 0) {
if (session && SDL_strcmp(session, "wayland") == 0) {
host = "unix-wayland";
} else {
host = "unix";
@ -403,7 +403,7 @@ static char *IBus_GetDBusAddressFilename(void)
SDL_strlcpy(config_dir, conf_env, sizeof(config_dir));
} else {
const char *home_env = SDL_getenv("HOME");
if (home_env == NULL || !*home_env) {
if (!home_env || !*home_env) {
SDL_free(display);
return NULL;
}
@ -412,7 +412,7 @@ static char *IBus_GetDBusAddressFilename(void)
key = SDL_DBus_GetLocalMachineId();
if (key == NULL) {
if (!key) {
SDL_free(display);
return NULL;
}
@ -473,7 +473,7 @@ static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr)
ibus_input_interface = IBUS_INPUT_INTERFACE;
ibus_conn = dbus->connection_open_private(addr, NULL);
if (ibus_conn == NULL) {
if (!ibus_conn) {
return SDL_FALSE; /* oh well. */
}
@ -513,7 +513,7 @@ static SDL_bool IBus_SetupConnection(SDL_DBusContext *dbus, const char *addr)
static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus)
{
if (dbus == NULL) {
if (!dbus) {
return SDL_FALSE;
}
@ -533,7 +533,7 @@ static SDL_bool IBus_CheckConnection(SDL_DBusContext *dbus)
struct inotify_event *event = (struct inotify_event *)p;
if (event->len > 0) {
char *addr_file_no_path = SDL_strrchr(ibus_addr_file, '/');
if (addr_file_no_path == NULL) {
if (!addr_file_no_path) {
return SDL_FALSE;
}
@ -570,12 +570,12 @@ SDL_bool SDL_IBus_Init(void)
char *addr;
char *addr_file_dir;
if (addr_file == NULL) {
if (!addr_file) {
return SDL_FALSE;
}
addr = IBus_ReadAddressFromFile(addr_file);
if (addr == NULL) {
if (!addr) {
SDL_free(addr_file);
return SDL_FALSE;
}
@ -661,7 +661,7 @@ static void IBus_SimpleMessage(const char *method)
{
SDL_DBusContext *dbus = SDL_DBus_GetContext();
if ((input_ctx_path != NULL) && (IBus_CheckConnection(dbus))) {
if ((input_ctx_path) && (IBus_CheckConnection(dbus))) {
SDL_DBus_CallVoidMethodOnConnection(ibus_conn, ibus_service, input_ctx_path, ibus_input_interface, method, DBUS_TYPE_INVALID);
}
}
@ -712,7 +712,7 @@ void SDL_IBus_UpdateTextRect(const SDL_Rect *rect)
}
focused_win = SDL_GetKeyboardFocus();
if (focused_win == NULL) {
if (!focused_win) {
return;
}

View file

@ -56,9 +56,9 @@ static void InitIME()
/* See if fcitx IME support is being requested */
#ifdef HAVE_FCITX
if (SDL_IME_Init_Real == NULL &&
if (!SDL_IME_Init_Real &&
((im_module && SDL_strcmp(im_module, "fcitx") == 0) ||
(im_module == NULL && xmodifiers && SDL_strstr(xmodifiers, "@im=fcitx") != NULL))) {
(!im_module && xmodifiers && SDL_strstr(xmodifiers, "@im=fcitx") != NULL))) {
SDL_IME_Init_Real = SDL_Fcitx_Init;
SDL_IME_Quit_Real = SDL_Fcitx_Quit;
SDL_IME_SetFocus_Real = SDL_Fcitx_SetFocus;
@ -71,7 +71,7 @@ static void InitIME()
/* default to IBus */
#ifdef HAVE_IBUS_IBUS_H
if (SDL_IME_Init_Real == NULL) {
if (!SDL_IME_Init_Real) {
SDL_IME_Init_Real = SDL_IBus_Init;
SDL_IME_Quit_Real = SDL_IBus_Quit;
SDL_IME_SetFocus_Real = SDL_IBus_SetFocus;

View file

@ -116,19 +116,19 @@ static void rtkit_initialize()
dbus_conn = get_rtkit_dbus_connection();
/* Try getting minimum nice level: this is often greater than PRIO_MIN (-20). */
if (dbus_conn == NULL || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MinNiceLevel",
if (!dbus_conn || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MinNiceLevel",
DBUS_TYPE_INT32, &rtkit_min_nice_level)) {
rtkit_min_nice_level = -20;
}
/* Try getting maximum realtime priority: this can be less than the POSIX default (99). */
if (dbus_conn == NULL || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MaxRealtimePriority",
if (!dbus_conn || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MaxRealtimePriority",
DBUS_TYPE_INT32, &rtkit_max_realtime_priority)) {
rtkit_max_realtime_priority = 99;
}
/* Try getting maximum rttime allowed by rtkit: exceeding this value will result in SIGKILL */
if (dbus_conn == NULL || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "RTTimeUSecMax",
if (!dbus_conn || !SDL_DBus_QueryPropertyOnConnection(dbus_conn, rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "RTTimeUSecMax",
DBUS_TYPE_INT64, &rtkit_max_rttime_usec)) {
rtkit_max_rttime_usec = 200000;
}
@ -207,7 +207,7 @@ static SDL_bool rtkit_setpriority_nice(pid_t thread, int nice_level)
nice = rtkit_min_nice_level;
}
if (dbus_conn == NULL || !SDL_DBus_CallMethodOnConnection(dbus_conn,
if (!dbus_conn || !SDL_DBus_CallMethodOnConnection(dbus_conn,
rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MakeThreadHighPriorityWithPID",
DBUS_TYPE_UINT64, &pid, DBUS_TYPE_UINT64, &tid, DBUS_TYPE_INT32, &nice, DBUS_TYPE_INVALID,
DBUS_TYPE_INVALID)) {
@ -238,7 +238,7 @@ static SDL_bool rtkit_setpriority_realtime(pid_t thread, int rt_priority)
// go through to determine whether it really needs to fail or not.
rtkit_initialize_realtime_thread();
if (dbus_conn == NULL || !SDL_DBus_CallMethodOnConnection(dbus_conn,
if (!dbus_conn || !SDL_DBus_CallMethodOnConnection(dbus_conn,
rtkit_dbus_node, rtkit_dbus_path, rtkit_dbus_interface, "MakeThreadRealtimeWithPID",
DBUS_TYPE_UINT64, &pid, DBUS_TYPE_UINT64, &tid, DBUS_TYPE_UINT32, &priority, DBUS_TYPE_INVALID,
DBUS_TYPE_INVALID)) {

View file

@ -52,7 +52,7 @@ static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev);
static SDL_bool SDL_UDEV_load_sym(const char *fn, void **addr)
{
*addr = SDL_LoadFunction(_this->udev_handle, fn);
if (*addr == NULL) {
if (!*addr) {
/* Don't call SDL_SetError(): SDL_LoadFunction already did. */
return SDL_FALSE;
}
@ -100,7 +100,7 @@ static int SDL_UDEV_load_syms(void)
static SDL_bool SDL_UDEV_hotplug_update_available(void)
{
if (_this->udev_mon != NULL) {
if (_this->udev_mon) {
const int fd = _this->syms.udev_monitor_get_fd(_this->udev_mon);
if (SDL_IOReady(fd, SDL_IOR_READ, 0)) {
return SDL_TRUE;
@ -113,9 +113,9 @@ int SDL_UDEV_Init(void)
{
int retval = 0;
if (_this == NULL) {
if (!_this) {
_this = (SDL_UDEV_PrivateData *)SDL_calloc(1, sizeof(*_this));
if (_this == NULL) {
if (!_this) {
return SDL_OutOfMemory();
}
@ -130,13 +130,13 @@ int SDL_UDEV_Init(void)
*/
_this->udev = _this->syms.udev_new();
if (_this->udev == NULL) {
if (!_this->udev) {
SDL_UDEV_Quit();
return SDL_SetError("udev_new() failed");
}
_this->udev_mon = _this->syms.udev_monitor_new_from_netlink(_this->udev, "udev");
if (_this->udev_mon == NULL) {
if (!_this->udev_mon) {
SDL_UDEV_Quit();
return SDL_SetError("udev_monitor_new_from_netlink() failed");
}
@ -158,7 +158,7 @@ void SDL_UDEV_Quit(void)
{
SDL_UDEV_CallbackList *item;
if (_this == NULL) {
if (!_this) {
return;
}
@ -166,17 +166,17 @@ void SDL_UDEV_Quit(void)
if (_this->ref_count < 1) {
if (_this->udev_mon != NULL) {
if (_this->udev_mon) {
_this->syms.udev_monitor_unref(_this->udev_mon);
_this->udev_mon = NULL;
}
if (_this->udev != NULL) {
if (_this->udev) {
_this->syms.udev_unref(_this->udev);
_this->udev = NULL;
}
/* Remove existing devices */
while (_this->first != NULL) {
while (_this->first) {
item = _this->first;
_this->first = _this->first->next;
SDL_free(item);
@ -194,12 +194,12 @@ void SDL_UDEV_Scan(void)
struct udev_list_entry *devs = NULL;
struct udev_list_entry *item = NULL;
if (_this == NULL) {
if (!_this) {
return;
}
enumerate = _this->syms.udev_enumerate_new(_this->udev);
if (enumerate == NULL) {
if (!enumerate) {
SDL_UDEV_Quit();
SDL_SetError("udev_enumerate_new() failed");
return;
@ -213,7 +213,7 @@ void SDL_UDEV_Scan(void)
for (item = devs; item; item = _this->syms.udev_list_entry_get_next(item)) {
const char *path = _this->syms.udev_list_entry_get_name(item);
struct udev_device *dev = _this->syms.udev_device_new_from_syspath(_this->udev, path);
if (dev != NULL) {
if (dev) {
device_event(SDL_UDEV_DEVICEADDED, dev);
_this->syms.udev_device_unref(dev);
}
@ -229,12 +229,12 @@ SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16
struct udev_list_entry *item = NULL;
SDL_bool found = SDL_FALSE;
if (_this == NULL) {
if (!_this) {
return SDL_FALSE;
}
enumerate = _this->syms.udev_enumerate_new(_this->udev);
if (enumerate == NULL) {
if (!enumerate) {
SDL_SetError("udev_enumerate_new() failed");
return SDL_FALSE;
}
@ -244,7 +244,7 @@ SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16
for (item = devs; item && !found; item = _this->syms.udev_list_entry_get_next(item)) {
const char *path = _this->syms.udev_list_entry_get_name(item);
struct udev_device *dev = _this->syms.udev_device_new_from_syspath(_this->udev, path);
if (dev != NULL) {
if (dev) {
const char *val = NULL;
const char *existing_path;
@ -253,17 +253,17 @@ SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16
found = SDL_TRUE;
val = _this->syms.udev_device_get_property_value(dev, "ID_VENDOR_ID");
if (val != NULL) {
if (val) {
*vendor = (Uint16)SDL_strtol(val, NULL, 16);
}
val = _this->syms.udev_device_get_property_value(dev, "ID_MODEL_ID");
if (val != NULL) {
if (val) {
*product = (Uint16)SDL_strtol(val, NULL, 16);
}
val = _this->syms.udev_device_get_property_value(dev, "ID_REVISION");
if (val != NULL) {
if (val) {
*version = (Uint16)SDL_strtol(val, NULL, 16);
}
}
@ -277,11 +277,11 @@ SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16
void SDL_UDEV_UnloadLibrary(void)
{
if (_this == NULL) {
if (!_this) {
return;
}
if (_this->udev_handle != NULL) {
if (_this->udev_handle) {
SDL_UnloadObject(_this->udev_handle);
_this->udev_handle = NULL;
}
@ -291,7 +291,7 @@ int SDL_UDEV_LoadLibrary(void)
{
int retval = 0, i;
if (_this == NULL) {
if (!_this) {
return SDL_SetError("UDEV not initialized");
}
@ -302,9 +302,9 @@ int SDL_UDEV_LoadLibrary(void)
#ifdef SDL_UDEV_DYNAMIC
/* Check for the build environment's libudev first */
if (_this->udev_handle == NULL) {
if (!_this->udev_handle) {
_this->udev_handle = SDL_LoadObject(SDL_UDEV_DYNAMIC);
if (_this->udev_handle != NULL) {
if (_this->udev_handle) {
retval = SDL_UDEV_load_syms();
if (retval < 0) {
SDL_UDEV_UnloadLibrary();
@ -313,10 +313,10 @@ int SDL_UDEV_LoadLibrary(void)
}
#endif
if (_this->udev_handle == NULL) {
if (!_this->udev_handle) {
for (i = 0; i < SDL_arraysize(SDL_UDEV_LIBS); i++) {
_this->udev_handle = SDL_LoadObject(SDL_UDEV_LIBS[i]);
if (_this->udev_handle != NULL) {
if (_this->udev_handle) {
retval = SDL_UDEV_load_syms();
if (retval < 0) {
SDL_UDEV_UnloadLibrary();
@ -326,7 +326,7 @@ int SDL_UDEV_LoadLibrary(void)
}
}
if (_this->udev_handle == NULL) {
if (!_this->udev_handle) {
retval = -1;
/* Don't call SDL_SetError(): SDL_LoadObject already did. */
}
@ -345,7 +345,7 @@ static void get_caps(struct udev_device *dev, struct udev_device *pdev, const ch
SDL_memset(bitmask, 0, bitmask_len * sizeof(*bitmask));
value = _this->syms.udev_device_get_sysattr_value(pdev, attr);
if (value == NULL) {
if (!value) {
return;
}
@ -379,7 +379,7 @@ static int guess_device_class(struct udev_device *dev)
while (pdev && !_this->syms.udev_device_get_sysattr_value(pdev, "capabilities/ev")) {
pdev = _this->syms.udev_device_get_parent_with_subsystem_devtype(pdev, "input", NULL);
}
if (pdev == NULL) {
if (!pdev) {
return 0;
}
@ -403,7 +403,7 @@ static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev)
SDL_UDEV_CallbackList *item;
path = _this->syms.udev_device_get_devnode(dev);
if (path == NULL) {
if (!path) {
return;
}
@ -414,23 +414,23 @@ static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev)
/* udev rules reference: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c */
val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_JOYSTICK");
if (val != NULL && SDL_strcmp(val, "1") == 0) {
if (val && SDL_strcmp(val, "1") == 0) {
devclass |= SDL_UDEV_DEVICE_JOYSTICK;
}
val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_ACCELEROMETER");
if (SDL_GetHintBoolean(SDL_HINT_ACCELEROMETER_AS_JOYSTICK, SDL_TRUE) &&
val != NULL && SDL_strcmp(val, "1") == 0) {
val && SDL_strcmp(val, "1") == 0) {
devclass |= SDL_UDEV_DEVICE_JOYSTICK;
}
val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_MOUSE");
if (val != NULL && SDL_strcmp(val, "1") == 0) {
if (val && SDL_strcmp(val, "1") == 0) {
devclass |= SDL_UDEV_DEVICE_MOUSE;
}
val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_TOUCHSCREEN");
if (val != NULL && SDL_strcmp(val, "1") == 0) {
if (val && SDL_strcmp(val, "1") == 0) {
devclass |= SDL_UDEV_DEVICE_TOUCHSCREEN;
}
@ -441,14 +441,14 @@ static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev)
Ref: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c#n183
*/
val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_KEY");
if (val != NULL && SDL_strcmp(val, "1") == 0) {
if (val && SDL_strcmp(val, "1") == 0) {
devclass |= SDL_UDEV_DEVICE_KEYBOARD;
}
if (devclass == 0) {
/* Fall back to old style input classes */
val = _this->syms.udev_device_get_property_value(dev, "ID_CLASS");
if (val != NULL) {
if (val) {
if (SDL_strcmp(val, "joystick") == 0) {
devclass = SDL_UDEV_DEVICE_JOYSTICK;
} else if (SDL_strcmp(val, "mouse") == 0) {
@ -468,7 +468,7 @@ static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev)
}
/* Process callbacks */
for (item = _this->first; item != NULL; item = item->next) {
for (item = _this->first; item; item = item->next) {
item->callback(type, devclass, path);
}
}
@ -478,13 +478,13 @@ void SDL_UDEV_Poll(void)
struct udev_device *dev = NULL;
const char *action = NULL;
if (_this == NULL) {
if (!_this) {
return;
}
while (SDL_UDEV_hotplug_update_available()) {
dev = _this->syms.udev_monitor_receive_device(_this->udev_mon);
if (dev == NULL) {
if (!dev) {
break;
}
action = _this->syms.udev_device_get_action(dev);
@ -505,13 +505,13 @@ int SDL_UDEV_AddCallback(SDL_UDEV_Callback cb)
{
SDL_UDEV_CallbackList *item;
item = (SDL_UDEV_CallbackList *)SDL_calloc(1, sizeof(SDL_UDEV_CallbackList));
if (item == NULL) {
if (!item) {
return SDL_OutOfMemory();
}
item->callback = cb;
if (_this->last == NULL) {
if (!_this->last) {
_this->first = _this->last = item;
} else {
_this->last->next = item;
@ -526,14 +526,14 @@ void SDL_UDEV_DelCallback(SDL_UDEV_Callback cb)
SDL_UDEV_CallbackList *item;
SDL_UDEV_CallbackList *prev = NULL;
if (_this == NULL) {
if (!_this) {
return;
}
for (item = _this->first; item != NULL; item = item->next) {
for (item = _this->first; item; item = item->next) {
/* found it, remove it. */
if (item->callback == cb) {
if (prev != NULL) {
if (prev) {
prev->next = item->next;
} else {
SDL_assert(_this->first == item);

View file

@ -423,7 +423,7 @@ static SDL_WSCONS_input_data *SDL_WSCONS_Init_Keyboard(const char *dev)
#endif
SDL_WSCONS_input_data *input = (SDL_WSCONS_input_data *)SDL_calloc(1, sizeof(SDL_WSCONS_input_data));
if (input == NULL) {
if (!input) {
return input;
}
input->fd = open(dev, O_RDWR | O_NONBLOCK | O_CLOEXEC);
@ -433,7 +433,7 @@ static SDL_WSCONS_input_data *SDL_WSCONS_Init_Keyboard(const char *dev)
return NULL;
}
input->keymap.map = SDL_calloc(sizeof(struct wscons_keymap), KS_NUMKEYCODES);
if (input->keymap.map == NULL) {
if (!input->keymap.map) {
free(input);
return NULL;
}
@ -583,7 +583,7 @@ static void updateKeyboard(SDL_WSCONS_input_data *input)
keysym_t *group;
keysym_t ksym, result;
if (input == NULL) {
if (!input) {
return;
}
if ((n = read(input->fd, events, sizeof(events))) > 0) {
@ -927,7 +927,7 @@ void SDL_WSCONS_PumpEvents()
for (i = 0; i < 4; i++) {
updateKeyboard(inputs[i]);
}
if (mouseInputData != NULL) {
if (mouseInputData) {
updateMouse(mouseInputData);
}
}

View file

@ -42,7 +42,7 @@ SDL_WSCONS_mouse_input_data *SDL_WSCONS_Init_Mouse()
#endif
SDL_WSCONS_mouse_input_data *mouseInputData = SDL_calloc(1, sizeof(SDL_WSCONS_mouse_input_data));
if (mouseInputData == NULL) {
if (!mouseInputData) {
return NULL;
}
mouseInputData->fd = open("/dev/wsmouse", O_RDWR | O_NONBLOCK | O_CLOEXEC);
@ -126,7 +126,7 @@ void updateMouse(SDL_WSCONS_mouse_input_data *inputData)
void SDL_WSCONS_Quit_Mouse(SDL_WSCONS_mouse_input_data *inputData)
{
if (inputData == NULL) {
if (!inputData) {
return;
}
close(inputData->fd);

View file

@ -357,7 +357,7 @@ unsigned long os2cpFromName(char *cp)
PCHAR pcEnd;
CHAR acBuf[64];
if (cp == NULL) {
if (!cp) {
ULONG aulCP[3];
ULONG cCP;
return (DosQueryCp(sizeof(aulCP), aulCP, &cCP) != NO_ERROR)? 0 : aulCP[0];
@ -368,7 +368,7 @@ unsigned long os2cpFromName(char *cp)
}
pcEnd = SDL_strchr(cp, ' ');
if (pcEnd == NULL) {
if (!pcEnd) {
pcEnd = SDL_strchr(cp, '\0');
}
ulNext = pcEnd - cp;

View file

@ -76,7 +76,7 @@ static int _createUconvObj(const char *code, UconvObject *uobj)
const unsigned char *ch =
(const unsigned char *)code;
if (code == NULL)
if (!code)
uc_code[0] = 0;
else {
for (i = 0; i < MAX_CP_NAME_LEN; i++) {
@ -119,10 +119,10 @@ iconv_t _System os2_iconv_open(const char* tocode, const char* fromcode)
int rc;
iuconv_obj *iuobj;
if (tocode == NULL) {
if (!tocode) {
tocode = "";
}
if (fromcode == NULL) {
if (!fromcode) {
fromcode = "";
}
@ -169,7 +169,7 @@ size_t _System os2_iconv(iconv_t cd,
int rc;
size_t ret = (size_t)(-1);
if (uo_tocode == NULL && uo_fromcode == NULL) {
if (!uo_tocode && !uo_fromcode) {
uc_buf_len = SDL_min(*inbytesleft, *outbytesleft);
SDL_memcpy(*outbuf, *inbuf, uc_buf_len);
*inbytesleft -= uc_buf_len;

View file

@ -95,7 +95,7 @@ char *StrUTF8New(int to_utf8, char *str, int c_str)
int c_newstr = (((c_str > 4) ? c_str : 4) + 1) * 2;
char * newstr = (char *) SDL_malloc(c_newstr);
if (newstr == NULL) {
if (!newstr) {
return NULL;
}

View file

@ -58,9 +58,9 @@ int WIN_LoadHIDDLL(void)
SDL_HidP_GetValueCaps = (HidP_GetValueCaps_t)GetProcAddress(s_pHIDDLL, "HidP_GetValueCaps");
SDL_HidP_MaxDataListLength = (HidP_MaxDataListLength_t)GetProcAddress(s_pHIDDLL, "HidP_MaxDataListLength");
SDL_HidP_GetData = (HidP_GetData_t)GetProcAddress(s_pHIDDLL, "HidP_GetData");
if (SDL_HidD_GetManufacturerString == NULL || SDL_HidD_GetProductString == NULL ||
SDL_HidP_GetCaps == NULL || SDL_HidP_GetButtonCaps == NULL ||
SDL_HidP_GetValueCaps == NULL || SDL_HidP_MaxDataListLength == NULL || SDL_HidP_GetData == NULL) {
if (!SDL_HidD_GetManufacturerString || !SDL_HidD_GetProductString ||
!SDL_HidP_GetCaps || !SDL_HidP_GetButtonCaps ||
!SDL_HidP_GetValueCaps || !SDL_HidP_MaxDataListLength || !SDL_HidP_GetData) {
WIN_UnloadHIDDLL();
return -1;
}

View file

@ -136,7 +136,7 @@ static void SDL_IMMDevice_Add(const SDL_bool iscapture, const char *devname, WAV
}
devidlist = (DevIdList *)SDL_malloc(sizeof(*devidlist));
if (devidlist == NULL) {
if (!devidlist) {
return; /* oh well. */
}
@ -361,10 +361,10 @@ int SDL_IMMDevice_Get(LPCWSTR devid, IMMDevice **device, SDL_bool iscapture)
const Uint64 timeout = SDL_GetTicks64() + 8000; /* intel's audio drivers can fail for up to EIGHT SECONDS after a device is connected or we wake from sleep. */
HRESULT ret;
SDL_assert(device != NULL);
SDL_assert(device);
while (SDL_TRUE) {
if (devid == NULL) {
if (!devid) {
const EDataFlow dataflow = iscapture ? eCapture : eRender;
ret = IMMDeviceEnumerator_GetDefaultAudioEndpoint(enumerator, dataflow, SDL_IMMDevice_role, device);
} else {
@ -443,7 +443,7 @@ static void EnumerateEndpointsForFlow(const SDL_bool iscapture)
}
items = (EndpointItem *)SDL_calloc(total, sizeof(EndpointItem));
if (items == NULL) {
if (!items) {
return; /* oh well. */
}
@ -496,11 +496,11 @@ int SDL_IMMDevice_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int isca
HRESULT ret = IMMDeviceEnumerator_GetDefaultAudioEndpoint(enumerator, dataflow, SDL_IMMDevice_role, &device);
if (FAILED(ret)) {
SDL_assert(device == NULL);
SDL_assert(!device);
return WIN_SetErrorFromHRESULT("WASAPI can't find default audio endpoint", ret);
}
if (name == NULL) {
if (!name) {
name = &filler;
}

View file

@ -285,7 +285,7 @@ char *WIN_LookupAudioDeviceName(const WCHAR *name, const GUID *guid)
}
strw = (WCHAR *)SDL_malloc(len + sizeof(WCHAR));
if (strw == NULL) {
if (!strw) {
RegCloseKey(hkey);
return WIN_StringToUTF8(name); /* oh well. */
}

View file

@ -106,13 +106,13 @@ int WIN_LoadXInputDLL(void)
/* 100 is the ordinal for _XInputGetStateEx, which returns the same struct as XinputGetState, but with extra data in wButtons for the guide button, we think... */
SDL_XInputGetState = (XInputGetState_t)GetProcAddress(s_pXInputDLL, (LPCSTR)100);
if (SDL_XInputGetState == NULL) {
if (!SDL_XInputGetState) {
SDL_XInputGetState = (XInputGetState_t)GetProcAddress(s_pXInputDLL, "XInputGetState");
}
SDL_XInputSetState = (XInputSetState_t)GetProcAddress(s_pXInputDLL, "XInputSetState");
SDL_XInputGetCapabilities = (XInputGetCapabilities_t)GetProcAddress(s_pXInputDLL, "XInputGetCapabilities");
SDL_XInputGetBatteryInformation = (XInputGetBatteryInformation_t)GetProcAddress(s_pXInputDLL, "XInputGetBatteryInformation");
if (SDL_XInputGetState == NULL || SDL_XInputSetState == NULL || SDL_XInputGetCapabilities == NULL) {
if (!SDL_XInputGetState || !SDL_XInputSetState || !SDL_XInputGetCapabilities) {
WIN_UnloadXInputDLL();
return -1;
}

View file

@ -348,7 +348,7 @@ void SDL_WinRTApp::Run()
// representation of command line arguments.
int argc = 1;
char **argv = (char **)SDL_malloc(2 * sizeof(*argv));
if (argv == NULL) {
if (!argv) {
return;
}
argv[0] = SDL_strdup("WinRTApp");

View file

@ -1198,7 +1198,7 @@ void *SDL_SIMDRealloc(void *mem, const size_t len)
ptr = (Uint8 *)SDL_realloc(mem, to_allocate);
if (ptr == NULL) {
if (!ptr) {
return NULL; /* Out of memory, bail! */
}

View file

@ -372,7 +372,7 @@ static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym)
void *retval = NULL;
if (lib) {
retval = (void *) GetProcAddress(lib, sym);
if (retval == NULL) {
if (!retval) {
FreeLibrary(lib);
}
}
@ -385,9 +385,9 @@ static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym)
{
void *lib = dlopen(fname, RTLD_NOW | RTLD_LOCAL);
void *retval = NULL;
if (lib != NULL) {
if (lib) {
retval = dlsym(lib, sym);
if (retval == NULL) {
if (!retval) {
dlclose(lib);
}
}

View file

@ -29,7 +29,7 @@ int SDL_SendDisplayEvent(SDL_VideoDisplay *display, Uint8 displayevent, int data
{
int posted;
if (display == NULL) {
if (!display) {
return 0;
}
switch (displayevent) {

View file

@ -129,7 +129,7 @@ static unsigned long SDL_HashDollar(SDL_FloatPoint *points)
static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops *dst)
{
if (dst == NULL) {
if (!dst) {
return 0;
}
@ -200,7 +200,7 @@ static int SDL_AddDollarGesture_one(SDL_GestureTouch *inTouch, SDL_FloatPoint *p
(SDL_DollarTemplate *)SDL_realloc(inTouch->dollarTemplate,
(index + 1) *
sizeof(SDL_DollarTemplate));
if (dollarTemplate == NULL) {
if (!dollarTemplate) {
return SDL_OutOfMemory();
}
inTouch->dollarTemplate = dollarTemplate;
@ -217,7 +217,7 @@ static int SDL_AddDollarGesture(SDL_GestureTouch *inTouch, SDL_FloatPoint *path)
{
int index = -1;
int i = 0;
if (inTouch == NULL) {
if (!inTouch) {
if (SDL_numGestureTouches == 0) {
return SDL_SetError("no gesture touch devices registered");
}
@ -238,7 +238,7 @@ int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src)
{
int i, loaded = 0;
SDL_GestureTouch *touch = NULL;
if (src == NULL) {
if (!src) {
return 0;
}
if (touchId >= 0) {
@ -247,7 +247,7 @@ int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src)
touch = &SDL_gestureTouch[i];
}
}
if (touch == NULL) {
if (!touch) {
return SDL_SetError("given touch id not found");
}
}
@ -475,7 +475,7 @@ int SDL_GestureAddTouch(SDL_TouchID touchId)
(SDL_numGestureTouches + 1) *
sizeof(SDL_GestureTouch));
if (gestureTouch == NULL) {
if (!gestureTouch) {
return SDL_OutOfMemory();
}
@ -589,7 +589,7 @@ void SDL_GestureProcessEvent(SDL_Event *event)
SDL_GestureTouch *inTouch = SDL_GetGestureTouch(event->tfinger.touchId);
/* Shouldn't be possible */
if (inTouch == NULL) {
if (!inTouch) {
return;
}

View file

@ -768,7 +768,7 @@ void SDL_SetKeyboardFocus(SDL_Window *window)
{
SDL_Keyboard *keyboard = &SDL_keyboard;
if (keyboard->focus && window == NULL) {
if (keyboard->focus && !window) {
/* We won't get anymore keyboard messages, so reset keyboard state */
SDL_ResetKeyboard();
}
@ -777,7 +777,7 @@ void SDL_SetKeyboardFocus(SDL_Window *window)
if (keyboard->focus && keyboard->focus != window) {
/* new window shouldn't think it has mouse captured. */
SDL_assert(window == NULL || !(window->flags & SDL_WINDOW_MOUSE_CAPTURE));
SDL_assert(!window || !(window->flags & SDL_WINDOW_MOUSE_CAPTURE));
/* old window must lose an existing mouse capture. */
if (keyboard->focus->flags & SDL_WINDOW_MOUSE_CAPTURE) {
@ -1183,7 +1183,7 @@ const char *SDL_GetScancodeName(SDL_Scancode scancode)
}
name = SDL_scancode_names[scancode];
if (name != NULL) {
if (name) {
return name;
}
@ -1194,7 +1194,7 @@ SDL_Scancode SDL_GetScancodeFromName(const char *name)
{
int i;
if (name == NULL || !*name) {
if (!name || !*name) {
SDL_InvalidParamError("name");
return SDL_SCANCODE_UNKNOWN;
}
@ -1254,7 +1254,7 @@ SDL_Keycode SDL_GetKeyFromName(const char *name)
SDL_Keycode key;
/* Check input */
if (name == NULL) {
if (!name) {
return SDLK_UNKNOWN;
}

View file

@ -491,7 +491,7 @@ int SDL_SetMouseSystemScale(int num_values, const float *values)
}
v = (float *)SDL_realloc(mouse->system_scale_values, num_values * sizeof(*values));
if (v == NULL) {
if (!v) {
return SDL_OutOfMemory();
}
SDL_memcpy(v, values, num_values * sizeof(*values));
@ -712,7 +712,7 @@ static SDL_MouseClickState *GetMouseClickState(SDL_Mouse *mouse, Uint8 button)
if (button >= mouse->num_clickstates) {
int i, count = button + 1;
SDL_MouseClickState *clickstate = (SDL_MouseClickState *)SDL_realloc(mouse->clickstate, count * sizeof(*mouse->clickstate));
if (clickstate == NULL) {
if (!clickstate) {
return NULL;
}
mouse->clickstate = clickstate;
@ -734,7 +734,7 @@ static int SDL_PrivateSendMouseButton(SDL_Window *window, SDL_MouseID mouseID, U
SDL_MouseInputSource *source;
source = GetMouseInputSource(mouse, mouseID);
if (source == NULL) {
if (!source) {
return 0;
}
buttonstate = source->buttonstate;
@ -1030,10 +1030,10 @@ Uint32 SDL_GetGlobalMouseState(int *x, int *y)
int tmpx, tmpy;
/* make sure these are never NULL for the backend implementations... */
if (x == NULL) {
if (!x) {
x = &tmpx;
}
if (y == NULL) {
if (!y) {
y = &tmpy;
}
@ -1049,11 +1049,11 @@ void SDL_PerformWarpMouseInWindow(SDL_Window *window, int x, int y, SDL_bool ign
{
SDL_Mouse *mouse = SDL_GetMouse();
if (window == NULL) {
if (!window) {
window = mouse->focus;
}
if (window == NULL) {
if (!window) {
return;
}
@ -1284,7 +1284,7 @@ SDL_Cursor *SDL_CreateCursor(const Uint8 *data, const Uint8 *mask,
0x0000FF00,
0x000000FF,
0xFF000000);
if (surface == NULL) {
if (!surface) {
return NULL;
}
for (y = 0; y < h; ++y) {
@ -1317,7 +1317,7 @@ SDL_Cursor *SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y)
SDL_Surface *temp = NULL;
SDL_Cursor *cursor;
if (surface == NULL) {
if (!surface) {
SDL_InvalidParamError("surface");
return NULL;
}
@ -1331,7 +1331,7 @@ SDL_Cursor *SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y)
if (surface->format->format != SDL_PIXELFORMAT_ARGB8888) {
temp = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888, 0);
if (temp == NULL) {
if (!temp) {
return NULL;
}
surface = temp;
@ -1398,7 +1398,7 @@ void SDL_SetCursor(SDL_Cursor *cursor)
break;
}
}
if (found == NULL) {
if (!found) {
SDL_SetError("Cursor not associated with the current mouse");
return;
}
@ -1427,7 +1427,7 @@ SDL_Cursor *SDL_GetCursor(void)
{
SDL_Mouse *mouse = SDL_GetMouse();
if (mouse == NULL) {
if (!mouse) {
return NULL;
}
return mouse->cur_cursor;
@ -1437,7 +1437,7 @@ SDL_Cursor *SDL_GetDefaultCursor(void)
{
SDL_Mouse *mouse = SDL_GetMouse();
if (mouse == NULL) {
if (!mouse) {
return NULL;
}
return mouse->def_cursor;
@ -1448,7 +1448,7 @@ void SDL_FreeCursor(SDL_Cursor *cursor)
SDL_Mouse *mouse = SDL_GetMouse();
SDL_Cursor *curr, *prev;
if (cursor == NULL) {
if (!cursor) {
return;
}
@ -1483,7 +1483,7 @@ int SDL_ShowCursor(int toggle)
SDL_Mouse *mouse = SDL_GetMouse();
SDL_bool shown;
if (mouse == NULL) {
if (!mouse) {
return 0;
}

View file

@ -138,7 +138,7 @@ int SDL_GetNumTouchFingers(SDL_TouchID touchID)
SDL_Finger *SDL_GetTouchFinger(SDL_TouchID touchID, int index)
{
SDL_Touch *touch = SDL_GetTouch(touchID);
if (touch == NULL) {
if (!touch) {
return NULL;
}
if (index < 0 || index >= touch->num_fingers) {
@ -161,7 +161,7 @@ int SDL_AddTouch(SDL_TouchID touchID, SDL_TouchDeviceType type, const char *name
/* Add the touch to the list of touch */
touchDevices = (SDL_Touch **)SDL_realloc(SDL_touchDevices,
(SDL_num_touch + 1) * sizeof(*touchDevices));
if (touchDevices == NULL) {
if (!touchDevices) {
return SDL_OutOfMemory();
}
@ -198,7 +198,7 @@ static int SDL_AddFinger(SDL_Touch *touch, SDL_FingerID fingerid, float x, float
if (touch->num_fingers == touch->max_fingers) {
SDL_Finger **new_fingers;
new_fingers = (SDL_Finger **)SDL_realloc(touch->fingers, (touch->max_fingers + 1) * sizeof(*touch->fingers));
if (new_fingers == NULL) {
if (!new_fingers) {
return SDL_OutOfMemory();
}
touch->fingers = new_fingers;
@ -241,7 +241,7 @@ int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window,
SDL_Mouse *mouse;
SDL_Touch *touch = SDL_GetTouch(id);
if (touch == NULL) {
if (!touch) {
return -1;
}
@ -334,7 +334,7 @@ int SDL_SendTouch(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *window,
posted = (SDL_PushEvent(&event) > 0);
}
} else {
if (finger == NULL) {
if (!finger) {
/* This finger is already up */
return 0;
}
@ -370,7 +370,7 @@ int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *windo
float xrel, yrel, prel;
touch = SDL_GetTouch(id);
if (touch == NULL) {
if (!touch) {
return -1;
}
@ -413,7 +413,7 @@ int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *windo
}
finger = SDL_GetFinger(touch, fingerid);
if (finger == NULL) {
if (!finger) {
return SDL_SendTouch(id, fingerid, window, SDL_TRUE, x, y, pressure);
}
@ -464,7 +464,7 @@ void SDL_DelTouch(SDL_TouchID id)
index = SDL_GetTouchIndex(id);
touch = SDL_GetTouch(id);
if (touch == NULL) {
if (!touch) {
return;
}

View file

@ -84,7 +84,7 @@ int SDL_SendWindowEvent(SDL_Window *window, Uint8 windowevent, int data1,
{
int posted;
if (window == NULL) {
if (!window) {
return 0;
}
switch (windowevent) {

View file

@ -86,7 +86,7 @@ static int SDLCALL windows_file_open(SDL_RWops *context, const char *filename, c
DWORD must_exist, truncate;
int a_mode;
if (context == NULL) {
if (!context) {
return -1; /* failed (invalid call) */
}
@ -154,7 +154,7 @@ static Sint64 SDLCALL windows_file_size(SDL_RWops *context)
{
LARGE_INTEGER size;
if (context == NULL || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) {
if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) {
return SDL_SetError("windows_file_size: invalid context/file not opened");
}
@ -170,7 +170,7 @@ static Sint64 SDLCALL windows_file_seek(SDL_RWops *context, Sint64 offset, int w
DWORD windowswhence;
LARGE_INTEGER windowsoffset;
if (context == NULL || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) {
if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) {
return SDL_SetError("windows_file_seek: invalid context/file not opened");
}
@ -211,7 +211,7 @@ windows_file_read(SDL_RWops *context, void *ptr, size_t size, size_t maxnum)
total_need = size * maxnum;
if (context == NULL || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !total_need) {
if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !total_need) {
return 0;
}
@ -264,7 +264,7 @@ windows_file_write(SDL_RWops *context, const void *ptr, size_t size,
total_bytes = size * num;
if (context == NULL || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !size || !total_bytes) {
if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !size || !total_bytes) {
return 0;
}
@ -526,7 +526,7 @@ static int SDLCALL mem_close(SDL_RWops *context)
SDL_RWops *SDL_RWFromFile(const char *file, const char *mode)
{
SDL_RWops *rwops = NULL;
if (file == NULL || !*file || mode == NULL || !*mode) {
if (!file || !*file || !mode || !*mode) {
SDL_SetError("SDL_RWFromFile(): No file or no mode specified");
return NULL;
}
@ -559,7 +559,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode)
/* Try to open the file from the asset system */
rwops = SDL_AllocRW();
if (rwops == NULL) {
if (!rwops) {
return NULL; /* SDL_SetError already setup by SDL_AllocRW() */
}
@ -576,7 +576,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode)
#elif defined(__WIN32__) || defined(__GDK__)
rwops = SDL_AllocRW();
if (rwops == NULL) {
if (!rwops) {
return NULL; /* SDL_SetError already setup by SDL_AllocRW() */
}
@ -602,7 +602,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode)
#else
FILE *fp = fopen(file, mode);
#endif
if (fp == NULL) {
if (!fp) {
SDL_SetError("Couldn't open %s", file);
} else {
rwops = SDL_RWFromFP(fp, SDL_TRUE);
@ -621,7 +621,7 @@ SDL_RWops *SDL_RWFromFP(FILE * fp, SDL_bool autoclose)
SDL_RWops *rwops = NULL;
rwops = SDL_AllocRW();
if (rwops != NULL) {
if (rwops) {
rwops->size = stdio_size;
rwops->seek = stdio_seek;
rwops->read = stdio_read;
@ -644,7 +644,7 @@ SDL_RWops *SDL_RWFromFP(void * fp, SDL_bool autoclose)
SDL_RWops *SDL_RWFromMem(void *mem, int size)
{
SDL_RWops *rwops = NULL;
if (mem == NULL) {
if (!mem) {
SDL_InvalidParamError("mem");
return rwops;
}
@ -654,7 +654,7 @@ SDL_RWops *SDL_RWFromMem(void *mem, int size)
}
rwops = SDL_AllocRW();
if (rwops != NULL) {
if (rwops) {
rwops->size = mem_size;
rwops->seek = mem_seek;
rwops->read = mem_read;
@ -671,7 +671,7 @@ SDL_RWops *SDL_RWFromMem(void *mem, int size)
SDL_RWops *SDL_RWFromConstMem(const void *mem, int size)
{
SDL_RWops *rwops = NULL;
if (mem == NULL) {
if (!mem) {
SDL_InvalidParamError("mem");
return rwops;
}
@ -681,7 +681,7 @@ SDL_RWops *SDL_RWFromConstMem(const void *mem, int size)
}
rwops = SDL_AllocRW();
if (rwops != NULL) {
if (rwops) {
rwops->size = mem_size;
rwops->seek = mem_seek;
rwops->read = mem_read;
@ -700,7 +700,7 @@ SDL_RWops *SDL_AllocRW(void)
SDL_RWops *area;
area = (SDL_RWops *)SDL_malloc(sizeof(*area));
if (area == NULL) {
if (!area) {
SDL_OutOfMemory();
} else {
area->type = SDL_RWOPS_UNKNOWN;
@ -721,7 +721,7 @@ void *SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, int freesrc)
size_t size_read, size_total;
void *data = NULL, *newdata;
if (src == NULL) {
if (!src) {
SDL_InvalidParamError("src");
return NULL;
}
@ -737,7 +737,7 @@ void *SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, int freesrc)
if ((((Sint64)size_total) + FILE_CHUNK_SIZE) > size) {
size = (size_total + FILE_CHUNK_SIZE);
newdata = SDL_realloc(data, (size_t)(size + 1));
if (newdata == NULL) {
if (!newdata) {
SDL_free(data);
data = NULL;
SDL_OutOfMemory();

View file

@ -66,7 +66,7 @@ static FILE *TryOpenFile(const char *file, const char *mode)
FILE *fp = NULL;
fp = TryOpenInRomfs(file, mode);
if (fp == NULL) {
if (!fp) {
fp = fopen(file, mode);
}

View file

@ -45,7 +45,7 @@ char *SDL_GetPrefPath(const char *org, const char *app)
if (path) {
size_t pathlen = SDL_strlen(path) + 2;
char *fullpath = (char *)SDL_malloc(pathlen);
if (fullpath == NULL) {
if (!fullpath) {
SDL_OutOfMemory();
return NULL;
}

View file

@ -45,17 +45,17 @@ char *SDL_GetPrefPath(const char *org, const char *app)
char *ptr = NULL;
size_t len = 0;
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}
len = SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
retval = (char *)SDL_malloc(len);
if (retval == NULL) {
if (!retval) {
SDL_OutOfMemory();
return NULL;
}

View file

@ -44,7 +44,7 @@ SDL_GetBasePath(void)
while (SDL_TRUE) {
void *ptr = SDL_realloc(path, buflen * sizeof(CHAR));
if (ptr == NULL) {
if (!ptr) {
SDL_free(path);
SDL_OutOfMemory();
return NULL;
@ -90,13 +90,13 @@ SDL_GetPrefPath(const char *org, const char *app)
HRESULT result;
const char *csid = SDL_GetHint("SDL_GDK_SERVICE_CONFIGURATION_ID");
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
/* This should be set before calling SDL_GetPrefPath! */
if (csid == NULL) {
if (!csid) {
SDL_LogWarn(SDL_LOG_CATEGORY_SYSTEM, "Set SDL_GDK_SERVICE_CONFIGURATION_ID before calling SDL_GetPrefPath!");
return SDL_strdup("T:\\");
}

View file

@ -52,11 +52,11 @@ char *SDL_GetBasePath(void)
rc = path.GetParent(&path); /* chop filename, keep directory. */
SDL_assert(rc == B_OK);
const char *str = path.Path();
SDL_assert(str != NULL);
SDL_assert(str);
const size_t len = SDL_strlen(str);
char *retval = (char *) SDL_malloc(len + 2);
if (retval == NULL) {
if (!retval) {
SDL_OutOfMemory();
return NULL;
}
@ -75,11 +75,11 @@ char *SDL_GetPrefPath(const char *org, const char *app)
const char *append = "/config/settings/";
size_t len = SDL_strlen(home);
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}
@ -88,7 +88,7 @@ char *SDL_GetPrefPath(const char *org, const char *app)
}
len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
char *retval = (char *) SDL_malloc(len);
if (retval == NULL) {
if (!retval) {
SDL_OutOfMemory();
} else {
if (*org) {

View file

@ -44,13 +44,13 @@ char *SDL_GetBasePath(void)
char *SDL_GetPrefPath(const char *org, const char *app)
{
char *pref_path = NULL;
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
pref_path = MakePrefPath(app);
if (pref_path == NULL) {
if (!pref_path) {
return NULL;
}

View file

@ -82,11 +82,11 @@ char *SDL_GetPrefPath(const char *org, const char *app)
char *retval = NULL;
size_t len;
char *base = SDL_GetBasePath();
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}

View file

@ -50,11 +50,11 @@ char *SDL_GetPrefPath(const char *org, const char *app)
char *retval = NULL;
size_t len;
char *base = SDL_GetBasePath();
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}

View file

@ -38,21 +38,21 @@ static char *SDL_unixify_std(const char *ro_path, char *buffer, size_t buf_len,
{
const char *const in_buf = buffer; /* = NULL if we allocate the buffer. */
if (buffer == NULL) {
if (!buffer) {
/* This matches the logic in __unixify, with an additional byte for the
* extra path separator.
*/
buf_len = SDL_strlen(ro_path) + 14 + 1;
buffer = SDL_malloc(buf_len);
if (buffer == NULL) {
if (!buffer) {
SDL_OutOfMemory();
return NULL;
}
}
if (!__unixify_std(ro_path, buffer, buf_len, filetype)) {
if (in_buf == NULL) {
if (!in_buf) {
SDL_free(buffer);
}
@ -92,7 +92,7 @@ static char *canonicalisePath(const char *path, const char *pathVar)
regs.r[5] = 1 - regs.r[5];
buf = SDL_malloc(regs.r[5]);
if (buf == NULL) {
if (!buf) {
SDL_OutOfMemory();
return NULL;
}
@ -121,7 +121,7 @@ static _kernel_oserror *createDirectoryRecursive(char *path)
*ptr = '\0';
error = _kernel_swi(OS_File, &regs, &regs);
*ptr = '.';
if (error != NULL) {
if (error) {
return error;
}
}
@ -141,13 +141,13 @@ char *SDL_GetBasePath(void)
}
canon = canonicalisePath((const char *)regs.r[0], "Run$Path");
if (canon == NULL) {
if (!canon) {
return NULL;
}
/* chop off filename. */
ptr = SDL_strrchr(canon, '.');
if (ptr != NULL) {
if (ptr) {
*ptr = '\0';
}
@ -162,22 +162,22 @@ char *SDL_GetPrefPath(const char *org, const char *app)
size_t len;
_kernel_oserror *error;
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}
canon = canonicalisePath("<Choices$Write>", "Run$Path");
if (canon == NULL) {
if (!canon) {
return NULL;
}
len = SDL_strlen(canon) + SDL_strlen(org) + SDL_strlen(app) + 4;
dir = (char *)SDL_malloc(len);
if (dir == NULL) {
if (!dir) {
SDL_OutOfMemory();
SDL_free(canon);
return NULL;
@ -192,7 +192,7 @@ char *SDL_GetPrefPath(const char *org, const char *app)
SDL_free(canon);
error = createDirectoryRecursive(dir);
if (error != NULL) {
if (error) {
SDL_SetError("Couldn't create directory: %s", error->errmess);
SDL_free(dir);
return NULL;

View file

@ -53,7 +53,7 @@ static char *readSymLink(const char *path)
while (1) {
char *ptr = (char *)SDL_realloc(retval, (size_t)len);
if (ptr == NULL) {
if (!ptr) {
SDL_OutOfMemory();
break;
}
@ -86,18 +86,18 @@ static char *search_path_for_binary(const char *bin)
char *start = envr;
char *ptr;
if (envr == NULL) {
if (!envr) {
SDL_SetError("No $PATH set");
return NULL;
}
envr = SDL_strdup(envr);
if (envr == NULL) {
if (!envr) {
SDL_OutOfMemory();
return NULL;
}
SDL_assert(bin != NULL);
SDL_assert(bin);
alloc_size = SDL_strlen(bin) + SDL_strlen(envr) + 2;
exe = (char *)SDL_malloc(alloc_size);
@ -118,7 +118,7 @@ static char *search_path_for_binary(const char *bin)
}
}
start = ptr + 1; /* start points to beginning of next element. */
} while (ptr != NULL);
} while (ptr);
SDL_free(envr);
SDL_free(exe);
@ -138,7 +138,7 @@ char *SDL_GetBasePath(void)
const int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
if (sysctl(mib, SDL_arraysize(mib), fullpath, &buflen, NULL, 0) != -1) {
retval = SDL_strdup(fullpath);
if (retval == NULL) {
if (!retval) {
SDL_OutOfMemory();
return NULL;
}
@ -152,13 +152,13 @@ char *SDL_GetBasePath(void)
if (sysctl(mib, 4, NULL, &len, NULL, 0) != -1) {
char *exe, *pwddst;
char *realpathbuf = (char *)SDL_malloc(PATH_MAX + 1);
if (realpathbuf == NULL) {
if (!realpathbuf) {
SDL_OutOfMemory();
return NULL;
}
cmdline = SDL_malloc(len);
if (cmdline == NULL) {
if (!cmdline) {
SDL_free(realpathbuf);
SDL_OutOfMemory();
return NULL;
@ -180,7 +180,7 @@ char *SDL_GetBasePath(void)
}
if (exe) {
if (pwddst == NULL) {
if (!pwddst) {
if (realpath(exe, realpathbuf) != NULL) {
retval = realpathbuf;
}
@ -196,7 +196,7 @@ char *SDL_GetBasePath(void)
}
}
if (retval == NULL) {
if (!retval) {
SDL_free(realpathbuf);
}
@ -205,7 +205,7 @@ char *SDL_GetBasePath(void)
#endif
/* is a Linux-style /proc filesystem available? */
if (retval == NULL && (access("/proc", F_OK) == 0)) {
if (!retval && (access("/proc", F_OK) == 0)) {
/* !!! FIXME: after 2.0.6 ships, let's delete this code and just
use the /proc/%llu version. There's no reason to have
two copies of this plus all the #ifdefs. --ryan. */
@ -219,7 +219,7 @@ char *SDL_GetBasePath(void)
retval = SDL_LoadFile("/proc/self/exefile", NULL);
#else
retval = readSymLink("/proc/self/exe"); /* linux. */
if (retval == NULL) {
if (!retval) {
/* older kernels don't have /proc/self ... try PID version... */
char path[64];
const int rc = SDL_snprintf(path, sizeof(path),
@ -248,9 +248,9 @@ char *SDL_GetBasePath(void)
/* If we had access to argv[0] here, we could check it for a path,
or troll through $PATH looking for it, too. */
if (retval != NULL) { /* chop off filename. */
if (retval) { /* chop off filename. */
char *ptr = SDL_strrchr(retval, '/');
if (ptr != NULL) {
if (ptr) {
*(ptr + 1) = '\0';
} else { /* shouldn't happen, but just in case... */
SDL_free(retval);
@ -258,10 +258,10 @@ char *SDL_GetBasePath(void)
}
}
if (retval != NULL) {
if (retval) {
/* try to shrink buffer... */
char *ptr = (char *)SDL_realloc(retval, SDL_strlen(retval) + 1);
if (ptr != NULL) {
if (ptr) {
retval = ptr; /* oh well if it failed. */
}
}
@ -284,18 +284,18 @@ char *SDL_GetPrefPath(const char *org, const char *app)
char *ptr = NULL;
size_t len = 0;
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}
if (envr == NULL) {
if (!envr) {
/* You end up with "$HOME/.local/share/Game Name 2" */
envr = SDL_getenv("HOME");
if (envr == NULL) {
if (!envr) {
/* we could take heroic measures with /etc/passwd, but oh well. */
SDL_SetError("neither XDG_DATA_HOME nor HOME environment is set");
return NULL;
@ -312,7 +312,7 @@ char *SDL_GetPrefPath(const char *org, const char *app)
len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
retval = (char *)SDL_malloc(len);
if (retval == NULL) {
if (!retval) {
SDL_OutOfMemory();
return NULL;
}

View file

@ -53,11 +53,11 @@ char *SDL_GetPrefPath(const char *org, const char *app)
char *ptr = NULL;
size_t len = 0;
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}
@ -65,7 +65,7 @@ char *SDL_GetPrefPath(const char *org, const char *app)
len += SDL_strlen(org) + SDL_strlen(app) + 3;
retval = (char *)SDL_malloc(len);
if (retval == NULL) {
if (!retval) {
SDL_OutOfMemory();
return NULL;
}

View file

@ -42,7 +42,7 @@ char *SDL_GetBasePath(void)
while (SDL_TRUE) {
void *ptr = SDL_realloc(path, buflen * sizeof(WCHAR));
if (ptr == NULL) {
if (!ptr) {
SDL_free(path);
SDL_OutOfMemory();
return NULL;
@ -99,11 +99,11 @@ char *SDL_GetPrefPath(const char *org, const char *app)
size_t new_wpath_len = 0;
BOOL api_result = FALSE;
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}
@ -113,13 +113,13 @@ char *SDL_GetPrefPath(const char *org, const char *app)
}
worg = WIN_UTF8ToStringW(org);
if (worg == NULL) {
if (!worg) {
SDL_OutOfMemory();
return NULL;
}
wapp = WIN_UTF8ToStringW(app);
if (wapp == NULL) {
if (!wapp) {
SDL_free(worg);
SDL_OutOfMemory();
return NULL;

View file

@ -111,7 +111,7 @@ SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType)
}
const wchar_t *ucs2Path = SDL_WinRTGetFSPathUNICODE(pathType);
if (ucs2Path == NULL) {
if (!ucs2Path) {
return NULL;
}
@ -128,14 +128,14 @@ SDL_GetBasePath(void)
size_t destPathLen;
char *destPath = NULL;
if (srcPath == NULL) {
if (!srcPath) {
SDL_SetError("Couldn't locate our basepath: %s", SDL_GetError());
return NULL;
}
destPathLen = SDL_strlen(srcPath) + 2;
destPath = (char *)SDL_malloc(destPathLen);
if (destPath == NULL) {
if (!destPath) {
SDL_OutOfMemory();
return NULL;
}
@ -161,16 +161,16 @@ SDL_GetPrefPath(const char *org, const char *app)
size_t new_wpath_len = 0;
BOOL api_result = FALSE;
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}
srcPath = SDL_WinRTGetFSPathUNICODE(SDL_WINRT_PATH_LOCAL_FOLDER);
if (srcPath == NULL) {
if (!srcPath) {
SDL_SetError("Unable to find a source path");
return NULL;
}
@ -182,13 +182,13 @@ SDL_GetPrefPath(const char *org, const char *app)
SDL_wcslcpy(path, srcPath, SDL_arraysize(path));
worg = WIN_UTF8ToString(org);
if (worg == NULL) {
if (!worg) {
SDL_OutOfMemory();
return NULL;
}
wapp = WIN_UTF8ToString(app);
if (wapp == NULL) {
if (!wapp) {
SDL_free(worg);
SDL_OutOfMemory();
return NULL;

View file

@ -55,7 +55,7 @@ static int ValidHaptic(SDL_Haptic *haptic)
SDL_Haptic *hapticlist;
valid = 0;
if (haptic != NULL) {
if (haptic) {
hapticlist = SDL_haptics;
while (hapticlist) {
if (hapticlist == haptic) {
@ -124,7 +124,7 @@ SDL_Haptic *SDL_HapticOpen(int device_index)
/* Create the haptic device */
haptic = (SDL_Haptic *)SDL_malloc(sizeof(*haptic));
if (haptic == NULL) {
if (!haptic) {
SDL_OutOfMemory();
return NULL;
}
@ -296,7 +296,7 @@ SDL_Haptic *SDL_HapticOpenFromJoystick(SDL_Joystick *joystick)
/* Create the haptic device */
haptic = (SDL_Haptic *)SDL_malloc(sizeof(*haptic));
if (haptic == NULL) {
if (!haptic) {
SDL_OutOfMemory();
SDL_UnlockJoysticks();
return NULL;
@ -609,7 +609,7 @@ int SDL_HapticSetGain(SDL_Haptic *haptic, int gain)
/* We use the envvar to get the maximum gain. */
env = SDL_getenv("SDL_HAPTIC_GAIN_MAX");
if (env != NULL) {
if (env) {
max_gain = SDL_atoi(env);
/* Check for sanity. */

View file

@ -70,7 +70,7 @@ static SDL_hapticlist_item *HapticByOrder(int index)
return NULL;
}
while (index > 0) {
SDL_assert(item != NULL);
SDL_assert(item);
--index;
item = item->next;
}
@ -80,7 +80,7 @@ static SDL_hapticlist_item *HapticByOrder(int index)
static SDL_hapticlist_item *HapticByDevId(int device_id)
{
SDL_hapticlist_item *item;
for (item = SDL_hapticlist; item != NULL; item = item->next) {
for (item = SDL_hapticlist; item; item = item->next) {
if (device_id == item->device_id) {
/*SDL_Log("=+=+=+=+=+= HapticByDevId id [%d]", device_id);*/
return item;
@ -92,7 +92,7 @@ static SDL_hapticlist_item *HapticByDevId(int device_id)
const char *SDL_SYS_HapticName(int index)
{
SDL_hapticlist_item *item = HapticByOrder(index);
if (item == NULL) {
if (!item) {
SDL_SetError("No such device");
return NULL;
}
@ -101,11 +101,11 @@ const char *SDL_SYS_HapticName(int index)
static SDL_hapticlist_item *OpenHaptic(SDL_Haptic *haptic, SDL_hapticlist_item *item)
{
if (item == NULL) {
if (!item) {
SDL_SetError("No such device");
return NULL;
}
if (item->haptic != NULL) {
if (item->haptic) {
SDL_SetError("Haptic already opened");
return NULL;
}
@ -117,7 +117,7 @@ static SDL_hapticlist_item *OpenHaptic(SDL_Haptic *haptic, SDL_hapticlist_item *
haptic->neffects = 1;
haptic->nplaying = haptic->neffects;
haptic->effects = (struct haptic_effect *)SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
if (haptic->effects == NULL) {
if (!haptic->effects) {
SDL_OutOfMemory();
return NULL;
}
@ -149,7 +149,7 @@ int SDL_SYS_JoystickIsHaptic(SDL_Joystick *joystick)
{
SDL_hapticlist_item *item;
item = HapticByDevId(((joystick_hwdata *)joystick->hwdata)->device_id);
return (item != NULL) ? 1 : 0;
return (item) ? 1 : 0;
}
int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick)
@ -257,18 +257,18 @@ int Android_AddHaptic(int device_id, const char *name)
{
SDL_hapticlist_item *item;
item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item));
if (item == NULL) {
if (!item) {
return -1;
}
item->device_id = device_id;
item->name = SDL_strdup(name);
if (item->name == NULL) {
if (!item->name) {
SDL_free(item);
return -1;
}
if (SDL_hapticlist_tail == NULL) {
if (!SDL_hapticlist_tail) {
SDL_hapticlist = SDL_hapticlist_tail = item;
} else {
SDL_hapticlist_tail->next = item;
@ -284,12 +284,12 @@ int Android_RemoveHaptic(int device_id)
SDL_hapticlist_item *item;
SDL_hapticlist_item *prev = NULL;
for (item = SDL_hapticlist; item != NULL; item = item->next) {
for (item = SDL_hapticlist; item; item = item->next) {
/* found it, remove it. */
if (device_id == item->device_id) {
const int retval = item->haptic ? item->haptic->index : -1;
if (prev != NULL) {
if (prev) {
prev->next = item->next;
} else {
SDL_assert(SDL_hapticlist == item);

View file

@ -157,7 +157,7 @@ int SDL_SYS_HapticInit(void)
/* Get HID devices. */
match = IOServiceMatching(kIOHIDDeviceKey);
if (match == NULL) {
if (!match) {
return SDL_SetError("Haptic: Failed to get IOServiceMatching.");
}
@ -196,7 +196,7 @@ static SDL_hapticlist_item *HapticByDevIndex(int device_index)
}
while (device_index > 0) {
SDL_assert(item != NULL);
SDL_assert(item);
--device_index;
item = item->next;
}
@ -229,7 +229,7 @@ int MacHaptic_MaybeAddDevice(io_object_t device)
}
item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item));
if (item == NULL) {
if (!item) {
return SDL_SetError("Could not allocate haptic storage");
}
@ -265,7 +265,7 @@ int MacHaptic_MaybeAddDevice(io_object_t device)
CFRelease(hidProperties);
}
if (SDL_hapticlist_tail == NULL) {
if (!SDL_hapticlist_tail) {
SDL_hapticlist = SDL_hapticlist_tail = item;
} else {
SDL_hapticlist_tail->next = item;
@ -287,12 +287,12 @@ int MacHaptic_MaybeRemoveDevice(io_object_t device)
return -1; /* not initialized. ignore this. */
}
for (item = SDL_hapticlist; item != NULL; item = item->next) {
for (item = SDL_hapticlist; item; item = item->next) {
/* found it, remove it. */
if (IOObjectIsEqualTo((io_object_t)item->dev, device)) {
const int retval = item->haptic ? item->haptic->index : -1;
if (prev != NULL) {
if (prev) {
prev->next = item->next;
} else {
SDL_assert(SDL_hapticlist == item);
@ -478,7 +478,7 @@ static int SDL_SYS_HapticOpenFromService(SDL_Haptic *haptic, io_service_t servic
/* Allocate the hwdata */
haptic->hwdata = (struct haptic_hwdata *)
SDL_malloc(sizeof(*haptic->hwdata));
if (haptic->hwdata == NULL) {
if (!haptic->hwdata) {
SDL_OutOfMemory();
goto creat_err;
}
@ -516,7 +516,7 @@ static int SDL_SYS_HapticOpenFromService(SDL_Haptic *haptic, io_service_t servic
/* Allocate effects memory. */
haptic->effects = (struct haptic_effect *)
SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
if (haptic->effects == NULL) {
if (!haptic->effects) {
SDL_OutOfMemory();
goto open_err;
}
@ -530,7 +530,7 @@ static int SDL_SYS_HapticOpenFromService(SDL_Haptic *haptic, io_service_t servic
open_err:
FFReleaseDevice(haptic->hwdata->device);
creat_err:
if (haptic->hwdata != NULL) {
if (haptic->hwdata) {
SDL_free(haptic->hwdata);
haptic->hwdata = NULL;
}
@ -703,7 +703,7 @@ static int SDL_SYS_SetDirection(FFEFFECT *effect, SDL_HapticDirection *dir, int
/* Has axes. */
rglDir = SDL_malloc(sizeof(LONG) * naxes);
if (rglDir == NULL) {
if (!rglDir) {
return SDL_OutOfMemory();
}
SDL_memset(rglDir, 0, sizeof(LONG) * naxes);
@ -776,7 +776,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe
/* Envelope. */
envelope = SDL_malloc(sizeof(FFENVELOPE));
if (envelope == NULL) {
if (!envelope) {
return SDL_OutOfMemory();
}
SDL_memset(envelope, 0, sizeof(FFENVELOPE));
@ -791,7 +791,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe
}
if (dest->cAxes > 0) {
axes = SDL_malloc(sizeof(DWORD) * dest->cAxes);
if (axes == NULL) {
if (!axes) {
return SDL_OutOfMemory();
}
axes[0] = haptic->hwdata->axes[0]; /* Always at least one axis. */
@ -809,7 +809,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe
case SDL_HAPTIC_CONSTANT:
hap_constant = &src->constant;
constant = SDL_malloc(sizeof(FFCONSTANTFORCE));
if (constant == NULL) {
if (!constant) {
return SDL_OutOfMemory();
}
SDL_memset(constant, 0, sizeof(FFCONSTANTFORCE));
@ -851,7 +851,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe
case SDL_HAPTIC_SAWTOOTHDOWN:
hap_periodic = &src->periodic;
periodic = SDL_malloc(sizeof(FFPERIODIC));
if (periodic == NULL) {
if (!periodic) {
return SDL_OutOfMemory();
}
SDL_memset(periodic, 0, sizeof(FFPERIODIC));
@ -896,7 +896,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe
hap_condition = &src->condition;
if (dest->cAxes > 0) {
condition = SDL_malloc(sizeof(FFCONDITION) * dest->cAxes);
if (condition == NULL) {
if (!condition) {
return SDL_OutOfMemory();
}
SDL_memset(condition, 0, sizeof(FFCONDITION));
@ -939,7 +939,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe
case SDL_HAPTIC_RAMP:
hap_ramp = &src->ramp;
ramp = SDL_malloc(sizeof(FFRAMPFORCE));
if (ramp == NULL) {
if (!ramp) {
return SDL_OutOfMemory();
}
SDL_memset(ramp, 0, sizeof(FFRAMPFORCE));
@ -977,7 +977,7 @@ static int SDL_SYS_ToFFEFFECT(SDL_Haptic *haptic, FFEFFECT *dest, SDL_HapticEffe
case SDL_HAPTIC_CUSTOM:
hap_custom = &src->custom;
custom = SDL_malloc(sizeof(FFCUSTOMFORCE));
if (custom == NULL) {
if (!custom) {
return SDL_OutOfMemory();
}
SDL_memset(custom, 0, sizeof(FFCUSTOMFORCE));
@ -1037,7 +1037,7 @@ static void SDL_SYS_HapticFreeFFEFFECT(FFEFFECT *effect, int type)
effect->lpEnvelope = NULL;
SDL_free(effect->rgdwAxes);
effect->rgdwAxes = NULL;
if (effect->lpvTypeSpecificParams != NULL) {
if (effect->lpvTypeSpecificParams) {
if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */
custom = (FFCUSTOMFORCE *)effect->lpvTypeSpecificParams;
SDL_free(custom->rglForceData);
@ -1112,14 +1112,14 @@ int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect,
/* Alloc the effect. */
effect->hweffect = (struct haptic_hweffect *)
SDL_malloc(sizeof(struct haptic_hweffect));
if (effect->hweffect == NULL) {
if (!effect->hweffect) {
SDL_OutOfMemory();
goto err_hweffect;
}
/* Get the type. */
type = SDL_SYS_HapticEffectType(base->type);
if (type == NULL) {
if (!type) {
goto err_hweffect;
}

View file

@ -195,7 +195,7 @@ static SDL_hapticlist_item *HapticByDevIndex(int device_index)
}
while (device_index > 0) {
SDL_assert(item != NULL);
SDL_assert(item);
--device_index;
item = item->next;
}
@ -206,7 +206,7 @@ static SDL_hapticlist_item *HapticByDevIndex(int device_index)
#if SDL_USE_LIBUDEV
static void haptic_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath)
{
if (devpath == NULL || !(udev_class & SDL_UDEV_DEVICE_JOYSTICK)) {
if (!devpath || !(udev_class & SDL_UDEV_DEVICE_JOYSTICK)) {
return;
}
@ -232,7 +232,7 @@ static int MaybeAddDevice(const char *path)
int success;
SDL_hapticlist_item *item;
if (path == NULL) {
if (!path) {
return -1;
}
@ -242,7 +242,7 @@ static int MaybeAddDevice(const char *path)
}
/* check for duplicates */
for (item = SDL_hapticlist; item != NULL; item = item->next) {
for (item = SDL_hapticlist; item; item = item->next) {
if (item->dev_num == sb.st_rdev) {
return -1; /* duplicate. */
}
@ -266,12 +266,12 @@ static int MaybeAddDevice(const char *path)
}
item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item));
if (item == NULL) {
if (!item) {
return -1;
}
item->fname = SDL_strdup(path);
if (item->fname == NULL) {
if (!item->fname) {
SDL_free(item);
return -1;
}
@ -279,7 +279,7 @@ static int MaybeAddDevice(const char *path)
item->dev_num = sb.st_rdev;
/* TODO: should we add instance IDs? */
if (SDL_hapticlist_tail == NULL) {
if (!SDL_hapticlist_tail) {
SDL_hapticlist = SDL_hapticlist_tail = item;
} else {
SDL_hapticlist_tail->next = item;
@ -299,16 +299,16 @@ static int MaybeRemoveDevice(const char *path)
SDL_hapticlist_item *item;
SDL_hapticlist_item *prev = NULL;
if (path == NULL) {
if (!path) {
return -1;
}
for (item = SDL_hapticlist; item != NULL; item = item->next) {
for (item = SDL_hapticlist; item; item = item->next) {
/* found it, remove it. */
if (SDL_strcmp(path, item->fname) == 0) {
const int retval = item->haptic ? item->haptic->index : -1;
if (prev != NULL) {
if (prev) {
prev->next = item->next;
} else {
SDL_assert(SDL_hapticlist == item);
@ -365,7 +365,7 @@ const char *SDL_SYS_HapticName(int index)
if (fd >= 0) {
name = SDL_SYS_HapticNameFromFD(fd);
if (name == NULL) {
if (!name) {
/* No name found, return device character device */
name = item->fname;
}
@ -383,7 +383,7 @@ static int SDL_SYS_HapticOpenFromFD(SDL_Haptic *haptic, int fd)
/* Allocate the hwdata */
haptic->hwdata = (struct haptic_hwdata *)
SDL_malloc(sizeof(*haptic->hwdata));
if (haptic->hwdata == NULL) {
if (!haptic->hwdata) {
SDL_OutOfMemory();
goto open_err;
}
@ -403,7 +403,7 @@ static int SDL_SYS_HapticOpenFromFD(SDL_Haptic *haptic, int fd)
haptic->nplaying = haptic->neffects; /* Linux makes no distinction. */
haptic->effects = (struct haptic_effect *)
SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
if (haptic->effects == NULL) {
if (!haptic->effects) {
SDL_OutOfMemory();
goto open_err;
}
@ -416,7 +416,7 @@ static int SDL_SYS_HapticOpenFromFD(SDL_Haptic *haptic, int fd)
/* Error handling */
open_err:
close(fd);
if (haptic->hwdata != NULL) {
if (haptic->hwdata) {
SDL_free(haptic->hwdata);
haptic->hwdata = NULL;
}
@ -911,7 +911,7 @@ int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect,
/* Allocate the hardware effect */
effect->hweffect = (struct haptic_hweffect *)
SDL_malloc(sizeof(struct haptic_hweffect));
if (effect->hweffect == NULL) {
if (!effect->hweffect) {
return SDL_OutOfMemory();
}

View file

@ -98,7 +98,7 @@ int SDL_DINPUT_HapticInit(void)
/* Because we used CoCreateInstance, we need to Initialize it, first. */
instance = GetModuleHandle(NULL);
if (instance == NULL) {
if (!instance) {
SDL_SYS_HapticQuit();
return SDL_SetError("GetModuleHandle() failed with error code %lu.",
GetLastError());
@ -139,7 +139,7 @@ int SDL_DINPUT_HapticMaybeAddDevice(const DIDEVICEINSTANCE *pdidInstance)
DIDEVCAPS capabilities;
SDL_hapticlist_item *item = NULL;
if (dinput == NULL) {
if (!dinput) {
return -1; /* not initialized. We'll pick these up on enumeration if we init later. */
}
@ -172,7 +172,7 @@ int SDL_DINPUT_HapticMaybeAddDevice(const DIDEVICEINSTANCE *pdidInstance)
}
item = (SDL_hapticlist_item *)SDL_calloc(1, sizeof(SDL_hapticlist_item));
if (item == NULL) {
if (!item) {
return SDL_OutOfMemory();
}
@ -194,11 +194,11 @@ int SDL_DINPUT_HapticMaybeRemoveDevice(const DIDEVICEINSTANCE *pdidInstance)
SDL_hapticlist_item *item;
SDL_hapticlist_item *prev = NULL;
if (dinput == NULL) {
if (!dinput) {
return -1; /* not initialized, ignore this. */
}
for (item = SDL_hapticlist; item != NULL; item = item->next) {
for (item = SDL_hapticlist; item; item = item->next) {
if (!item->bXInputHaptic && SDL_memcmp(&item->instance, pdidInstance, sizeof(*pdidInstance)) == 0) {
/* found it, remove it. */
return SDL_SYS_RemoveHapticDevice(prev, item);
@ -293,7 +293,7 @@ static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVI
/* Allocate the hwdata */
haptic->hwdata = (struct haptic_hwdata *)SDL_malloc(sizeof(*haptic->hwdata));
if (haptic->hwdata == NULL) {
if (!haptic->hwdata) {
return SDL_OutOfMemory();
}
SDL_memset(haptic->hwdata, 0, sizeof(*haptic->hwdata));
@ -407,7 +407,7 @@ static int SDL_DINPUT_HapticOpenFromDevice(SDL_Haptic *haptic, LPDIRECTINPUTDEVI
/* Prepare effects memory. */
haptic->effects = (struct haptic_effect *)
SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects);
if (haptic->effects == NULL) {
if (!haptic->effects) {
SDL_OutOfMemory();
goto acquire_err;
}
@ -480,7 +480,7 @@ int SDL_DINPUT_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick
}
/* Since it comes from a joystick we have to try to match it with a haptic device on our haptic list. */
for (item = SDL_hapticlist; item != NULL; item = item->next) {
for (item = SDL_hapticlist; item; item = item->next) {
if (!item->bXInputHaptic && WIN_IsEqualGUID(&item->instance.guidInstance, &joy_instance.guidInstance)) {
haptic->index = index;
return SDL_DINPUT_HapticOpenFromDevice(haptic, joystick->hwdata->InputDevice, SDL_TRUE);
@ -546,7 +546,7 @@ static int SDL_SYS_SetDirection(DIEFFECT *effect, SDL_HapticDirection *dir, int
/* Has axes. */
rglDir = SDL_malloc(sizeof(LONG) * naxes);
if (rglDir == NULL) {
if (!rglDir) {
return SDL_OutOfMemory();
}
SDL_memset(rglDir, 0, sizeof(LONG) * naxes);
@ -620,7 +620,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
/* Envelope. */
envelope = SDL_malloc(sizeof(DIENVELOPE));
if (envelope == NULL) {
if (!envelope) {
return SDL_OutOfMemory();
}
SDL_memset(envelope, 0, sizeof(DIENVELOPE));
@ -635,7 +635,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
}
if (dest->cAxes > 0) {
axes = SDL_malloc(sizeof(DWORD) * dest->cAxes);
if (axes == NULL) {
if (!axes) {
return SDL_OutOfMemory();
}
axes[0] = haptic->hwdata->axes[0]; /* Always at least one axis. */
@ -653,7 +653,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
case SDL_HAPTIC_CONSTANT:
hap_constant = &src->constant;
constant = SDL_malloc(sizeof(DICONSTANTFORCE));
if (constant == NULL) {
if (!constant) {
return SDL_OutOfMemory();
}
SDL_memset(constant, 0, sizeof(DICONSTANTFORCE));
@ -695,7 +695,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
case SDL_HAPTIC_SAWTOOTHDOWN:
hap_periodic = &src->periodic;
periodic = SDL_malloc(sizeof(DIPERIODIC));
if (periodic == NULL) {
if (!periodic) {
return SDL_OutOfMemory();
}
SDL_memset(periodic, 0, sizeof(DIPERIODIC));
@ -739,7 +739,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
case SDL_HAPTIC_FRICTION:
hap_condition = &src->condition;
condition = SDL_malloc(sizeof(DICONDITION) * dest->cAxes);
if (condition == NULL) {
if (!condition) {
return SDL_OutOfMemory();
}
SDL_memset(condition, 0, sizeof(DICONDITION));
@ -780,7 +780,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
case SDL_HAPTIC_RAMP:
hap_ramp = &src->ramp;
ramp = SDL_malloc(sizeof(DIRAMPFORCE));
if (ramp == NULL) {
if (!ramp) {
return SDL_OutOfMemory();
}
SDL_memset(ramp, 0, sizeof(DIRAMPFORCE));
@ -818,7 +818,7 @@ static int SDL_SYS_ToDIEFFECT(SDL_Haptic *haptic, DIEFFECT *dest,
case SDL_HAPTIC_CUSTOM:
hap_custom = &src->custom;
custom = SDL_malloc(sizeof(DICUSTOMFORCE));
if (custom == NULL) {
if (!custom) {
return SDL_OutOfMemory();
}
SDL_memset(custom, 0, sizeof(DICUSTOMFORCE));
@ -877,7 +877,7 @@ static void SDL_SYS_HapticFreeDIEFFECT(DIEFFECT *effect, int type)
effect->lpEnvelope = NULL;
SDL_free(effect->rgdwAxes);
effect->rgdwAxes = NULL;
if (effect->lpvTypeSpecificParams != NULL) {
if (effect->lpvTypeSpecificParams) {
if (type == SDL_HAPTIC_CUSTOM) { /* Must free the custom data. */
custom = (DICUSTOMFORCE *)effect->lpvTypeSpecificParams;
SDL_free(custom->rglForceData);
@ -943,7 +943,7 @@ int SDL_DINPUT_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect,
HRESULT ret;
REFGUID type = SDL_SYS_HapticEffectType(base);
if (type == NULL) {
if (!type) {
return SDL_SetError("Haptic: Unknown effect type.");
}

View file

@ -81,7 +81,7 @@ int SDL_SYS_HapticInit(void)
int SDL_SYS_AddHapticDevice(SDL_hapticlist_item *item)
{
if (SDL_hapticlist_tail == NULL) {
if (!SDL_hapticlist_tail) {
SDL_hapticlist = SDL_hapticlist_tail = item;
} else {
SDL_hapticlist_tail->next = item;
@ -97,7 +97,7 @@ int SDL_SYS_AddHapticDevice(SDL_hapticlist_item *item)
int SDL_SYS_RemoveHapticDevice(SDL_hapticlist_item *prev, SDL_hapticlist_item *item)
{
const int retval = item->haptic ? item->haptic->index : -1;
if (prev != NULL) {
if (prev) {
prev->next = item->next;
} else {
SDL_assert(SDL_hapticlist == item);
@ -126,7 +126,7 @@ static SDL_hapticlist_item *HapticByDevIndex(int device_index)
}
while (device_index > 0) {
SDL_assert(item != NULL);
SDL_assert(item);
--device_index;
item = item->next;
}
@ -165,7 +165,7 @@ int SDL_SYS_HapticMouse(void)
int index = 0;
/* Grab the first mouse haptic device we find. */
for (item = SDL_hapticlist; item != NULL; item = item->next) {
for (item = SDL_hapticlist; item; item = item->next) {
if (item->capabilities.dwDevType == DI8DEVCLASS_POINTER) {
return index;
}
@ -299,7 +299,7 @@ int SDL_SYS_HapticNewEffect(SDL_Haptic *haptic, struct haptic_effect *effect,
/* Alloc the effect. */
effect->hweffect = (struct haptic_hweffect *)
SDL_malloc(sizeof(struct haptic_hweffect));
if (effect->hweffect == NULL) {
if (!effect->hweffect) {
SDL_OutOfMemory();
return -1;
}

Some files were not shown because too many files have changed in this diff Show more