diff --git a/VisualC-GDK/tests/testgdk/src/testgdk.cpp b/VisualC-GDK/tests/testgdk/src/testgdk.cpp index 1a962a4c2..50f93e2fa 100644 --- a/VisualC-GDK/tests/testgdk/src/testgdk.cpp +++ b/VisualC-GDK/tests/testgdk/src/testgdk.cpp @@ -385,7 +385,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; } @@ -448,7 +448,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); } @@ -463,7 +463,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); } diff --git a/cmake/test/main_gui.c b/cmake/test/main_gui.c index 715c4306f..c8cc03c12 100644 --- a/cmake/test/main_gui.c +++ b/cmake/test/main_gui.c @@ -10,7 +10,7 @@ int main(int argc, char *argv[]) return 1; } window = SDL_CreateWindow("Hello SDL", 640, 480, 0); - if (window == NULL) { + if (!window) { SDL_Log("could not create window: %s\n", SDL_GetError()); return 1; } diff --git a/src/SDL.c b/src/SDL.c index 2959db874..302e625e9 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -557,7 +557,7 @@ int 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 SDL_InvalidParamError("ver"); } diff --git a/src/SDL_assert.c b/src/SDL_assert.c index ba1c194d9..6c2491aac 100644 --- a/src/SDL_assert.c +++ b/src/SDL_assert.c @@ -106,11 +106,11 @@ static void SDL_GenerateAssertionReport(void) const SDL_AssertData *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" @@ -198,7 +198,7 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v /* 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); } @@ -334,9 +334,9 @@ SDL_AssertState SDL_ReportAssertion(SDL_AssertData *data, const char *func, cons #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. */ } @@ -401,7 +401,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; } @@ -429,7 +429,7 @@ void SDL_ResetAssertionReport(void) { SDL_AssertData *next = NULL; SDL_AssertData *item; - for (item = triggered_assertions; item != NULL; item = next) { + for (item = triggered_assertions; item; item = next) { next = (SDL_AssertData *)item->next; item->always_ignore = SDL_FALSE; item->trigger_count = 0; @@ -446,7 +446,7 @@ SDL_AssertionHandler SDL_GetDefaultAssertionHandler(void) SDL_AssertionHandler SDL_GetAssertionHandler(void **userdata) { - if (userdata != NULL) { + if (userdata) { *userdata = assertion_userdata; } return assertion_handler; diff --git a/src/SDL_error.c b/src/SDL_error.c index 00f1bcf7d..25fe696c7 100644 --- a/src/SDL_error.c +++ b/src/SDL_error.c @@ -27,7 +27,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(); diff --git a/src/SDL_guid.c b/src/SDL_guid.c index 61387941c..fc68db429 100644 --- a/src/SDL_guid.c +++ b/src/SDL_guid.c @@ -26,7 +26,7 @@ int SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID) static const char k_rgchHexToASCII[] = "0123456789abcdef"; int i; - if (pszGUID == NULL) { + if (!pszGUID) { return SDL_InvalidParamError("pszGUID"); } if (cbGUID <= 0) { diff --git a/src/SDL_hashtable.c b/src/SDL_hashtable.c index 1c3c7bb63..0b8980598 100644 --- a/src/SDL_hashtable.c +++ b/src/SDL_hashtable.c @@ -53,13 +53,13 @@ SDL_HashTable *SDL_CreateHashTable(void *data, const Uint32 num_buckets, const S } table = (SDL_HashTable *) SDL_calloc(1, sizeof (SDL_HashTable)); - if (table == NULL) { + if (!table) { SDL_OutOfMemory(); return NULL; } table->table = (SDL_HashItem **) SDL_calloc(num_buckets, sizeof (SDL_HashItem *)); - if (table->table == NULL) { + if (!table->table) { SDL_free(table); SDL_OutOfMemory(); return NULL; @@ -91,7 +91,7 @@ SDL_bool SDL_InsertIntoHashTable(SDL_HashTable *table, const void *key, const vo // !!! FIXME: grow and rehash table if it gets too saturated. item = (SDL_HashItem *) SDL_malloc(sizeof (SDL_HashItem)); - if (item == NULL) { + if (!item) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -110,9 +110,9 @@ SDL_bool SDL_FindInHashTable(const SDL_HashTable *table, const void *key, const void *data = table->data; SDL_HashItem *i; - for (i = table->table[hash]; i != NULL; i = i->next) { + for (i = table->table[hash]; i; i = i->next) { if (table->keymatch(key, i->key, data)) { - if (_value != NULL) { + if (_value) { *_value = i->value; } return SDL_TRUE; @@ -129,9 +129,9 @@ SDL_bool SDL_RemoveFromHashTable(SDL_HashTable *table, const void *key) SDL_HashItem *prev = NULL; void *data = table->data; - for (item = table->table[hash]; item != NULL; item = item->next) { + for (item = table->table[hash]; item; item = item->next) { if (table->keymatch(key, item->key, data)) { - if (prev != NULL) { + if (prev) { prev->next = item->next; } else { table->table[hash] = item->next; @@ -152,7 +152,7 @@ SDL_bool SDL_IterateHashTableKey(const SDL_HashTable *table, const void *key, co { SDL_HashItem *item = *iter ? ((SDL_HashItem *) *iter)->next : table->table[calc_hash(table, key)]; - while (item != NULL) { + while (item) { if (table->keymatch(key, item->key, table->data)) { *_value = item->value; *iter = item; @@ -172,10 +172,10 @@ SDL_bool SDL_IterateHashTable(const SDL_HashTable *table, const void **_key, con SDL_HashItem *item = (SDL_HashItem *) *iter; Uint32 idx = 0; - if (item != NULL) { + if (item) { const SDL_HashItem *orig = item; item = item->next; - if (item == NULL) { + if (!item) { idx = calc_hash(table, orig->key) + 1; // !!! FIXME: we probably shouldn't rehash each time. } } @@ -184,7 +184,7 @@ SDL_bool SDL_IterateHashTable(const SDL_HashTable *table, const void **_key, con item = table->table[idx++]; // skip empty buckets... } - if (item == NULL) { // no more matches? + if (!item) { // no more matches? *_key = NULL; *iter = NULL; return SDL_FALSE; @@ -199,12 +199,12 @@ SDL_bool SDL_IterateHashTable(const SDL_HashTable *table, const void **_key, con SDL_bool SDL_HashTableEmpty(SDL_HashTable *table) { - if (table != NULL) { + if (table) { Uint32 i; for (i = 0; i < table->table_len; i++) { SDL_HashItem *item = table->table[i]; - if (item != NULL) { + if (item) { return SDL_FALSE; } } @@ -214,13 +214,13 @@ SDL_bool SDL_HashTableEmpty(SDL_HashTable *table) void SDL_DestroyHashTable(SDL_HashTable *table) { - if (table != NULL) { + if (table) { void *data = table->data; Uint32 i; for (i = 0; i < table->table_len; i++) { SDL_HashItem *item = table->table[i]; - while (item != NULL) { + while (item) { SDL_HashItem *next = item->next; table->nuke(item->key, item->value, data); SDL_free(item); diff --git a/src/SDL_hints.c b/src/SDL_hints.c index 9ee0bc31c..3e792c6d5 100644 --- a/src/SDL_hints.c +++ b/src/SDL_hints.c @@ -49,7 +49,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; } @@ -64,7 +64,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)) { char *old_value = hint->value; hint->value = value ? SDL_strdup(value) : NULL; @@ -85,7 +85,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); @@ -103,16 +103,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; @@ -137,9 +137,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; @@ -166,7 +166,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; @@ -177,7 +177,7 @@ const char *SDL_GetHint(const char *name) int SDL_GetStringInteger(const char *value, int default_value) { - if (value == NULL || !*value) { + if (!value || !*value) { return default_value; } if (*value == '0' || SDL_strcasecmp(value, "false") == 0) { @@ -194,7 +194,7 @@ int SDL_GetStringInteger(const char *value, int default_value) 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) { @@ -215,7 +215,7 @@ int SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userd SDL_HintWatch *entry; const char *value; - if (name == NULL || !*name) { + if (!name || !*name) { return SDL_InvalidParamError("name"); } if (!callback) { @@ -225,7 +225,7 @@ int SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userd SDL_DelHintCallback(name, callback, userdata); entry = (SDL_HintWatch *)SDL_malloc(sizeof(*entry)); - if (entry == NULL) { + if (!entry) { return SDL_OutOfMemory(); } entry->callback = callback; @@ -236,10 +236,10 @@ int SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userd 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_free(entry); return SDL_OutOfMemory(); } diff --git a/src/SDL_list.c b/src/SDL_list.c index 8c4b509e3..64c39245e 100644 --- a/src/SDL_list.c +++ b/src/SDL_list.c @@ -27,7 +27,7 @@ int SDL_ListAdd(SDL_ListNode **head, void *ent) { SDL_ListNode *node = SDL_malloc(sizeof(*node)); - if (node == NULL) { + if (!node) { return SDL_OutOfMemory(); } @@ -43,7 +43,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; } diff --git a/src/SDL_log.c b/src/SDL_log.c index 214574e34..a9ac740c4 100644 --- a/src/SDL_log.c +++ b/src/SDL_log.c @@ -112,7 +112,7 @@ static int SDL_android_priority[SDL_NUM_LOG_PRIORITIES] = { void SDL_InitLog(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(); } @@ -305,7 +305,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(); } @@ -323,7 +323,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); @@ -459,7 +459,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); } @@ -468,7 +468,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); } @@ -477,7 +477,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); } diff --git a/src/atomic/SDL_spinlock.c b/src/atomic/SDL_spinlock.c index 6f37fa52a..25615accc 100644 --- a/src/atomic/SDL_spinlock.c +++ b/src/atomic/SDL_spinlock.c @@ -63,7 +63,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(); } diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index f8f24c392..7d44695d2 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -139,7 +139,7 @@ static int GetDefaultSampleFramesFromFreq(const int freq) void OnAudioStreamCreated(SDL_AudioStream *stream) { - SDL_assert(stream != NULL); + SDL_assert(stream); // NOTE that you can create an audio stream without initializing the audio subsystem, // but it will not be automatically destroyed during a later call to SDL_Quit! @@ -159,7 +159,7 @@ void OnAudioStreamCreated(SDL_AudioStream *stream) void OnAudioStreamDestroy(SDL_AudioStream *stream) { - SDL_assert(stream != NULL); + SDL_assert(stream); // NOTE that you can create an audio stream without initializing the audio subsystem, // but it will not be automatically destroyed during a later call to SDL_Quit! @@ -207,8 +207,8 @@ static void UpdateAudioStreamFormatsPhysical(SDL_AudioDevice *device) spec.format = SDL_AUDIO_F32; // mixing and postbuf operates in float32 format. } - for (SDL_LogicalAudioDevice *logdev = device->logical_devices; logdev != NULL; logdev = logdev->next) { - for (SDL_AudioStream *stream = logdev->bound_streams; stream != NULL; stream = stream->next_binding) { + for (SDL_LogicalAudioDevice *logdev = device->logical_devices; logdev; logdev = logdev->next) { + for (SDL_AudioStream *stream = logdev->bound_streams; stream; stream = stream->next_binding) { // set the proper end of the stream to the device's format. // SDL_SetAudioStreamFormat does a ton of validation just to memcpy an audiospec. SDL_LockMutex(stream->lock); @@ -441,7 +441,7 @@ static void DestroyLogicalAudioDevice(SDL_LogicalAudioDevice *logdev) // unbind any still-bound streams... SDL_AudioStream *next; - for (SDL_AudioStream *stream = logdev->bound_streams; stream != NULL; stream = next) { + for (SDL_AudioStream *stream = logdev->bound_streams; stream; stream = next) { SDL_LockMutex(stream->lock); next = stream->next_binding; stream->next_binding = NULL; @@ -463,7 +463,7 @@ static void DestroyPhysicalAudioDevice(SDL_AudioDevice *device) // Destroy any logical devices that still exist... SDL_LockMutex(device->lock); // don't use ObtainPhysicalAudioDeviceObj because we don't want to change refcounts while destroying. - while (device->logical_devices != NULL) { + while (device->logical_devices) { DestroyLogicalAudioDevice(device->logical_devices); } SDL_UnlockMutex(device->lock); // don't use ReleaseAudioDevice because we don't want to change refcounts while destroying. @@ -500,7 +500,7 @@ void RefPhysicalAudioDevice(SDL_AudioDevice *device) static SDL_AudioDevice *CreatePhysicalAudioDevice(const char *name, SDL_bool iscapture, const SDL_AudioSpec *spec, void *handle, SDL_AtomicInt *device_count) { - SDL_assert(name != NULL); + SDL_assert(name); SDL_LockRWLockForReading(current_audio.device_hash_lock); const int shutting_down = SDL_AtomicGet(¤t_audio.shutting_down); @@ -593,8 +593,8 @@ SDL_AudioDevice *SDL_AddAudioDevice(const SDL_bool iscapture, const char *name, p->devid = device->instance_id; p->next = NULL; SDL_LockRWLockForWriting(current_audio.device_hash_lock); - SDL_assert(current_audio.pending_events_tail != NULL); - SDL_assert(current_audio.pending_events_tail->next == NULL); + SDL_assert(current_audio.pending_events_tail); + SDL_assert(!current_audio.pending_events_tail->next); current_audio.pending_events_tail->next = p; current_audio.pending_events_tail = p; SDL_UnlockRWLock(current_audio.device_hash_lock); @@ -642,7 +642,7 @@ void SDL_AudioDeviceDisconnected(SDL_AudioDevice *device) // on default devices, dump any logical devices that explicitly opened this device. Things that opened the system default can stay. // on non-default devices, dump everything. // (by "dump" we mean send a REMOVED event; the zombie will keep consuming audio data for these logical devices until explicitly closed.) - for (SDL_LogicalAudioDevice *logdev = device->logical_devices; logdev != NULL; logdev = logdev->next) { + for (SDL_LogicalAudioDevice *logdev = device->logical_devices; logdev; logdev = logdev->next) { if (!is_default_device || !logdev->opened_as_default) { // if opened as a default, leave it on the zombie device for later migration. SDL_PendingAudioDeviceEvent *p = (SDL_PendingAudioDeviceEvent *) SDL_malloc(sizeof (SDL_PendingAudioDeviceEvent)); if (p) { // if this failed, no event for you, but you have deeper problems anyhow. @@ -670,8 +670,8 @@ void SDL_AudioDeviceDisconnected(SDL_AudioDevice *device) if (first_disconnect) { if (pending.next) { // NULL if event is disabled or disaster struck. SDL_LockRWLockForWriting(current_audio.device_hash_lock); - SDL_assert(current_audio.pending_events_tail != NULL); - SDL_assert(current_audio.pending_events_tail->next == NULL); + SDL_assert(current_audio.pending_events_tail); + SDL_assert(!current_audio.pending_events_tail->next); current_audio.pending_events_tail->next = pending.next; current_audio.pending_events_tail = pending_tail; SDL_UnlockRWLock(current_audio.device_hash_lock); @@ -817,26 +817,26 @@ int SDL_InitAudio(const char *driver_name) } // Select the proper audio driver - if (driver_name == NULL) { + if (!driver_name) { driver_name = SDL_GetHint(SDL_HINT_AUDIO_DRIVER); } SDL_bool initialized = SDL_FALSE; SDL_bool tried_to_init = SDL_FALSE; - if (driver_name != NULL && *driver_name != 0) { + if (driver_name && *driver_name != 0) { char *driver_name_copy = SDL_strdup(driver_name); const char *driver_attempt = driver_name_copy; - if (driver_name_copy == NULL) { + if (!driver_name_copy) { SDL_DestroyRWLock(device_hash_lock); SDL_DestroyHashTable(device_hash); return SDL_OutOfMemory(); } - while (driver_attempt != NULL && *driver_attempt != 0 && !initialized) { + while (driver_attempt && *driver_attempt != 0 && !initialized) { char *driver_attempt_end = SDL_strchr(driver_attempt, ','); - if (driver_attempt_end != NULL) { + if (driver_attempt_end) { *driver_attempt_end = '\0'; } @@ -863,7 +863,7 @@ int SDL_InitAudio(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; } SDL_free(driver_name_copy); @@ -940,7 +940,7 @@ void SDL_QuitAudio(void) current_audio.impl.DeinitializeStart(); // Destroy any audio streams that still exist... - while (current_audio.existing_streams != NULL) { + while (current_audio.existing_streams) { SDL_DestroyAudioStream(current_audio.existing_streams); } @@ -955,7 +955,7 @@ void SDL_QuitAudio(void) SDL_UnlockRWLock(current_audio.device_hash_lock); SDL_PendingAudioDeviceEvent *pending_next = NULL; - for (SDL_PendingAudioDeviceEvent *i = pending_events; i != NULL; i = pending_next) { + for (SDL_PendingAudioDeviceEvent *i = pending_events; i; i = pending_next) { pending_next = i->next; SDL_free(i); } @@ -1053,7 +1053,7 @@ SDL_bool SDL_OutputAudioThreadIterate(SDL_AudioDevice *device) SDL_memset(final_mix_buffer, '\0', work_buffer_size); // start with silence. - for (SDL_LogicalAudioDevice *logdev = device->logical_devices; logdev != NULL; logdev = logdev->next) { + for (SDL_LogicalAudioDevice *logdev = device->logical_devices; logdev; logdev = logdev->next) { if (SDL_AtomicGet(&logdev->paused)) { continue; // paused? Skip this logical device. } @@ -1065,7 +1065,7 @@ SDL_bool SDL_OutputAudioThreadIterate(SDL_AudioDevice *device) SDL_memset(mix_buffer, '\0', work_buffer_size); // start with silence. } - for (SDL_AudioStream *stream = logdev->bound_streams; stream != NULL; stream = stream->next_binding) { + for (SDL_AudioStream *stream = logdev->bound_streams; stream; stream = stream->next_binding) { // We should have updated this elsewhere if the format changed! SDL_assert(AUDIO_SPECS_EQUAL(stream->dst_spec, outspec)); @@ -1127,7 +1127,7 @@ void SDL_OutputAudioThreadShutdown(SDL_AudioDevice *device) static int SDLCALL OutputAudioThread(void *devicep) // thread entry point { SDL_AudioDevice *device = (SDL_AudioDevice *)devicep; - SDL_assert(device != NULL); + SDL_assert(device); SDL_assert(!device->iscapture); SDL_OutputAudioThreadSetup(device); @@ -1164,7 +1164,7 @@ SDL_bool SDL_CaptureAudioThreadIterate(SDL_AudioDevice *device) SDL_bool failed = SDL_FALSE; - if (device->logical_devices == NULL) { + if (!device->logical_devices) { device->FlushCapture(device); // nothing wants data, dump anything pending. } else { // this SHOULD NOT BLOCK, as we are holding a lock right now. Block in WaitCaptureDevice! @@ -1172,7 +1172,7 @@ SDL_bool SDL_CaptureAudioThreadIterate(SDL_AudioDevice *device) if (br < 0) { // uhoh, device failed for some reason! failed = SDL_TRUE; } else if (br > 0) { // queue the new data to each bound stream. - for (SDL_LogicalAudioDevice *logdev = device->logical_devices; logdev != NULL; logdev = logdev->next) { + for (SDL_LogicalAudioDevice *logdev = device->logical_devices; logdev; logdev = logdev->next) { if (SDL_AtomicGet(&logdev->paused)) { continue; // paused? Skip this logical device. } @@ -1193,7 +1193,7 @@ SDL_bool SDL_CaptureAudioThreadIterate(SDL_AudioDevice *device) logdev->postmix(logdev->postmix_userdata, &outspec, device->postmix_buffer, br); } - for (SDL_AudioStream *stream = logdev->bound_streams; stream != NULL; stream = stream->next_binding) { + for (SDL_AudioStream *stream = logdev->bound_streams; stream; stream = stream->next_binding) { // We should have updated this elsewhere if the format changed! SDL_assert(stream->src_spec.format == (logdev->postmix ? SDL_AUDIO_F32 : device->spec.format)); SDL_assert(stream->src_spec.channels == device->spec.channels); @@ -1233,7 +1233,7 @@ void SDL_CaptureAudioThreadShutdown(SDL_AudioDevice *device) static int SDLCALL CaptureAudioThread(void *devicep) // thread entry point { SDL_AudioDevice *device = (SDL_AudioDevice *)devicep; - SDL_assert(device != NULL); + SDL_assert(device); SDL_assert(device->iscapture); SDL_CaptureAudioThreadSetup(device); @@ -1261,7 +1261,7 @@ static SDL_AudioDeviceID *GetAudioDevices(int *reqcount, SDL_bool iscapture) int num_devices = SDL_AtomicGet(iscapture ? ¤t_audio.capture_device_count : ¤t_audio.output_device_count); if (num_devices > 0) { retval = (SDL_AudioDeviceID *) SDL_malloc((num_devices + 1) * sizeof (SDL_AudioDeviceID)); - if (retval == NULL) { + if (!retval) { num_devices = 0; SDL_OutOfMemory(); } else { @@ -1287,7 +1287,7 @@ static SDL_AudioDeviceID *GetAudioDevices(int *reqcount, SDL_bool iscapture) } SDL_UnlockRWLock(current_audio.device_hash_lock); - if (reqcount != NULL) { + if (reqcount) { *reqcount = num_devices; } @@ -1384,7 +1384,7 @@ int SDL_GetAudioDeviceFormat(SDL_AudioDeviceID devid, SDL_AudioSpec *spec, int * static void ClosePhysicalAudioDevice(SDL_AudioDevice *device) { SDL_AtomicSet(&device->shutdown, 1); - if (device->thread != NULL) { + if (device->thread) { SDL_WaitThread(device->thread, NULL); device->thread = NULL; } @@ -1417,7 +1417,7 @@ void SDL_CloseAudioDevice(SDL_AudioDeviceID devid) SDL_LogicalAudioDevice *logdev = ObtainLogicalAudioDevice(devid, &device); if (logdev) { DestroyLogicalAudioDevice(logdev); - close_physical = (device->logical_devices == NULL); // no more logical devices? Close the physical device, too. + close_physical = (!device->logical_devices); // no more logical devices? Close the physical device, too. } // !!! FIXME: we _need_ to release this lock, but doing so can cause a race condition if someone opens a device while we're closing it. @@ -1458,7 +1458,7 @@ static void PrepareAudioFormat(SDL_bool iscapture, SDL_AudioSpec *spec) spec->freq = iscapture ? DEFAULT_AUDIO_CAPTURE_FREQUENCY : DEFAULT_AUDIO_OUTPUT_FREQUENCY; const char *env = SDL_getenv("SDL_AUDIO_FREQUENCY"); // !!! FIXME: should be a hint? - if (env != NULL) { + if (env) { const int val = SDL_atoi(env); if (val > 0) { spec->freq = val; @@ -1469,7 +1469,7 @@ static void PrepareAudioFormat(SDL_bool iscapture, SDL_AudioSpec *spec) if (spec->channels == 0) { spec->channels = iscapture ? DEFAULT_AUDIO_CAPTURE_CHANNELS : DEFAULT_AUDIO_OUTPUT_CHANNELS;; const char *env = SDL_getenv("SDL_AUDIO_CHANNELS"); - if (env != NULL) { + if (env) { const int val = SDL_atoi(env); if (val > 0) { spec->channels = val; @@ -1502,7 +1502,7 @@ char *SDL_GetAudioThreadName(SDL_AudioDevice *device, char *buf, size_t buflen) static int OpenPhysicalAudioDevice(SDL_AudioDevice *device, const SDL_AudioSpec *inspec) { SDL_assert(!device->currently_opened); - SDL_assert(device->logical_devices == NULL); + SDL_assert(!device->logical_devices); // Just pretend to open a zombie device. It can still collect logical devices on a default device under the assumption they will all migrate when the default device is officially changed. if (SDL_AtomicGet(&device->zombie)) { @@ -1541,14 +1541,14 @@ static int OpenPhysicalAudioDevice(SDL_AudioDevice *device, const SDL_AudioSpec // Allocate a scratch audio buffer device->work_buffer = (Uint8 *)SDL_aligned_alloc(SDL_SIMDGetAlignment(), device->work_buffer_size); - if (device->work_buffer == NULL) { + if (!device->work_buffer) { ClosePhysicalAudioDevice(device); return SDL_OutOfMemory(); } if (device->spec.format != SDL_AUDIO_F32) { device->mix_buffer = (Uint8 *)SDL_aligned_alloc(SDL_SIMDGetAlignment(), device->work_buffer_size); - if (device->mix_buffer == NULL) { + if (!device->mix_buffer) { ClosePhysicalAudioDevice(device); return SDL_OutOfMemory(); } @@ -1561,7 +1561,7 @@ static int OpenPhysicalAudioDevice(SDL_AudioDevice *device, const SDL_AudioSpec SDL_GetAudioThreadName(device, threadname, sizeof (threadname)); device->thread = SDL_CreateThreadInternal(device->iscapture ? CaptureAudioThread : OutputAudioThread, threadname, stacksize, device); - if (device->thread == NULL) { + if (!device->thread) { ClosePhysicalAudioDevice(device); return SDL_SetError("Couldn't create audio thread"); } @@ -1672,7 +1672,7 @@ int SDL_SetAudioPostmixCallback(SDL_AudioDeviceID devid, SDL_AudioPostmixCallbac if (logdev) { if (callback && !device->postmix_buffer) { device->postmix_buffer = (float *)SDL_aligned_alloc(SDL_SIMDGetAlignment(), device->work_buffer_size); - if (device->postmix_buffer == NULL) { + if (!device->postmix_buffer) { retval = SDL_OutOfMemory(); } } @@ -1682,7 +1682,7 @@ int SDL_SetAudioPostmixCallback(SDL_AudioDeviceID devid, SDL_AudioPostmixCallbac logdev->postmix_userdata = userdata; if (device->iscapture) { - for (SDL_AudioStream *stream = logdev->bound_streams; stream != NULL; stream = stream->next_binding) { + for (SDL_AudioStream *stream = logdev->bound_streams; stream; stream = stream->next_binding) { // set the proper end of the stream to the device's format. // SDL_SetAudioStreamFormat does a ton of validation just to memcpy an audiospec. SDL_LockMutex(stream->lock); @@ -1709,7 +1709,7 @@ int SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int return 0; // nothing to do } else if (num_streams < 0) { return SDL_InvalidParamError("num_streams"); - } else if (streams == NULL) { + } else if (!streams) { return SDL_InvalidParamError("streams"); } else if (!islogical) { return SDL_SetError("Audio streams are bound to device ids from SDL_OpenAudioDevice, not raw physical devices"); @@ -1726,16 +1726,16 @@ int SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int // !!! FIXME: Actually, why do we allow there to be an invalid format, again? // make sure start of list is sane. - SDL_assert(!logdev->bound_streams || (logdev->bound_streams->prev_binding == NULL)); + SDL_assert(!logdev->bound_streams || (!logdev->bound_streams->prev_binding)); // lock all the streams upfront, so we can verify they aren't bound elsewhere and add them all in one block, as this is intended to add everything or nothing. for (int i = 0; i < num_streams; i++) { SDL_AudioStream *stream = streams[i]; - if (stream == NULL) { + if (!stream) { retval = SDL_SetError("Stream #%d is NULL", i); } else { SDL_LockMutex(stream->lock); - SDL_assert((stream->bound_device == NULL) == ((stream->prev_binding == NULL) || (stream->next_binding == NULL))); + SDL_assert((!stream->bound_device) == ((!stream->prev_binding) || (!stream->next_binding))); if (stream->bound_device) { retval = SDL_SetError("Stream #%d is already bound to a device", i); } else if (stream->simplified) { // You can get here if you closed the device instead of destroying the stream. @@ -1830,7 +1830,7 @@ void SDL_UnbindAudioStreams(SDL_AudioStream **streams, int num_streams) // don't allow unbinding from "simplified" devices (opened with SDL_OpenAudioDeviceStream). Just ignore them. if (stream && stream->bound_device && !stream->bound_device->simplified) { if (stream->bound_device->bound_streams == stream) { - SDL_assert(stream->prev_binding == NULL); + SDL_assert(!stream->prev_binding); stream->bound_device->bound_streams = stream->next_binding; } if (stream->prev_binding) { @@ -1887,12 +1887,12 @@ SDL_AudioStream *SDL_OpenAudioDeviceStream(SDL_AudioDeviceID devid, const SDL_Au SDL_AudioStream *stream = NULL; SDL_AudioDevice *device = NULL; SDL_LogicalAudioDevice *logdev = ObtainLogicalAudioDevice(logdevid, &device); - if (logdev == NULL) { // this shouldn't happen, but just in case. + if (!logdev) { // this shouldn't happen, but just in case. failed = SDL_TRUE; } else { SDL_AtomicSet(&logdev->paused, 1); // start the device paused, to match SDL2. - SDL_assert(device != NULL); + SDL_assert(device); const SDL_bool iscapture = device->iscapture; if (iscapture) { @@ -1960,7 +1960,7 @@ int SDL_GetSilenceValueForFormat(SDL_AudioFormat format) // called internally by backends when the system default device changes. void SDL_DefaultAudioDeviceChanged(SDL_AudioDevice *new_default_device) { - if (new_default_device == NULL) { // !!! FIXME: what should we do in this case? Maybe all devices are lost, so there _isn't_ a default? + if (!new_default_device) { // !!! FIXME: what should we do in this case? Maybe all devices are lost, so there _isn't_ a default? return; // uhoh. } @@ -2007,10 +2007,10 @@ void SDL_DefaultAudioDeviceChanged(SDL_AudioDevice *new_default_device) SDL_bool needs_migration = SDL_FALSE; SDL_zero(spec); - for (SDL_LogicalAudioDevice *logdev = current_default_device->logical_devices; logdev != NULL; logdev = logdev->next) { + for (SDL_LogicalAudioDevice *logdev = current_default_device->logical_devices; logdev; logdev = logdev->next) { if (logdev->opened_as_default) { needs_migration = SDL_TRUE; - for (SDL_AudioStream *stream = logdev->bound_streams; stream != NULL; stream = stream->next_binding) { + for (SDL_AudioStream *stream = logdev->bound_streams; stream; stream = stream->next_binding) { const SDL_AudioSpec *streamspec = iscapture ? &stream->dst_spec : &stream->src_spec; if (SDL_AUDIO_BITSIZE(streamspec->format) > SDL_AUDIO_BITSIZE(spec.format)) { spec.format = streamspec->format; @@ -2036,7 +2036,7 @@ void SDL_DefaultAudioDeviceChanged(SDL_AudioDevice *new_default_device) if (needs_migration) { const SDL_bool spec_changed = !AUDIO_SPECS_EQUAL(current_default_device->spec, new_default_device->spec); SDL_LogicalAudioDevice *next = NULL; - for (SDL_LogicalAudioDevice *logdev = current_default_device->logical_devices; logdev != NULL; logdev = next) { + for (SDL_LogicalAudioDevice *logdev = current_default_device->logical_devices; logdev; logdev = next) { next = logdev->next; if (!logdev->opened_as_default) { @@ -2083,7 +2083,7 @@ void SDL_DefaultAudioDeviceChanged(SDL_AudioDevice *new_default_device) UpdateAudioStreamFormatsPhysical(current_default_device); UpdateAudioStreamFormatsPhysical(new_default_device); - if (current_default_device->logical_devices == NULL) { // nothing left on the current physical device, close it. + if (!current_default_device->logical_devices) { // nothing left on the current physical device, close it. // !!! FIXME: we _need_ to release this lock, but doing so can cause a race condition if someone opens a device while we're closing it. RefPhysicalAudioDevice(current_default_device); // hold a temp ref for a moment while we release... ReleaseAudioDevice(current_default_device); // can't hold the lock or the audio thread will deadlock while we WaitThread it. @@ -2105,8 +2105,8 @@ void SDL_DefaultAudioDeviceChanged(SDL_AudioDevice *new_default_device) if (pending.next) { SDL_LockRWLockForWriting(current_audio.device_hash_lock); - SDL_assert(current_audio.pending_events_tail != NULL); - SDL_assert(current_audio.pending_events_tail->next == NULL); + SDL_assert(current_audio.pending_events_tail); + SDL_assert(!current_audio.pending_events_tail->next); current_audio.pending_events_tail->next = pending.next; current_audio.pending_events_tail = pending_tail; SDL_UnlockRWLock(current_audio.device_hash_lock); @@ -2173,7 +2173,7 @@ int SDL_AudioDeviceFormatChangedAlreadyLocked(SDL_AudioDevice *device, const SDL pending_tail = p; } - for (SDL_LogicalAudioDevice *logdev = device->logical_devices; logdev != NULL; logdev = logdev->next) { + for (SDL_LogicalAudioDevice *logdev = device->logical_devices; logdev; logdev = logdev->next) { p = (SDL_PendingAudioDeviceEvent *)SDL_malloc(sizeof(SDL_PendingAudioDeviceEvent)); if (p) { // if this failed, no event for you, but you have deeper problems anyhow. p->type = SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED; @@ -2186,8 +2186,8 @@ int SDL_AudioDeviceFormatChangedAlreadyLocked(SDL_AudioDevice *device, const SDL if (pending.next) { SDL_LockRWLockForWriting(current_audio.device_hash_lock); - SDL_assert(current_audio.pending_events_tail != NULL); - SDL_assert(current_audio.pending_events_tail->next == NULL); + SDL_assert(current_audio.pending_events_tail); + SDL_assert(!current_audio.pending_events_tail->next); current_audio.pending_events_tail->next = pending.next; current_audio.pending_events_tail = pending_tail; SDL_UnlockRWLock(current_audio.device_hash_lock); @@ -2225,7 +2225,7 @@ void SDL_UpdateAudio(void) SDL_UnlockRWLock(current_audio.device_hash_lock); SDL_PendingAudioDeviceEvent *pending_next = NULL; - for (SDL_PendingAudioDeviceEvent *i = pending_events; i != NULL; i = pending_next) { + for (SDL_PendingAudioDeviceEvent *i = pending_events; i; i = pending_next) { pending_next = i->next; if (SDL_EventEnabled(i->type)) { SDL_Event event; diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c index f4eb332a2..ed93684f2 100644 --- a/src/audio/SDL_audiocvt.c +++ b/src/audio/SDL_audiocvt.c @@ -221,8 +221,8 @@ static SDL_bool SDL_IsSupportedChannelCount(const int channels) void ConvertAudio(int num_frames, const void *src, SDL_AudioFormat src_format, int src_channels, void *dst, SDL_AudioFormat dst_format, int dst_channels, void* scratch) { - SDL_assert(src != NULL); - SDL_assert(dst != NULL); + SDL_assert(src); + SDL_assert(dst); SDL_assert(SDL_IsSupportedAudioFormat(src_format)); SDL_assert(SDL_IsSupportedAudioFormat(dst_format)); SDL_assert(SDL_IsSupportedChannelCount(src_channels)); @@ -278,7 +278,7 @@ void ConvertAudio(int num_frames, const void *src, SDL_AudioFormat src_format, i } } - if (scratch == NULL) { + if (!scratch) { scratch = dst; } @@ -313,7 +313,7 @@ void ConvertAudio(int num_frames, const void *src, SDL_AudioFormat src_format, i SDL_assert(dst_channels <= SDL_arraysize(channel_converters[0])); channel_converter = channel_converters[src_channels - 1][dst_channels - 1]; - SDL_assert(channel_converter != NULL); + SDL_assert(channel_converter); // swap in some SIMD versions for a few of these. if (channel_converter == SDL_ConvertStereoToMono) { @@ -408,7 +408,7 @@ SDL_AudioStream *SDL_CreateAudioStream(const SDL_AudioSpec *src_spec, const SDL_ SDL_SetupAudioResampler(); SDL_AudioStream *retval = (SDL_AudioStream *)SDL_calloc(1, sizeof(SDL_AudioStream)); - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); return NULL; } @@ -416,13 +416,13 @@ SDL_AudioStream *SDL_CreateAudioStream(const SDL_AudioSpec *src_spec, const SDL_ retval->freq_ratio = 1.0f; retval->queue = SDL_CreateAudioQueue(4096); - if (retval->queue == NULL) { + if (!retval->queue) { SDL_free(retval); return NULL; } retval->lock = SDL_CreateMutex(); - if (retval->lock == NULL) { + if (!retval->lock) { SDL_free(retval->queue); SDL_free(retval); return NULL; @@ -632,9 +632,9 @@ int SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len) SDL_Log("AUDIOSTREAM: wants to put %d bytes", len); #endif - if (stream == NULL) { + if (!stream) { return SDL_InvalidParamError("stream"); - } else if (buf == NULL) { + } else if (!buf) { return SDL_InvalidParamError("buf"); } else if (len < 0) { return SDL_InvalidParamError("len"); @@ -669,7 +669,7 @@ int SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len) size_t chunk_size = SDL_GetAudioQueueChunkSize(stream->queue); track = SDL_CreateChunkedAudioTrack(&src_spec, buf, len, chunk_size); - if (track == NULL) { + if (!track) { return -1; } @@ -680,7 +680,7 @@ int SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len) int retval = 0; - if (track != NULL) { + if (track) { SDL_AddTrackToAudioQueue(stream->queue, track); } else { retval = SDL_WriteToAudioQueue(stream->queue, &stream->src_spec, buf, len); @@ -701,7 +701,7 @@ int SDL_PutAudioStreamData(SDL_AudioStream *stream, const void *buf, int len) int SDL_FlushAudioStream(SDL_AudioStream *stream) { - if (stream == NULL) { + if (!stream) { return SDL_InvalidParamError("stream"); } @@ -721,7 +721,7 @@ static Uint8 *EnsureAudioStreamWorkBufferSize(SDL_AudioStream *stream, size_t ne } Uint8 *ptr = (Uint8 *) SDL_aligned_alloc(SDL_SIMDGetAlignment(), newlen); - if (ptr == NULL) { + if (!ptr) { SDL_OutOfMemory(); return NULL; // previous work buffer is still valid! } @@ -741,7 +741,7 @@ static void UpdateAudioStreamHistoryBuffer(SDL_AudioStream* stream, Uint8 *history_buffer = stream->history_buffer; int history_bytes = history_buffer_frames * SDL_AUDIO_FRAMESIZE(stream->input_spec); - if (left_padding != NULL) { + if (left_padding) { // Fill in the left padding using the history buffer SDL_assert(padding_bytes <= history_bytes); SDL_memcpy(left_padding, history_buffer + history_bytes - padding_bytes, padding_bytes); @@ -835,7 +835,7 @@ static Sint64 GetAudioStreamHead(SDL_AudioStream* stream, SDL_AudioSpec* out_spe { void* iter = SDL_BeginAudioQueueIter(stream->queue); - if (iter == NULL) { + if (!iter) { SDL_zerop(out_spec); *out_flushed = SDL_FALSE; return 0; @@ -1025,9 +1025,9 @@ int SDL_GetAudioStreamData(SDL_AudioStream *stream, void *voidbuf, int len) SDL_Log("AUDIOSTREAM: want to get %d converted bytes", len); #endif - if (stream == NULL) { + if (!stream) { return SDL_InvalidParamError("stream"); - } else if (buf == NULL) { + } else if (!buf) { return SDL_InvalidParamError("buf"); } else if (len < 0) { return SDL_InvalidParamError("len"); @@ -1160,7 +1160,7 @@ int SDL_GetAudioStreamQueued(SDL_AudioStream *stream) int SDL_ClearAudioStream(SDL_AudioStream *stream) { - if (stream == NULL) { + if (!stream) { return SDL_InvalidParamError("stream"); } @@ -1177,7 +1177,7 @@ int SDL_ClearAudioStream(SDL_AudioStream *stream) void SDL_DestroyAudioStream(SDL_AudioStream *stream) { - if (stream == NULL) { + if (!stream) { return; } @@ -1214,13 +1214,13 @@ int SDL_ConvertAudioSamples(const SDL_AudioSpec *src_spec, const Uint8 *src_data *dst_len = 0; } - if (src_data == NULL) { + if (!src_data) { return SDL_InvalidParamError("src_data"); } else if (src_len < 0) { return SDL_InvalidParamError("src_len"); - } else if (dst_data == NULL) { + } else if (!dst_data) { return SDL_InvalidParamError("dst_data"); - } else if (dst_len == NULL) { + } else if (!dst_len) { return SDL_InvalidParamError("dst_len"); } @@ -1229,7 +1229,7 @@ int SDL_ConvertAudioSamples(const SDL_AudioSpec *src_spec, const Uint8 *src_data int dstlen = 0; SDL_AudioStream *stream = SDL_CreateAudioStream(src_spec, dst_spec); - if (stream != NULL) { + if (stream) { if ((SDL_PutAudioStreamData(stream, src_data, src_len) == 0) && (SDL_FlushAudioStream(stream) == 0)) { dstlen = SDL_GetAudioStreamAvailable(stream); if (dstlen >= 0) { diff --git a/src/audio/SDL_audiodev.c b/src/audio/SDL_audiodev.c index f00b8590d..f49a9fe7f 100644 --- a/src/audio/SDL_audiodev.c +++ b/src/audio/SDL_audiodev.c @@ -80,16 +80,16 @@ static void SDL_EnumUnixAudioDevices_Internal(const SDL_bool iscapture, const SD 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 = SDL_PATH_DEV_AUDIO; } else { diff --git a/src/audio/SDL_audioqueue.c b/src/audio/SDL_audioqueue.c index c27bb4094..37a2f8457 100644 --- a/src/audio/SDL_audioqueue.c +++ b/src/audio/SDL_audioqueue.c @@ -92,7 +92,7 @@ static SDL_AudioChunk *CreateAudioChunk(size_t chunk_size) { SDL_AudioChunk *chunk = (SDL_AudioChunk *)SDL_malloc(sizeof(*chunk) + chunk_size); - if (chunk == NULL) { + if (!chunk) { return NULL; } @@ -146,14 +146,14 @@ static int WriteToChunkedAudioTrack(void *ctx, const Uint8 *data, size_t len) SDL_AudioChunk *chunk = track->tail; // Handle the first chunk - if (chunk == NULL) { + if (!chunk) { chunk = CreateAudioTrackChunk(track); - if (chunk == NULL) { + if (!chunk) { return SDL_OutOfMemory(); } - SDL_assert((track->head == NULL) && (track->tail == NULL) && (track->queued_bytes == 0)); + SDL_assert((!track->head) && (!track->tail) && (track->queued_bytes == 0)); track->head = chunk; track->tail = chunk; } @@ -180,7 +180,7 @@ static int WriteToChunkedAudioTrack(void *ctx, const Uint8 *data, size_t len) } // Roll back the changes if we couldn't write all the data - if (chunk == NULL) { + if (!chunk) { chunk = track->tail; SDL_AudioChunk *next = chunk->next; @@ -255,7 +255,7 @@ static SDL_AudioTrack *CreateChunkedAudioTrack(const SDL_AudioSpec *spec, size_t { SDL_ChunkedAudioTrack *track = (SDL_ChunkedAudioTrack *)SDL_calloc(1, sizeof(*track)); - if (track == NULL) { + if (!track) { SDL_OutOfMemory(); return NULL; } @@ -275,7 +275,7 @@ SDL_AudioQueue *SDL_CreateAudioQueue(size_t chunk_size) { SDL_AudioQueue *queue = (SDL_AudioQueue *)SDL_calloc(1, sizeof(*queue)); - if (queue == NULL) { + if (!queue) { SDL_OutOfMemory(); return NULL; } @@ -338,7 +338,7 @@ void SDL_PopAudioQueueHead(SDL_AudioQueue *queue) queue->head = track; - if (track == NULL) { + if (!track) { queue->tail = NULL; } } @@ -352,7 +352,7 @@ SDL_AudioTrack *SDL_CreateChunkedAudioTrack(const SDL_AudioSpec *spec, const Uin { SDL_AudioTrack *track = CreateChunkedAudioTrack(spec, chunk_size); - if (track == NULL) { + if (!track) { return NULL; } @@ -390,14 +390,14 @@ int SDL_WriteToAudioQueue(SDL_AudioQueue *queue, const SDL_AudioSpec *spec, cons SDL_AudioTrack *track = queue->tail; - if ((track != NULL) && !AUDIO_SPECS_EQUAL(track->spec, *spec)) { + if ((track) && !AUDIO_SPECS_EQUAL(track->spec, *spec)) { SDL_FlushAudioTrack(track); } - if ((track == NULL) || (track->write == NULL)) { + if ((!track) || (!track->write)) { SDL_AudioTrack *new_track = CreateChunkedAudioTrack(spec, queue->chunk_size); - if (new_track == NULL) { + if (!new_track) { return SDL_OutOfMemory(); } @@ -423,7 +423,7 @@ void *SDL_BeginAudioQueueIter(SDL_AudioQueue *queue) size_t SDL_NextAudioQueueIter(SDL_AudioQueue *queue, void **inout_iter, SDL_AudioSpec *out_spec, SDL_bool *out_flushed) { SDL_AudioTrack *iter = *inout_iter; - SDL_assert(iter != NULL); + SDL_assert(iter); SDL_copyp(out_spec, &iter->spec); @@ -462,7 +462,7 @@ int SDL_ReadFromAudioQueue(SDL_AudioQueue *queue, Uint8 *data, size_t len) SDL_AudioTrack *track = queue->head; for (;;) { - if (track == NULL) { + if (!track) { return SDL_SetError("Reading past end of queue"); } @@ -478,7 +478,7 @@ int SDL_ReadFromAudioQueue(SDL_AudioQueue *queue, Uint8 *data, size_t len) SDL_AudioTrack *next = track->next; - if (next == NULL) { + if (!next) { return SDL_SetError("Reading past end of incomplete track"); } @@ -495,7 +495,7 @@ int SDL_PeekIntoAudioQueue(SDL_AudioQueue *queue, Uint8 *data, size_t len) SDL_AudioTrack *track = queue->head; for (;;) { - if (track == NULL) { + if (!track) { return SDL_SetError("Peeking past end of queue"); } diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c index 3701a4320..76785cf91 100644 --- a/src/audio/SDL_wave.c +++ b/src/audio/SDL_wave.c @@ -262,7 +262,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; @@ -439,7 +439,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; @@ -682,7 +682,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(); } @@ -1073,12 +1073,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(); } @@ -1233,7 +1233,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; @@ -1364,7 +1364,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(); } @@ -1440,7 +1440,7 @@ static WaveRiffSizeHint WaveGetRiffSizeHint(void) { 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) { @@ -1459,7 +1459,7 @@ static WaveTruncationHint WaveGetTruncationHint(void) { 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) { @@ -1478,7 +1478,7 @@ static WaveFactChunkHint WaveGetFactChunkHint(void) { 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) { @@ -1495,7 +1495,7 @@ static WaveFactChunkHint WaveGetFactChunkHint(void) static void WaveFreeChunkData(WaveChunk *chunk) { - if (chunk->data != NULL) { + if (chunk->data) { SDL_free(chunk->data); chunk->data = NULL; } @@ -1544,7 +1544,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(); } @@ -1610,7 +1610,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(); } @@ -1788,7 +1788,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; @@ -2081,15 +2081,15 @@ int SDL_LoadWAV_RW(SDL_RWops *src, SDL_bool freesrc, SDL_AudioSpec *spec, Uint8 WaveFile file; /* Make sure we are passed a valid data source */ - if (src == NULL) { + if (!src) { goto done; /* Error may come from RWops. */ - } else if (spec == NULL) { + } else if (!spec) { SDL_InvalidParamError("spec"); goto done; - } else if (audio_buf == NULL) { + } else if (!audio_buf) { SDL_InvalidParamError("audio_buf"); goto done; - } else if (audio_len == NULL) { + } else if (!audio_len) { SDL_InvalidParamError("audio_len"); goto done; } diff --git a/src/audio/aaudio/SDL_aaudio.c b/src/audio/aaudio/SDL_aaudio.c index 9d9c98b8e..668ffac05 100644 --- a/src/audio/aaudio/SDL_aaudio.c +++ b/src/audio/aaudio/SDL_aaudio.c @@ -282,7 +282,7 @@ static int BuildAAudioStream(SDL_AudioDevice *device) if (res != AAUDIO_OK) { LOGI("SDL Failed AAudio_createStreamBuilder %d", res); return SDL_SetError("SDL Failed AAudio_createStreamBuilder %d", res); - } else if (builder == NULL) { + } else if (!builder) { LOGI("SDL Failed AAudio_createStreamBuilder - builder NULL"); return SDL_SetError("SDL Failed AAudio_createStreamBuilder - builder NULL"); } @@ -354,7 +354,7 @@ static int BuildAAudioStream(SDL_AudioDevice *device) hidden->num_buffers = 2; hidden->mixbuf_bytes = (hidden->num_buffers * device->buffer_size); hidden->mixbuf = (Uint8 *)SDL_aligned_alloc(SDL_SIMDGetAlignment(), hidden->mixbuf_bytes); - if (hidden->mixbuf == NULL) { + if (!hidden->mixbuf) { return SDL_OutOfMemory(); } hidden->processed_bytes = 0; @@ -384,7 +384,7 @@ static int BuildAAudioStream(SDL_AudioDevice *device) static int AAUDIO_OpenDevice(SDL_AudioDevice *device) { #if ALLOW_MULTIPLE_ANDROID_AUDIO_DEVICES - SDL_assert(device->handle != NULL); // AAUDIO_UNSPECIFIED is zero, so legit devices should all be non-zero. + SDL_assert(device->handle); // AAUDIO_UNSPECIFIED is zero, so legit devices should all be non-zero. #endif LOGI(__func__); @@ -397,7 +397,7 @@ static int AAUDIO_OpenDevice(SDL_AudioDevice *device) } device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden)); - if (device->hidden == NULL) { + if (!device->hidden) { return SDL_OutOfMemory(); } @@ -407,7 +407,7 @@ static int AAUDIO_OpenDevice(SDL_AudioDevice *device) static SDL_bool PauseOneDevice(SDL_AudioDevice *device, void *userdata) { struct SDL_PrivateAudioData *hidden = (struct SDL_PrivateAudioData *)device->hidden; - if (hidden != NULL) { + if (hidden) { if (hidden->stream) { aaudio_result_t res; @@ -433,7 +433,7 @@ static SDL_bool PauseOneDevice(SDL_AudioDevice *device, void *userdata) // Pause (block) all non already paused audio devices by taking their mixer lock void AAUDIO_PauseDevices(void) { - if (ctx.handle != NULL) { // AAUDIO driver is used? + if (ctx.handle) { // AAUDIO driver is used? (void) SDL_FindPhysicalAudioDeviceByCallback(PauseOneDevice, NULL); } } @@ -442,7 +442,7 @@ void AAUDIO_PauseDevices(void) static SDL_bool ResumeOneDevice(SDL_AudioDevice *device, void *userdata) { struct SDL_PrivateAudioData *hidden = device->hidden; - if (hidden != NULL) { + if (hidden) { if (hidden->resume) { hidden->resume = SDL_FALSE; SDL_UnlockMutex(device->lock); @@ -461,7 +461,7 @@ static SDL_bool ResumeOneDevice(SDL_AudioDevice *device, void *userdata) void AAUDIO_ResumeDevices(void) { - if (ctx.handle != NULL) { // AAUDIO driver is used? + if (ctx.handle) { // AAUDIO driver is used? (void) SDL_FindPhysicalAudioDeviceByCallback(ResumeOneDevice, NULL); } } @@ -495,7 +495,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); return SDL_FALSE; } diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index 4a076419f..71977c23f 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -96,7 +96,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; } @@ -165,7 +165,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; } @@ -174,9 +174,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 { @@ -224,12 +224,12 @@ static const ALSA_Device default_capture_handle = { static const char *get_audio_device(void *handle, const int channels) { - SDL_assert(handle != NULL); // SDL2 used NULL to mean "default" but that's not true in SDL3. + SDL_assert(handle); // SDL2 used NULL to mean "default" but that's not true in SDL3. ALSA_Device *dev = (ALSA_Device *)handle; if (SDL_strcmp(dev->name, "default") == 0) { const char *device = SDL_getenv("AUDIODEV"); // Is there a standard variable name? - if (device != NULL) { + if (device) { return device; } else if (channels == 6) { return "plug:surround51"; @@ -536,7 +536,7 @@ static int ALSA_OpenDevice(SDL_AudioDevice *device) // Initialize all variables that we clean on shutdown device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden)); - if (device->hidden == NULL) { + if (!device->hidden) { return SDL_OutOfMemory(); } @@ -682,7 +682,7 @@ static int ALSA_OpenDevice(SDL_AudioDevice *device) // Allocate mixing buffer if (!iscapture) { device->hidden->mixbuf = (Uint8 *)SDL_malloc(device->buffer_size); - if (device->hidden->mixbuf == NULL) { + if (!device->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(device->hidden->mixbuf, device->silence_value, device->buffer_size); @@ -705,7 +705,7 @@ static void add_device(const SDL_bool iscapture, const char *name, void *hint, A char *desc; char *ptr; - if (dev == NULL) { + if (!dev) { return; } @@ -715,7 +715,7 @@ static void add_device(const SDL_bool iscapture, const char *name, void *hint, A // 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; } @@ -723,13 +723,13 @@ static void add_device(const SDL_bool iscapture, const char *name, void *hint, A 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'; } @@ -784,7 +784,7 @@ static void ALSA_HotplugIteration(SDL_bool *has_default_output, SDL_bool *has_de // if we can find a preferred prefix for the system. for (int i = 0; hints[i]; i++) { char *name = ALSA_snd_device_name_get_hint(hints[i], "NAME"); - if (name == NULL) { + if (!name) { continue; } @@ -813,16 +813,16 @@ static void ALSA_HotplugIteration(SDL_bool *has_default_output, SDL_bool *has_de if (match || (has_default >= 0)) { // did we find a device name prefix we like at all...? for (int i = 0; hints[i]; i++) { char *name = ALSA_snd_device_name_get_hint(hints[i], "NAME"); - if (name == NULL) { + if (!name) { continue; } // only want physical hardware interfaces const SDL_bool is_default = (has_default == i); - if (is_default || (match != NULL && SDL_strncmp(name, match, match_len) == 0)) { + if (is_default || (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; @@ -942,7 +942,7 @@ static void ALSA_DeinitializeStart(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; diff --git a/src/audio/android/SDL_androidaudio.c b/src/audio/android/SDL_androidaudio.c index cd0a94264..b2147f336 100644 --- a/src/audio/android/SDL_androidaudio.c +++ b/src/audio/android/SDL_androidaudio.c @@ -42,7 +42,7 @@ static SDL_AudioDevice *captureDevice = NULL; static int ANDROIDAUDIO_OpenDevice(SDL_AudioDevice *device) { device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden)); - if (device->hidden == NULL) { + if (!device->hidden) { return SDL_OutOfMemory(); } @@ -131,13 +131,13 @@ void ANDROIDAUDIO_PauseDevices(void) { // TODO: Handle multiple devices? struct SDL_PrivateAudioData *hidden; - if (audioDevice != NULL && audioDevice->hidden != NULL) { + if (audioDevice && audioDevice->hidden) { hidden = (struct SDL_PrivateAudioData *)audioDevice->hidden; SDL_LockMutex(audioDevice->lock); hidden->resume = SDL_TRUE; } - if (captureDevice != NULL && captureDevice->hidden != NULL) { + if (captureDevice && captureDevice->hidden) { hidden = (struct SDL_PrivateAudioData *)captureDevice->hidden; SDL_LockMutex(captureDevice->lock); hidden->resume = SDL_TRUE; @@ -149,7 +149,7 @@ void ANDROIDAUDIO_ResumeDevices(void) { // TODO: Handle multiple devices? struct SDL_PrivateAudioData *hidden; - if (audioDevice != NULL && audioDevice->hidden != NULL) { + if (audioDevice && audioDevice->hidden) { hidden = (struct SDL_PrivateAudioData *)audioDevice->hidden; if (hidden->resume) { hidden->resume = SDL_FALSE; @@ -157,7 +157,7 @@ void ANDROIDAUDIO_ResumeDevices(void) } } - if (captureDevice != NULL && captureDevice->hidden != NULL) { + if (captureDevice && captureDevice->hidden) { hidden = (struct SDL_PrivateAudioData *)captureDevice->hidden; if (hidden->resume) { hidden->resume = SDL_FALSE; diff --git a/src/audio/directsound/SDL_directsound.c b/src/audio/directsound/SDL_directsound.c index 74fc522be..dc869bc46 100644 --- a/src/audio/directsound/SDL_directsound.c +++ b/src/audio/directsound/SDL_directsound.c @@ -62,7 +62,7 @@ static void DSOUND_Unload(void) pDirectSoundCaptureEnumerateW = NULL; pGetDeviceID = NULL; - if (DSoundDLL != NULL) { + if (DSoundDLL) { SDL_UnloadObject(DSoundDLL); DSoundDLL = NULL; } @@ -75,7 +75,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... @@ -176,7 +176,7 @@ static BOOL CALLBACK FindAllDevs(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVO FindAllDevsData *data = (FindAllDevsData *) userdata; if (guid != NULL) { // skip default device char *str = WIN_LookupAudioDeviceName(desc, guid); - if (str != NULL) { + if (str) { LPGUID cpyguid = (LPGUID)SDL_malloc(sizeof(GUID)); if (cpyguid) { SDL_copyp(cpyguid, guid); @@ -358,7 +358,7 @@ static int DSOUND_CaptureFromDevice(SDL_AudioDevice *device, void *buffer, int b } SDL_assert(ptr1len == (DWORD)buflen); - SDL_assert(ptr2 == NULL); + SDL_assert(!ptr2); SDL_assert(ptr2len == 0); SDL_memcpy(buffer, ptr1, ptr1len); @@ -384,18 +384,18 @@ static void DSOUND_FlushCapture(SDL_AudioDevice *device) static void DSOUND_CloseDevice(SDL_AudioDevice *device) { if (device->hidden) { - if (device->hidden->mixbuf != NULL) { + if (device->hidden->mixbuf) { IDirectSoundBuffer_Stop(device->hidden->mixbuf); IDirectSoundBuffer_Release(device->hidden->mixbuf); } - if (device->hidden->sound != NULL) { + if (device->hidden->sound) { IDirectSound_Release(device->hidden->sound); } - if (device->hidden->capturebuf != NULL) { + if (device->hidden->capturebuf) { IDirectSoundCaptureBuffer_Stop(device->hidden->capturebuf); IDirectSoundCaptureBuffer_Release(device->hidden->capturebuf); } - if (device->hidden->capture != NULL) { + if (device->hidden->capture) { IDirectSoundCapture_Release(device->hidden->capture); } SDL_free(device->hidden); @@ -491,7 +491,7 @@ static int DSOUND_OpenDevice(SDL_AudioDevice *device) { // Initialize all variables that we clean on shutdown device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden)); - if (device->hidden == NULL) { + if (!device->hidden) { return SDL_OutOfMemory(); } diff --git a/src/audio/disk/SDL_diskaudio.c b/src/audio/disk/SDL_diskaudio.c index 69d2d6d35..bdcb8b3be 100644 --- a/src/audio/disk/SDL_diskaudio.c +++ b/src/audio/disk/SDL_diskaudio.c @@ -87,7 +87,7 @@ static void DISKAUDIO_FlushCapture(SDL_AudioDevice *device) static void DISKAUDIO_CloseDevice(SDL_AudioDevice *device) { if (device->hidden) { - if (device->hidden->io != NULL) { + if (device->hidden->io) { SDL_RWclose(device->hidden->io); } SDL_free(device->hidden->mixbuf); @@ -99,7 +99,7 @@ static void DISKAUDIO_CloseDevice(SDL_AudioDevice *device) static const char *get_filename(const SDL_bool iscapture) { const char *devname = SDL_getenv(iscapture ? DISKENVR_INFILE : DISKENVR_OUTFILE); - if (devname == NULL) { + if (!devname) { devname = iscapture ? DISKDEFAULT_INFILE : DISKDEFAULT_OUTFILE; } return devname; @@ -112,11 +112,11 @@ static int DISKAUDIO_OpenDevice(SDL_AudioDevice *device) const char *envr = SDL_getenv(DISKENVR_IODELAY); device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden)); - if (device->hidden == NULL) { + if (!device->hidden) { return SDL_OutOfMemory(); } - if (envr != NULL) { + if (envr) { device->hidden->io_delay = SDL_atoi(envr); } else { device->hidden->io_delay = ((device->sample_frames * 1000) / device->spec.freq); @@ -124,14 +124,14 @@ static int DISKAUDIO_OpenDevice(SDL_AudioDevice *device) // Open the "audio device" device->hidden->io = SDL_RWFromFile(fname, iscapture ? "rb" : "wb"); - if (device->hidden->io == NULL) { + if (!device->hidden->io) { return -1; } // Allocate mixing buffer if (!iscapture) { device->hidden->mixbuf = (Uint8 *)SDL_malloc(device->buffer_size); - if (device->hidden->mixbuf == NULL) { + if (!device->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(device->hidden->mixbuf, device->silence_value, device->buffer_size); diff --git a/src/audio/dsp/SDL_dspaudio.c b/src/audio/dsp/SDL_dspaudio.c index 8178d52a2..9a2c918be 100644 --- a/src/audio/dsp/SDL_dspaudio.c +++ b/src/audio/dsp/SDL_dspaudio.c @@ -70,7 +70,7 @@ static int DSP_OpenDevice(SDL_AudioDevice *device) // Initialize all variables that we clean on shutdown device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden)); - if (device->hidden == NULL) { + if (!device->hidden) { return SDL_OutOfMemory(); } @@ -191,7 +191,7 @@ static int DSP_OpenDevice(SDL_AudioDevice *device) // Allocate mixing buffer if (!device->iscapture) { device->hidden->mixbuf = (Uint8 *)SDL_malloc(device->buffer_size); - if (device->hidden->mixbuf == NULL) { + if (!device->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(device->hidden->mixbuf, device->silence_value, device->buffer_size); diff --git a/src/audio/emscripten/SDL_emscriptenaudio.c b/src/audio/emscripten/SDL_emscriptenaudio.c index 51eec747e..64b195221 100644 --- a/src/audio/emscripten/SDL_emscriptenaudio.c +++ b/src/audio/emscripten/SDL_emscriptenaudio.c @@ -177,7 +177,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(SDL_AudioDevice *device) // Initialize all variables that we clean on shutdown device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden)); - if (device->hidden == NULL) { + if (!device->hidden) { return SDL_OutOfMemory(); } @@ -188,7 +188,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(SDL_AudioDevice *device) if (!device->iscapture) { device->hidden->mixbuf = (Uint8 *)SDL_malloc(device->buffer_size); - if (device->hidden->mixbuf == NULL) { + if (!device->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(device->hidden->mixbuf, device->silence_value, device->buffer_size); diff --git a/src/audio/haiku/SDL_haikuaudio.cc b/src/audio/haiku/SDL_haikuaudio.cc index 5772fbe05..1c2237213 100644 --- a/src/audio/haiku/SDL_haikuaudio.cc +++ b/src/audio/haiku/SDL_haikuaudio.cc @@ -39,7 +39,7 @@ extern "C" static Uint8 *HAIKUAUDIO_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size) { - SDL_assert(device->hidden->current_buffer != NULL); + SDL_assert(device->hidden->current_buffer); SDL_assert(device->hidden->current_buffer_len > 0); *buffer_size = device->hidden->current_buffer_len; return device->hidden->current_buffer; @@ -48,7 +48,7 @@ static Uint8 *HAIKUAUDIO_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size) static int HAIKUAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buffer_size) { // We already wrote our output right into the BSoundPlayer's callback's stream. Just clean up our stuff. - SDL_assert(device->hidden->current_buffer != NULL); + SDL_assert(device->hidden->current_buffer); SDL_assert(device->hidden->current_buffer_len > 0); device->hidden->current_buffer = NULL; device->hidden->current_buffer_len = 0; @@ -59,7 +59,7 @@ static int HAIKUAUDIO_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, i static void FillSound(void *data, void *stream, size_t len, const media_raw_audio_format & format) { SDL_AudioDevice *device = (SDL_AudioDevice *)data; - SDL_assert(device->hidden->current_buffer == NULL); + SDL_assert(!device->hidden->current_buffer); SDL_assert(device->hidden->current_buffer_len == 0); device->hidden->current_buffer = (Uint8 *) stream; device->hidden->current_buffer_len = (int) len; diff --git a/src/audio/jack/SDL_jackaudio.c b/src/audio/jack/SDL_jackaudio.c index 77e2f03fa..78a3dac30 100644 --- a/src/audio/jack/SDL_jackaudio.c +++ b/src/audio/jack/SDL_jackaudio.c @@ -57,7 +57,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; } @@ -72,7 +72,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; } @@ -81,9 +81,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 { @@ -296,18 +296,18 @@ static int JACK_OpenDevice(SDL_AudioDevice *device) // Initialize all variables that we clean on shutdown device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden)); - if (device->hidden == NULL) { + if (!device->hidden) { return SDL_OutOfMemory(); } client = JACK_jack_client_open(GetJackAppName(), JackNoStartServer, &status, NULL); device->hidden->client = client; - if (client == NULL) { + if (!client) { return SDL_SetError("Can't open JACK client"); } devports = JACK_jack_get_ports(client, NULL, NULL, JackPortIsPhysical | sysportflags); - if (devports == NULL || !devports[0]) { + if (!devports || !devports[0]) { return SDL_SetError("No physical JACK ports available"); } @@ -349,7 +349,7 @@ static int JACK_OpenDevice(SDL_AudioDevice *device) // Build SDL's ports, which we will connect to the device ports. device->hidden->sdlports = (jack_port_t **)SDL_calloc(channels, sizeof(jack_port_t *)); - if (device->hidden->sdlports == NULL) { + if (!device->hidden->sdlports) { SDL_free(audio_ports); return SDL_OutOfMemory(); } @@ -414,7 +414,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; } diff --git a/src/audio/n3ds/SDL_n3dsaudio.c b/src/audio/n3ds/SDL_n3dsaudio.c index c0bb1a242..a515d07d0 100644 --- a/src/audio/n3ds/SDL_n3dsaudio.c +++ b/src/audio/n3ds/SDL_n3dsaudio.c @@ -83,7 +83,7 @@ static int N3DSAUDIO_OpenDevice(SDL_AudioDevice *device) float mix[12]; device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden)); - if (device->hidden == NULL) { + if (!device->hidden) { return SDL_OutOfMemory(); } @@ -134,14 +134,14 @@ static int N3DSAUDIO_OpenDevice(SDL_AudioDevice *device) } device->hidden->mixbuf = (Uint8 *)SDL_malloc(device->buffer_size); - if (device->hidden->mixbuf == NULL) { + if (!device->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(device->hidden->mixbuf, device->silence_value, device->buffer_size); data_vaddr = (Uint8 *)linearAlloc(device->buffer_size * NUM_BUFFERS); - if (data_vaddr == NULL) { + if (!data_vaddr) { return SDL_OutOfMemory(); } diff --git a/src/audio/netbsd/SDL_netbsdaudio.c b/src/audio/netbsd/SDL_netbsdaudio.c index ca95a3a16..c5f97eb10 100644 --- a/src/audio/netbsd/SDL_netbsdaudio.c +++ b/src/audio/netbsd/SDL_netbsdaudio.c @@ -215,7 +215,7 @@ static int NETBSDAUDIO_OpenDevice(SDL_AudioDevice *device) // Initialize all variables that we clean on shutdown device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden)); - if (device->hidden == NULL) { + if (!device->hidden) { return SDL_OutOfMemory(); } @@ -293,7 +293,7 @@ static int NETBSDAUDIO_OpenDevice(SDL_AudioDevice *device) // Allocate mixing buffer device->hidden->mixlen = device->buffer_size; device->hidden->mixbuf = (Uint8 *)SDL_malloc(device->hidden->mixlen); - if (device->hidden->mixbuf == NULL) { + if (!device->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(device->hidden->mixbuf, device->silence_value, device->buffer_size); diff --git a/src/audio/openslES/SDL_openslES.c b/src/audio/openslES/SDL_openslES.c index 5b7112b20..22bec9dd6 100644 --- a/src/audio/openslES/SDL_openslES.c +++ b/src/audio/openslES/SDL_openslES.c @@ -327,7 +327,7 @@ static int OPENSLES_CreatePCMRecorder(SDL_AudioDevice *device) // Create the sound buffers audiodata->mixbuff = (Uint8 *)SDL_malloc(NUM_BUFFERS * device->buffer_size); - if (audiodata->mixbuff == NULL) { + if (!audiodata->mixbuff) { LOGE("mixbuffer allocate - out of memory"); goto failed; } @@ -574,7 +574,7 @@ static int OPENSLES_CreatePCMPlayer(SDL_AudioDevice *device) // Create the sound buffers audiodata->mixbuff = (Uint8 *)SDL_malloc(NUM_BUFFERS * device->buffer_size); - if (audiodata->mixbuff == NULL) { + if (!audiodata->mixbuff) { LOGE("mixbuffer allocate - out of memory"); goto failed; } @@ -599,7 +599,7 @@ failed: static int OPENSLES_OpenDevice(SDL_AudioDevice *device) { device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden)); - if (device->hidden == NULL) { + if (!device->hidden) { return SDL_OutOfMemory(); } diff --git a/src/audio/pipewire/SDL_pipewire.c b/src/audio/pipewire/SDL_pipewire.c index 9c46d770b..2e5586eb8 100644 --- a/src/audio/pipewire/SDL_pipewire.c +++ b/src/audio/pipewire/SDL_pipewire.c @@ -126,7 +126,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; } @@ -142,7 +142,7 @@ static int pipewire_dlsym(const char *fn, void **addr) static int load_pipewire_library(void) { pipewire_handle = SDL_LoadObject(pipewire_library); - return pipewire_handle != NULL ? 0 : -1; + return pipewire_handle ? 0 : -1; } static void unload_pipewire_library(void) @@ -404,7 +404,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; } @@ -623,16 +623,16 @@ 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; change_default_device(pipewire_default_sink_id); } 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); @@ -678,7 +678,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; } @@ -687,7 +687,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; @@ -708,7 +708,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; } @@ -736,22 +736,22 @@ static int hotplug_loop_init(void) 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); } @@ -783,11 +783,11 @@ static void hotplug_loop_destroy(void) 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; } @@ -826,10 +826,10 @@ static void PIPEWIRE_DetectDevices(SDL_AudioDevice **default_output, SDL_AudioDe spa_list_for_each (io, &hotplug_io_list, link) { SDL_AudioDevice *device = SDL_AddAudioDevice(io->is_capture, io->name, &io->spec, PW_ID_TO_HANDLE(io->id)); - if (pipewire_default_sink_id != NULL && SDL_strcmp(io->path, pipewire_default_sink_id) == 0) { + if (pipewire_default_sink_id && SDL_strcmp(io->path, pipewire_default_sink_id) == 0) { SDL_assert(!io->is_capture); *default_output = device; - } else if (pipewire_default_source_id != NULL && SDL_strcmp(io->path, pipewire_default_source_id) == 0) { + } else if (pipewire_default_source_id && SDL_strcmp(io->path, pipewire_default_source_id) == 0) { SDL_assert(io->is_capture); *default_capture = device; } @@ -965,7 +965,7 @@ static void PIPEWIRE_FlushCapture(SDL_AudioDevice *device) { struct pw_stream *stream = device->hidden->stream; struct pw_buffer *pw_buf = PIPEWIRE_pw_stream_dequeue_buffer(stream); - if (pw_buf != NULL) { // just requeue it without any further thought. + if (pw_buf) { // just requeue it without any further thought. PIPEWIRE_pw_stream_queue_buffer(stream, pw_buf); } } @@ -1062,7 +1062,7 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *device) struct SDL_PrivateAudioData *priv; struct pw_properties *props; const char *app_name, *app_id, *stream_name, *stream_role, *error; - Uint32 node_id = device->handle == NULL ? PW_ID_ANY : PW_HANDLE_TO_ID(device->handle); + Uint32 node_id = !device->handle ? PW_ID_ANY : PW_HANDLE_TO_ID(device->handle); const SDL_bool iscapture = device->iscapture; int res; @@ -1071,9 +1071,9 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *device) // 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"; } } @@ -1082,7 +1082,7 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *device) app_id = SDL_GetHint(SDL_HINT_APP_ID); 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"; } @@ -1091,20 +1091,20 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *device) * 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(&device->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)); device->hidden = priv; - if (priv == NULL) { + if (!priv) { return SDL_OutOfMemory(); } @@ -1119,23 +1119,23 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *device) SDL_GetAudioThreadName(device, thread_name, sizeof(thread_name)); 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); } @@ -1143,7 +1143,7 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *device) PIPEWIRE_pw_properties_set(props, PW_KEY_MEDIA_CATEGORY, iscapture ? "Capture" : "Playback"); PIPEWIRE_pw_properties_set(props, PW_KEY_MEDIA_ROLE, stream_role); PIPEWIRE_pw_properties_set(props, PW_KEY_APP_NAME, app_name); - if (app_id != NULL) { + if (app_id) { PIPEWIRE_pw_properties_set(props, PW_KEY_APP_ID, app_id); } PIPEWIRE_pw_properties_set(props, PW_KEY_NODE_NAME, stream_name); @@ -1165,7 +1165,7 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *device) 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); @@ -1177,7 +1177,7 @@ static int PIPEWIRE_OpenDevice(SDL_AudioDevice *device) // 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, device); - if (priv->stream == NULL) { + if (!priv->stream) { return SDL_SetError("Pipewire: Failed to create stream (%i)", errno); } diff --git a/src/audio/ps2/SDL_ps2audio.c b/src/audio/ps2/SDL_ps2audio.c index 78717cc12..fd64d86e1 100644 --- a/src/audio/ps2/SDL_ps2audio.c +++ b/src/audio/ps2/SDL_ps2audio.c @@ -30,7 +30,7 @@ static int PS2AUDIO_OpenDevice(SDL_AudioDevice *device) { device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden)); - if (device->hidden == NULL) { + if (!device->hidden) { return SDL_OutOfMemory(); } @@ -73,7 +73,7 @@ static int PS2AUDIO_OpenDevice(SDL_AudioDevice *device) 64, so spec->size should be a multiple of 64 as well. */ const int mixlen = device->buffer_size * NUM_BUFFERS; device->hidden->rawbuf = (Uint8 *)SDL_aligned_alloc(64, mixlen); - if (device->hidden->rawbuf == NULL) { + if (!device->hidden->rawbuf) { return SDL_SetError("Couldn't allocate mixing buffer"); } @@ -112,7 +112,7 @@ static void PS2AUDIO_CloseDevice(SDL_AudioDevice *device) device->hidden->channel = -1; } - if (device->hidden->rawbuf != NULL) { + if (device->hidden->rawbuf) { SDL_aligned_free(device->hidden->rawbuf); device->hidden->rawbuf = NULL; } diff --git a/src/audio/psp/SDL_pspaudio.c b/src/audio/psp/SDL_pspaudio.c index ff9bb358f..057b4b14f 100644 --- a/src/audio/psp/SDL_pspaudio.c +++ b/src/audio/psp/SDL_pspaudio.c @@ -41,7 +41,7 @@ static inline SDL_bool isBasicAudioConfig(const SDL_AudioSpec *spec) static int PSPAUDIO_OpenDevice(SDL_AudioDevice *device) { device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden)); - if (device->hidden == NULL) { + if (!device->hidden) { return SDL_OutOfMemory(); } @@ -93,7 +93,7 @@ static int PSPAUDIO_OpenDevice(SDL_AudioDevice *device) 64, so spec->size should be a multiple of 64 as well. */ const int mixlen = device->buffer_size * NUM_BUFFERS; device->hidden->rawbuf = (Uint8 *)SDL_aligned_alloc(64, mixlen); - if (device->hidden->rawbuf == NULL) { + if (!device->hidden->rawbuf) { return SDL_SetError("Couldn't allocate mixing buffer"); } @@ -141,7 +141,7 @@ static void PSPAUDIO_CloseDevice(SDL_AudioDevice *device) device->hidden->channel = -1; } - if (device->hidden->rawbuf != NULL) { + if (device->hidden->rawbuf) { SDL_aligned_free(device->hidden->rawbuf); device->hidden->rawbuf = NULL; } diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c index 0612d8808..4cf9a6cf0 100644 --- a/src/audio/pulseaudio/SDL_pulseaudio.c +++ b/src/audio/pulseaudio/SDL_pulseaudio.c @@ -135,7 +135,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; } @@ -150,7 +150,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; } @@ -159,9 +159,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 { @@ -275,7 +275,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)) { @@ -297,13 +297,13 @@ static void OperationStateChangeCallback(pa_operation *o, void *userdata) 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) { // note that if PULSEAUDIO_pa_operation_set_state_callback == NULL, then `o` must have a callback that will signal pulseaudio_threaded_mainloop. // If not, on really old (earlier PulseAudio 4.0, from the year 2013!) installs, this call will block forever. // On more modern installs, we won't ever block forever, and maybe be more efficient, thanks to pa_operation_set_state_callback. // WARNING: at the time of this writing: the Steam Runtime is still on PulseAudio 1.1! - if (PULSEAUDIO_pa_operation_set_state_callback != NULL) { + if (PULSEAUDIO_pa_operation_set_state_callback) { PULSEAUDIO_pa_operation_set_state_callback(o, OperationStateChangeCallback, NULL); } while (PULSEAUDIO_pa_operation_get_state(o) == PA_OPERATION_RUNNING) { @@ -315,7 +315,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) { @@ -323,7 +323,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; } @@ -339,8 +339,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())) { @@ -363,7 +363,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; } @@ -480,7 +480,7 @@ static int PULSEAUDIO_WaitCaptureDevice(SDL_AudioDevice *device) { struct SDL_PrivateAudioData *h = device->hidden; - if (h->capturebuf != NULL) { + if (h->capturebuf) { return 0; // there's still data available to read. } @@ -500,7 +500,7 @@ static int PULSEAUDIO_WaitCaptureDevice(SDL_AudioDevice *device) size_t nbytes = 0; PULSEAUDIO_pa_stream_peek(h->stream, &data, &nbytes); SDL_assert(nbytes > 0); - if (data == NULL) { // If NULL, then the buffer had a hole, ignore that + if (!data) { // If NULL, then the buffer had a hole, ignore that PULSEAUDIO_pa_stream_drop(h->stream); // drop this fragment. } else { // store this fragment's data for use with CaptureFromDevice @@ -521,7 +521,7 @@ static int PULSEAUDIO_CaptureFromDevice(SDL_AudioDevice *device, void *buffer, i { struct SDL_PrivateAudioData *h = device->hidden; - if (h->capturebuf != NULL) { + if (h->capturebuf) { const int cpy = SDL_min(buflen, h->capturelen); if (cpy > 0) { //SDL_Log("PULSEAUDIO: fed %d captured bytes", cpy); @@ -549,7 +549,7 @@ static void PULSEAUDIO_FlushCapture(SDL_AudioDevice *device) 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; @@ -578,7 +578,7 @@ static void PULSEAUDIO_CloseDevice(SDL_AudioDevice *device) PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop); if (device->hidden->stream) { - if (device->hidden->capturebuf != NULL) { + if (device->hidden->capturebuf) { PULSEAUDIO_pa_stream_drop(device->hidden->stream); } PULSEAUDIO_pa_stream_disconnect(device->hidden->stream); @@ -609,12 +609,12 @@ static int PULSEAUDIO_OpenDevice(SDL_AudioDevice *device) 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 = device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden)); - if (device->hidden == NULL) { + if (!device->hidden) { return SDL_OutOfMemory(); } @@ -663,7 +663,7 @@ static int PULSEAUDIO_OpenDevice(SDL_AudioDevice *device) // Allocate mixing buffer if (!iscapture) { h->mixbuf = (Uint8 *)SDL_malloc(device->buffer_size); - if (h->mixbuf == NULL) { + if (!h->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(h->mixbuf, device->silence_value, device->buffer_size); @@ -694,7 +694,7 @@ static int PULSEAUDIO_OpenDevice(SDL_AudioDevice *device) &pacmap // channel map ); - if (h->stream == NULL) { + if (!h->stream) { retval = SDL_SetError("Could not set up PulseAudio stream"); } else { int rc; diff --git a/src/audio/qnx/SDL_qsa_audio.c b/src/audio/qnx/SDL_qsa_audio.c index e6de9e6f7..27e21d721 100644 --- a/src/audio/qnx/SDL_qsa_audio.c +++ b/src/audio/qnx/SDL_qsa_audio.c @@ -176,7 +176,7 @@ static Uint8 *QSA_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size) static void QSA_CloseDevice(SDL_AudioDevice *device) { if (device->hidden) { - if (device->hidden->audio_handle != NULL) { + if (device->hidden->audio_handle) { #if _NTO_VERSION < 710 // Finish playing available samples or cancel unread samples during capture snd_pcm_plugin_flush(device->hidden->audio_handle, device->iscapture ? SND_PCM_CHANNEL_CAPTURE : SND_PCM_CHANNEL_PLAYBACK); diff --git a/src/audio/sndio/SDL_sndioaudio.c b/src/audio/sndio/SDL_sndioaudio.c index 8cca105d5..970e2e907 100644 --- a/src/audio/sndio/SDL_sndioaudio.c +++ b/src/audio/sndio/SDL_sndioaudio.c @@ -71,7 +71,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) { return 0; // Don't call SDL_SetError(): SDL_LoadFunction already did. } @@ -110,7 +110,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; } @@ -119,9 +119,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 { retval = load_sndio_syms(); @@ -213,7 +213,7 @@ static Uint8 *SNDIO_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size) static void SNDIO_CloseDevice(SDL_AudioDevice *device) { if (device->hidden) { - if (device->hidden->dev != NULL) { + if (device->hidden->dev) { SNDIO_sio_stop(device->hidden->dev); SNDIO_sio_close(device->hidden->dev); } @@ -227,7 +227,7 @@ static void SNDIO_CloseDevice(SDL_AudioDevice *device) static int SNDIO_OpenDevice(SDL_AudioDevice *device) { device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden)); - if (device->hidden == NULL) { + if (!device->hidden) { return SDL_OutOfMemory(); } @@ -235,14 +235,14 @@ static int SNDIO_OpenDevice(SDL_AudioDevice *device) const char *audiodev = SDL_getenv("AUDIODEV"); // Capture devices must be non-blocking for SNDIO_FlushCapture - device->hidden->dev = SNDIO_sio_open(audiodev != NULL ? audiodev : SIO_DEVANY, + device->hidden->dev = SNDIO_sio_open(audiodev ? audiodev : SIO_DEVANY, device->iscapture ? SIO_REC : SIO_PLAY, device->iscapture); - if (device->hidden->dev == NULL) { + if (!device->hidden->dev) { return SDL_SetError("sio_open() failed"); } device->hidden->pfd = SDL_malloc(sizeof(struct pollfd) * SNDIO_sio_nfds(device->hidden->dev)); - if (device->hidden->pfd == NULL) { + if (!device->hidden->pfd) { return SDL_OutOfMemory(); } @@ -307,7 +307,7 @@ static int SNDIO_OpenDevice(SDL_AudioDevice *device) // Allocate mixing buffer device->hidden->mixbuf = (Uint8 *)SDL_malloc(device->buffer_size); - if (device->hidden->mixbuf == NULL) { + if (!device->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(device->hidden->mixbuf, device->silence_value, device->buffer_size); diff --git a/src/audio/vita/SDL_vitaaudio.c b/src/audio/vita/SDL_vitaaudio.c index 705d19ede..7e7c60608 100644 --- a/src/audio/vita/SDL_vitaaudio.c +++ b/src/audio/vita/SDL_vitaaudio.c @@ -63,7 +63,7 @@ static int VITAAUD_OpenDevice(SDL_AudioDevice *device) device->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*device->hidden)); - if (device->hidden == NULL) { + if (!device->hidden) { return SDL_OutOfMemory(); } SDL_memset(device->hidden, 0, sizeof(*device->hidden)); @@ -95,7 +95,7 @@ static int VITAAUD_OpenDevice(SDL_AudioDevice *device) 64, so spec->size should be a multiple of 64 as well. */ mixlen = device->buffer_size * NUM_BUFFERS; device->hidden->rawbuf = (Uint8 *)SDL_aligned_alloc(64, mixlen); - if (device->hidden->rawbuf == NULL) { + if (!device->hidden->rawbuf) { return SDL_SetError("Couldn't allocate mixing buffer"); } @@ -163,7 +163,7 @@ static void VITAAUD_CloseDevice(SDL_AudioDevice *device) device->hidden->port = -1; } - if (!device->iscapture && device->hidden->rawbuf != NULL) { + if (!device->iscapture && device->hidden->rawbuf) { SDL_aligned_free(device->hidden->rawbuf); // this uses SDL_aligned_alloc(), not SDL_malloc() device->hidden->rawbuf = NULL; } diff --git a/src/audio/wasapi/SDL_wasapi.c b/src/audio/wasapi/SDL_wasapi.c index ffbeeec34..c7d251d6e 100644 --- a/src/audio/wasapi/SDL_wasapi.c +++ b/src/audio/wasapi/SDL_wasapi.c @@ -93,7 +93,7 @@ static void ManagementThreadMainloop(void) int WASAPI_ProxyToManagementThread(ManagementThreadTask task, void *userdata, int *wait_on_result) { // We want to block for a result, but we are already running from the management thread! Just run the task now so we don't deadlock. - if ((wait_on_result != NULL) && (SDL_ThreadID() == SDL_GetThreadID(ManagementThread))) { + if ((wait_on_result) && (SDL_ThreadID() == SDL_GetThreadID(ManagementThread))) { *wait_on_result = task(userdata); return 0; // completed! } @@ -124,11 +124,11 @@ int WASAPI_ProxyToManagementThread(ManagementThreadTask task, void *userdata, in // add to end of task list. ManagementThreadPendingTask *prev = NULL; - for (ManagementThreadPendingTask *i = SDL_AtomicGetPtr((void **) &ManagementThreadPendingTasks); i != NULL; i = i->next) { + for (ManagementThreadPendingTask *i = SDL_AtomicGetPtr((void **) &ManagementThreadPendingTasks); i; i = i->next) { prev = i; } - if (prev != NULL) { + if (prev) { prev->next = pending; } else { SDL_AtomicSetPtr((void **) &ManagementThreadPendingTasks, pending); @@ -413,7 +413,7 @@ static Uint8 *WASAPI_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size) if (device->hidden->render) { if (WasapiFailed(device, IAudioRenderClient_GetBuffer(device->hidden->render, device->sample_frames, &buffer))) { - SDL_assert(buffer == NULL); + SDL_assert(!buffer); if (device->hidden->device_lost) { // just use an available buffer, we won't be playing it anyhow. *buffer_size = 0; // we'll recover during WaitDevice and try again. } @@ -425,7 +425,7 @@ static Uint8 *WASAPI_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size) static int WASAPI_PlayDevice(SDL_AudioDevice *device, const Uint8 *buffer, int buflen) { - if (device->hidden->render != NULL) { // definitely activated? + if (device->hidden->render) { // definitely activated? // WasapiFailed() will mark the device for reacquisition or removal elsewhere. WasapiFailed(device, IAudioRenderClient_ReleaseBuffer(device->hidden->render, device->sample_frames, 0)); } @@ -542,7 +542,7 @@ static int mgmtthrtask_PrepDevice(void *userdata) const AUDCLNT_SHAREMODE sharemode = AUDCLNT_SHAREMODE_SHARED; IAudioClient *client = device->hidden->client; - SDL_assert(client != NULL); + SDL_assert(client); #if defined(__WINRT__) || defined(__GDK__) // CreateEventEx() arrived in Vista, so we need an #ifdef for XP. device->hidden->event = CreateEventEx(NULL, NULL, 0, EVENT_ALL_ACCESS); @@ -550,7 +550,7 @@ static int mgmtthrtask_PrepDevice(void *userdata) device->hidden->event = CreateEventW(NULL, 0, 0, NULL); #endif - if (device->hidden->event == NULL) { + if (!device->hidden->event) { return WIN_SetError("WASAPI can't create an event handle"); } @@ -561,7 +561,7 @@ static int mgmtthrtask_PrepDevice(void *userdata) if (FAILED(ret)) { return WIN_SetErrorFromHRESULT("WASAPI can't determine mix format", ret); } - SDL_assert(waveformat != NULL); + SDL_assert(waveformat); device->hidden->waveformat = waveformat; SDL_AudioSpec newspec; @@ -642,7 +642,7 @@ static int mgmtthrtask_PrepDevice(void *userdata) return WIN_SetErrorFromHRESULT("WASAPI can't get capture client service", ret); } - SDL_assert(capture != NULL); + SDL_assert(capture); device->hidden->capture = capture; ret = IAudioClient_Start(client); if (FAILED(ret)) { @@ -657,7 +657,7 @@ static int mgmtthrtask_PrepDevice(void *userdata) return WIN_SetErrorFromHRESULT("WASAPI can't get render client service", ret); } - SDL_assert(render != NULL); + SDL_assert(render); device->hidden->render = render; ret = IAudioClient_Start(client); if (FAILED(ret)) { @@ -679,7 +679,7 @@ static int WASAPI_OpenDevice(SDL_AudioDevice *device) { // Initialize all variables that we clean on shutdown device->hidden = (struct SDL_PrivateAudioData *) SDL_calloc(1, sizeof(*device->hidden)); - if (device->hidden == NULL) { + if (!device->hidden) { return SDL_OutOfMemory(); } else if (ActivateWasapiDevice(device) < 0) { return -1; // already set error. diff --git a/src/audio/wasapi/SDL_wasapi_win32.c b/src/audio/wasapi/SDL_wasapi_win32.c index db8397c41..25af3225c 100644 --- a/src/audio/wasapi/SDL_wasapi_win32.c +++ b/src/audio/wasapi/SDL_wasapi_win32.c @@ -164,11 +164,11 @@ int WASAPI_ActivateDevice(SDL_AudioDevice *device) IMMDevice_Release(immdevice); if (FAILED(ret)) { - SDL_assert(device->hidden->client == NULL); + SDL_assert(!device->hidden->client); return WIN_SetErrorFromHRESULT("WASAPI can't activate audio endpoint", ret); } - SDL_assert(device->hidden->client != NULL); + SDL_assert(device->hidden->client); if (WASAPI_PrepDevice(device) == -1) { // not async, fire it right away. return -1; } diff --git a/src/core/SDL_runapp.c b/src/core/SDL_runapp.c index 02e25c694..faa2a924b 100644 --- a/src/core/SDL_runapp.c +++ b/src/core/SDL_runapp.c @@ -32,7 +32,7 @@ SDL_RunApp(int argc, char* argv[], SDL_main_func mainFunction, void * reserved) (void)reserved; - if(argv == NULL) + if(!argv) { argc = 0; /* make sure argv isn't NULL, in case some user code doesn't like that */ diff --git a/src/core/android/SDL_android.c b/src/core/android/SDL_android.c index 8626a6b6f..63bd79d65 100644 --- a/src/core/android/SDL_android.c +++ b/src/core/android/SDL_android.c @@ -434,12 +434,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; } @@ -468,7 +468,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; } @@ -494,7 +494,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); } @@ -520,7 +520,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; } @@ -582,28 +582,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"); } @@ -1614,7 +1614,7 @@ int Android_JNI_OpenAudioDevice(SDL_AudioDevice *device) __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDL audio: opening device for output"); result = (*env)->CallStaticObjectMethod(env, mAudioManagerClass, midAudioOpen, spec->freq, audioformat, spec->channels, device->sample_frames, device_id); } - if (result == NULL) { + if (!result) { /* Error during audio initialization, error printed from Java */ return SDL_SetError("Java-side initialization failed"); } @@ -1675,7 +1675,7 @@ int Android_JNI_OpenAudioDevice(SDL_AudioDevice *device) 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(); } @@ -1946,7 +1946,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); } @@ -1970,16 +1970,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); } @@ -2051,7 +2051,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) @@ -2371,7 +2371,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; } @@ -2425,7 +2425,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; @@ -2524,7 +2524,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; @@ -2680,16 +2680,16 @@ int Android_JNI_GetLocale(char *buf, size_t buflen) /* Need to re-create the asset manager if locale has changed (SDL_EVENT_LOCALE_CHANGED) */ 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; } diff --git a/src/core/freebsd/SDL_evdev_kbd_freebsd.c b/src/core/freebsd/SDL_evdev_kbd_freebsd.c index e9129feeb..a89003ed2 100644 --- a/src/core/freebsd/SDL_evdev_kbd_freebsd.c +++ b/src/core/freebsd/SDL_evdev_kbd_freebsd.c @@ -87,7 +87,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; @@ -178,7 +178,7 @@ static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state *kbd) { int tabidx; - if (kbd_cleanup_state != NULL) { + if (kbd_cleanup_state) { return; } kbd_cleanup_state = kbd; @@ -230,7 +230,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; } @@ -296,7 +296,7 @@ void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *kbd) { struct mouse_info mData; - if (kbd == NULL) { + if (!kbd) { return; } SDL_zero(mData); @@ -486,7 +486,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; } diff --git a/src/core/haiku/SDL_BeApp.cc b/src/core/haiku/SDL_BeApp.cc index 8403f9a18..7f62bc52e 100644 --- a/src/core/haiku/SDL_BeApp.cc +++ b/src/core/haiku/SDL_BeApp.cc @@ -108,13 +108,13 @@ static int StartBeLooper() { if (!be_app) { SDL_AppThread = SDL_CreateThreadInternal(StartBeApp, "SDLApplication", 0, NULL); - if (SDL_AppThread == NULL) { + if (!SDL_AppThread) { return SDL_SetError("Couldn't create BApplication thread"); } do { SDL_Delay(10); - } while ((be_app == NULL) || be_app->IsLaunching()); + } while ((!be_app) || be_app->IsLaunching()); } /* Change working directory to that of executable */ @@ -167,7 +167,7 @@ void SDL_QuitBeApp(void) SDL_Looper->Lock(); SDL_Looper->Quit(); SDL_Looper = NULL; - if (SDL_AppThread != NULL) { + if (SDL_AppThread) { if (be_app != NULL) { /* Not tested */ be_app->PostMessage(B_QUIT_REQUESTED); } diff --git a/src/core/linux/SDL_dbus.c b/src/core/linux/SDL_dbus.c index 14154319f..900e1a1b2 100644 --- a/src/core/linux/SDL_dbus.c +++ b/src/core/linux/SDL_dbus.c @@ -96,7 +96,7 @@ static int LoadDBUSSyms(void) static void UnloadDBUSLibrary(void) { - if (dbus_handle != NULL) { + if (dbus_handle) { SDL_UnloadObject(dbus_handle); dbus_handle = NULL; } @@ -105,9 +105,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 { @@ -199,7 +199,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(); } @@ -360,7 +360,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); @@ -428,7 +428,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; } @@ -452,12 +452,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; } @@ -496,10 +496,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; } diff --git a/src/core/linux/SDL_evdev.c b/src/core/linux/SDL_evdev.c index 9ca3bdfaf..38f28602e 100644 --- a/src/core/linux/SDL_evdev.c +++ b/src/core/linux/SDL_evdev.c @@ -167,9 +167,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(); } @@ -231,7 +231,7 @@ int SDL_EVDEV_Init(void) void SDL_EVDEV_Quit(void) { - if (_this == NULL) { + if (!_this) { return; } @@ -244,14 +244,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); @@ -263,7 +263,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; } @@ -301,7 +301,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; } @@ -331,7 +331,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) { @@ -643,7 +643,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(); } @@ -654,7 +654,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(); } @@ -709,7 +709,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(); @@ -770,7 +770,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; } @@ -875,14 +875,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(); } @@ -893,7 +893,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(); @@ -928,7 +928,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; @@ -947,10 +947,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); diff --git a/src/core/linux/SDL_evdev_kbd.c b/src/core/linux/SDL_evdev_kbd.c index 2fb3034a3..cf768cdf7 100644 --- a/src/core/linux/SDL_evdev_kbd.c +++ b/src/core/linux/SDL_evdev_kbd.c @@ -173,7 +173,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; @@ -258,7 +258,7 @@ static void kbd_register_emerg_cleanup(SDL_EVDEV_keyboard_state *kbd) { int tabidx; - if (kbd_cleanup_state != NULL) { + if (kbd_cleanup_state) { return; } kbd_cleanup_state = kbd; @@ -428,7 +428,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; } @@ -464,7 +464,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; } @@ -892,7 +892,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; } @@ -900,7 +900,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; diff --git a/src/core/linux/SDL_fcitx.c b/src/core/linux/SDL_fcitx.c index 0efd7dc5b..64a200e97 100644 --- a/src/core/linux/SDL_fcitx.c +++ b/src/core/linux/SDL_fcitx.c @@ -419,7 +419,7 @@ void SDL_Fcitx_UpdateTextRect(const SDL_Rect *rect) } focused_win = SDL_GetKeyboardFocus(); - if (focused_win == NULL) { + if (!focused_win) { return; } diff --git a/src/core/linux/SDL_ibus.c b/src/core/linux/SDL_ibus.c index 5997b046d..9b8214f73 100644 --- a/src/core/linux/SDL_ibus.c +++ b/src/core/linux/SDL_ibus.c @@ -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; @@ -291,7 +291,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; } @@ -336,7 +336,7 @@ static char *IBus_GetDBusAddressFilename(void) } dbus = SDL_DBus_GetContext(); - if (dbus == NULL) { + if (!dbus) { return NULL; } @@ -350,7 +350,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); @@ -360,7 +360,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; } @@ -374,7 +374,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"; @@ -388,7 +388,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; } @@ -397,7 +397,7 @@ static char *IBus_GetDBusAddressFilename(void) key = SDL_DBus_GetLocalMachineId(); - if (key == NULL) { + if (!key) { SDL_free(display); return NULL; } @@ -458,7 +458,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. */ } @@ -498,7 +498,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; } @@ -518,7 +518,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; } @@ -555,12 +555,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; } @@ -646,7 +646,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); } } @@ -696,7 +696,7 @@ void SDL_IBus_UpdateTextRect(const SDL_Rect *rect) } focused_win = SDL_GetKeyboardFocus(); - if (focused_win == NULL) { + if (!focused_win) { return; } diff --git a/src/core/linux/SDL_ime.c b/src/core/linux/SDL_ime.c index 45bc1c6c6..1b9394e88 100644 --- a/src/core/linux/SDL_ime.c +++ b/src/core/linux/SDL_ime.c @@ -56,9 +56,9 @@ static void InitIME(void) /* 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(void) /* 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; diff --git a/src/core/linux/SDL_system_theme.c b/src/core/linux/SDL_system_theme.c index 89077a039..3b6e44581 100644 --- a/src/core/linux/SDL_system_theme.c +++ b/src/core/linux/SDL_system_theme.c @@ -115,12 +115,12 @@ SDL_bool SDL_SystemTheme_Init(void) system_theme_data.theme = SDL_SYSTEM_THEME_UNKNOWN; system_theme_data.dbus = dbus; - if (dbus == NULL) { + if (!dbus) { return SDL_FALSE; } msg = dbus->message_new_method_call(PORTAL_DESTINATION, PORTAL_PATH, PORTAL_INTERFACE, PORTAL_METHOD); - if (msg != NULL) { + if (msg) { if (dbus->message_append_args(msg, DBUS_TYPE_STRING, &namespace, DBUS_TYPE_STRING, &key, DBUS_TYPE_INVALID)) { DBusMessage *reply = dbus->connection_send_with_reply_and_block(dbus->session_conn, msg, 300, NULL); if (reply) { diff --git a/src/core/linux/SDL_threadprio.c b/src/core/linux/SDL_threadprio.c index 23b447334..c5d28dc92 100644 --- a/src/core/linux/SDL_threadprio.c +++ b/src/core/linux/SDL_threadprio.c @@ -111,19 +111,19 @@ static void rtkit_initialize(void) 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; } @@ -202,7 +202,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)) { @@ -233,7 +233,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)) { diff --git a/src/core/linux/SDL_udev.c b/src/core/linux/SDL_udev.c index 9e72d79ed..a459489b2 100644 --- a/src/core/linux/SDL_udev.c +++ b/src/core/linux/SDL_udev.c @@ -47,7 +47,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; } @@ -96,7 +96,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; @@ -109,9 +109,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(); } @@ -126,13 +126,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"); } @@ -152,7 +152,7 @@ int SDL_UDEV_Init(void) void SDL_UDEV_Quit(void) { - if (_this == NULL) { + if (!_this) { return; } @@ -160,17 +160,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) { SDL_UDEV_CallbackList *item = _this->first; _this->first = _this->first->next; SDL_free(item); @@ -188,12 +188,12 @@ int SDL_UDEV_Scan(void) struct udev_list_entry *devs = NULL; struct udev_list_entry *item = NULL; - if (_this == NULL) { + if (!_this) { return 0; } enumerate = _this->syms.udev_enumerate_new(_this->udev); - if (enumerate == NULL) { + if (!enumerate) { SDL_UDEV_Quit(); return SDL_SetError("udev_enumerate_new() failed"); } @@ -206,7 +206,7 @@ int 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); } @@ -223,12 +223,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; } @@ -238,7 +238,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; @@ -247,17 +247,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); } } @@ -271,11 +271,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; } @@ -285,7 +285,7 @@ int SDL_UDEV_LoadLibrary(void) { int retval = 0, i; - if (_this == NULL) { + if (!_this) { return SDL_SetError("UDEV not initialized"); } @@ -296,9 +296,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(); @@ -307,10 +307,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(); @@ -320,7 +320,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. */ } @@ -339,7 +339,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; } @@ -374,7 +374,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; } @@ -400,7 +400,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; } @@ -411,23 +411,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; } @@ -438,19 +438,19 @@ 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_HAS_KEYS; } val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_KEYBOARD"); - 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) { @@ -470,7 +470,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); } } @@ -480,13 +480,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); @@ -507,13 +507,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; @@ -528,14 +528,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); diff --git a/src/core/ngage/SDL_ngage_runapp.cpp b/src/core/ngage/SDL_ngage_runapp.cpp index 6c3e4b04d..b2eca9889 100644 --- a/src/core/ngage/SDL_ngage_runapp.cpp +++ b/src/core/ngage/SDL_ngage_runapp.cpp @@ -57,7 +57,7 @@ SDL_RunApp(int argc_, char* argv_[], SDL_main_func mainFunction, void * reserved newHeap = User::ChunkHeap(NULL, heapSize, heapSize, KMinHeapGrowBy); - if (newHeap == NULL) { + if (!newHeap) { ret = 3; goto cleanup; } else { diff --git a/src/core/openbsd/SDL_wscons_kbd.c b/src/core/openbsd/SDL_wscons_kbd.c index f54f1d395..a92a0484c 100644 --- a/src/core/openbsd/SDL_wscons_kbd.c +++ b/src/core/openbsd/SDL_wscons_kbd.c @@ -419,7 +419,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); @@ -429,7 +429,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) { SDL_free(input); return NULL; } @@ -579,7 +579,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) { @@ -923,7 +923,7 @@ void SDL_WSCONS_PumpEvents() for (i = 0; i < 4; i++) { updateKeyboard(inputs[i]); } - if (mouseInputData != NULL) { + if (mouseInputData) { updateMouse(mouseInputData); } } diff --git a/src/core/openbsd/SDL_wscons_mouse.c b/src/core/openbsd/SDL_wscons_mouse.c index c3378153c..88855e469 100644 --- a/src/core/openbsd/SDL_wscons_mouse.c +++ b/src/core/openbsd/SDL_wscons_mouse.c @@ -41,7 +41,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); @@ -125,7 +125,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); diff --git a/src/core/windows/SDL_hid.c b/src/core/windows/SDL_hid.c index 3129ac27d..541f6490f 100644 --- a/src/core/windows/SDL_hid.c +++ b/src/core/windows/SDL_hid.c @@ -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; } diff --git a/src/core/windows/SDL_immdevice.c b/src/core/windows/SDL_immdevice.c index 629f4a181..e2d1266ef 100644 --- a/src/core/windows/SDL_immdevice.c +++ b/src/core/windows/SDL_immdevice.c @@ -342,8 +342,8 @@ int SDL_IMMDevice_Get(SDL_AudioDevice *device, IMMDevice **immdevice, SDL_bool i { const Uint64 timeout = SDL_GetTicks() + 8000; /* intel's audio drivers can fail for up to EIGHT SECONDS after a device is connected or we wake from sleep. */ - SDL_assert(device != NULL); - SDL_assert(immdevice != NULL); + SDL_assert(device); + SDL_assert(immdevice); LPCWSTR devid = SDL_IMMDevice_GetDevID(device); SDL_assert(devid != NULL); diff --git a/src/core/windows/SDL_windows.c b/src/core/windows/SDL_windows.c index 389862708..39f48f9d9 100644 --- a/src/core/windows/SDL_windows.c +++ b/src/core/windows/SDL_windows.c @@ -283,7 +283,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. */ } @@ -388,7 +388,7 @@ DECLSPEC int MINGW32_FORCEALIGN SDL_RunApp(int _argc, char* _argv[], SDL_main_fu (void)_argc; (void)_argv; (void)reserved; argvw = CommandLineToArgvW(GetCommandLineW(), &argc); - if (argvw == NULL) { + if (!argvw) { return OutOfMemory(); } @@ -399,13 +399,13 @@ DECLSPEC int MINGW32_FORCEALIGN SDL_RunApp(int _argc, char* _argv[], SDL_main_fu /* Parse it into argv and argc */ argv = (char **)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (argc + 1) * sizeof(*argv)); - if (argv == NULL) { + if (!argv) { return OutOfMemory(); } for (i = 0; i < argc; ++i) { DWORD len; char *arg = WIN_StringToUTF8W(argvw[i]); - if (arg == NULL) { + if (!arg) { return OutOfMemory(); } len = (DWORD)SDL_strlen(arg); diff --git a/src/core/windows/SDL_xinput.c b/src/core/windows/SDL_xinput.c index 01418d9f3..8a410e783 100644 --- a/src/core/windows/SDL_xinput.c +++ b/src/core/windows/SDL_xinput.c @@ -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; } diff --git a/src/core/winrt/SDL_winrtapp_direct3d.cpp b/src/core/winrt/SDL_winrtapp_direct3d.cpp index 3bd87ccd6..167e5a9a0 100644 --- a/src/core/winrt/SDL_winrtapp_direct3d.cpp +++ b/src/core/winrt/SDL_winrtapp_direct3d.cpp @@ -343,7 +343,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"); diff --git a/src/dynapi/SDL_dynapi.c b/src/dynapi/SDL_dynapi.c index 833a98072..c865aac71 100644 --- a/src/dynapi/SDL_dynapi.c +++ b/src/dynapi/SDL_dynapi.c @@ -418,7 +418,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); } } @@ -431,9 +431,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); } } diff --git a/src/events/SDL_displayevents.c b/src/events/SDL_displayevents.c index 2e1a2ceaf..d7b620a56 100644 --- a/src/events/SDL_displayevents.c +++ b/src/events/SDL_displayevents.c @@ -28,7 +28,7 @@ int SDL_SendDisplayEvent(SDL_VideoDisplay *display, SDL_EventType displayevent, { int posted; - if (display == NULL || display->id == 0) { + if (!display || display->id == 0) { return 0; } switch (displayevent) { diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c index c1f27bc46..6bb763e46 100644 --- a/src/events/SDL_keyboard.c +++ b/src/events/SDL_keyboard.c @@ -778,7 +778,7 @@ int SDL_SetKeyboardFocus(SDL_Window *window) } } - if (keyboard->focus && window == NULL) { + if (keyboard->focus && !window) { /* We won't get anymore keyboard messages, so reset keyboard state */ SDL_ResetKeyboard(); } @@ -787,7 +787,7 @@ int 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) { @@ -1199,7 +1199,7 @@ const char *SDL_GetScancodeName(SDL_Scancode scancode) } name = SDL_scancode_names[scancode]; - if (name != NULL) { + if (name) { return name; } @@ -1210,7 +1210,7 @@ SDL_Scancode SDL_GetScancodeFromName(const char *name) { int i; - if (name == NULL || !*name) { + if (!name || !*name) { SDL_InvalidParamError("name"); return SDL_SCANCODE_UNKNOWN; } @@ -1270,7 +1270,7 @@ SDL_Keycode SDL_GetKeyFromName(const char *name) SDL_Keycode key; /* Check input */ - if (name == NULL) { + if (!name) { return SDLK_UNKNOWN; } diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index fc38e682a..cd4e6a719 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -476,7 +476,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)); @@ -704,7 +704,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; @@ -726,7 +726,7 @@ static int SDL_PrivateSendMouseButton(Uint64 timestamp, SDL_Window *window, SDL_ SDL_MouseInputSource *source; source = GetMouseInputSource(mouse, mouseID); - if (source == NULL) { + if (!source) { return 0; } buttonstate = source->buttonstate; @@ -982,10 +982,10 @@ Uint32 SDL_GetGlobalMouseState(float *x, float *y) float 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; } @@ -1001,11 +1001,11 @@ void SDL_PerformWarpMouseInWindow(SDL_Window *window, float x, float y, SDL_bool { SDL_Mouse *mouse = SDL_GetMouse(); - if (window == NULL) { + if (!window) { window = mouse->focus; } - if (window == NULL) { + if (!window) { return; } @@ -1231,7 +1231,7 @@ SDL_Cursor *SDL_CreateCursor(const Uint8 *data, const Uint8 *mask, int w, int h, /* Create the surface from a bitmap */ surface = SDL_CreateSurface(w, h, SDL_PIXELFORMAT_ARGB8888); - if (surface == NULL) { + if (!surface) { return NULL; } for (y = 0; y < h; ++y) { @@ -1264,7 +1264,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; } @@ -1278,7 +1278,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); - if (temp == NULL) { + if (!temp) { return NULL; } surface = temp; @@ -1344,7 +1344,7 @@ int SDL_SetCursor(SDL_Cursor *cursor) break; } } - if (found == NULL) { + if (!found) { return SDL_SetError("Cursor not associated with the current mouse"); } } @@ -1373,7 +1373,7 @@ SDL_Cursor *SDL_GetCursor(void) { SDL_Mouse *mouse = SDL_GetMouse(); - if (mouse == NULL) { + if (!mouse) { return NULL; } return mouse->cur_cursor; @@ -1383,7 +1383,7 @@ SDL_Cursor *SDL_GetDefaultCursor(void) { SDL_Mouse *mouse = SDL_GetMouse(); - if (mouse == NULL) { + if (!mouse) { return NULL; } return mouse->def_cursor; @@ -1394,7 +1394,7 @@ void SDL_DestroyCursor(SDL_Cursor *cursor) SDL_Mouse *mouse = SDL_GetMouse(); SDL_Cursor *curr, *prev; - if (cursor == NULL) { + if (!cursor) { return; } diff --git a/src/events/SDL_touch.c b/src/events/SDL_touch.c index d989a25e5..9671f49b4 100644 --- a/src/events/SDL_touch.c +++ b/src/events/SDL_touch.c @@ -137,7 +137,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) { @@ -160,7 +160,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(); } @@ -193,7 +193,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; @@ -235,7 +235,7 @@ int SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_W SDL_Mouse *mouse; SDL_Touch *touch = SDL_GetTouch(id); - if (touch == NULL) { + if (!touch) { return -1; } @@ -329,7 +329,7 @@ int SDL_SendTouch(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, SDL_W posted = (SDL_PushEvent(&event) > 0); } } else { - if (finger == NULL) { + if (!finger) { /* This finger is already up */ return 0; } @@ -366,7 +366,7 @@ int SDL_SendTouchMotion(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, float xrel, yrel, prel; touch = SDL_GetTouch(id); - if (touch == NULL) { + if (!touch) { return -1; } @@ -409,7 +409,7 @@ int SDL_SendTouchMotion(Uint64 timestamp, SDL_TouchID id, SDL_FingerID fingerid, } finger = SDL_GetFinger(touch, fingerid); - if (finger == NULL) { + if (!finger) { return SDL_SendTouch(timestamp, id, fingerid, window, SDL_TRUE, x, y, pressure); } @@ -461,7 +461,7 @@ void SDL_DelTouch(SDL_TouchID id) index = SDL_GetTouchIndex(id); touch = SDL_GetTouch(id); - if (touch == NULL) { + if (!touch) { return; } diff --git a/src/events/SDL_windowevents.c b/src/events/SDL_windowevents.c index 8273f82d0..5a4a235d5 100644 --- a/src/events/SDL_windowevents.c +++ b/src/events/SDL_windowevents.c @@ -43,7 +43,7 @@ int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent, { int posted; - if (window == NULL) { + if (!window) { return 0; } if (window->is_destroying && windowevent != SDL_EVENT_WINDOW_DESTROYED) { @@ -222,11 +222,11 @@ int SDL_SendWindowEvent(SDL_Window *window, SDL_EventType windowevent, break; } - if (windowevent == SDL_EVENT_WINDOW_CLOSE_REQUESTED && window->parent == NULL) { + if (windowevent == SDL_EVENT_WINDOW_CLOSE_REQUESTED && !window->parent) { int toplevel_count = 0; SDL_Window *n; - for (n = SDL_GetVideoDevice()->windows; n != NULL; n = n->next) { - if (n->parent == NULL) { + for (n = SDL_GetVideoDevice()->windows; n; n = n->next) { + if (!n->parent) { ++toplevel_count; } } diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c index 3bfb969b4..a671c76f2 100644 --- a/src/file/SDL_rwops.c +++ b/src/file/SDL_rwops.c @@ -389,7 +389,7 @@ static SDL_RWops *SDL_RWFromFP(void *fp, SDL_bool autoclose) SDL_RWops *rwops = NULL; rwops = SDL_CreateRW(); - if (rwops != NULL) { + if (rwops) { rwops->seek = stdio_seek; rwops->read = stdio_read; rwops->write = stdio_write; @@ -462,7 +462,7 @@ static size_t SDLCALL mem_write(SDL_RWops *context, const void *ptr, size_t size 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; } @@ -495,7 +495,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode) /* Try to open the file from the asset system */ rwops = SDL_CreateRW(); - if (rwops == NULL) { + if (!rwops) { return NULL; /* SDL_SetError already setup by SDL_CreateRW() */ } @@ -512,7 +512,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode) #elif defined(__WIN32__) || defined(__GDK__) || defined(__WINRT__) rwops = SDL_CreateRW(); - if (rwops == NULL) { + if (!rwops) { return NULL; /* SDL_SetError already setup by SDL_CreateRW() */ } @@ -538,7 +538,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); @@ -555,7 +555,7 @@ SDL_RWops *SDL_RWFromMem(void *mem, size_t size) { SDL_RWops *rwops = NULL; - if (mem == NULL) { + if (!mem) { SDL_InvalidParamError("mem"); return NULL; } @@ -565,7 +565,7 @@ SDL_RWops *SDL_RWFromMem(void *mem, size_t size) } rwops = SDL_CreateRW(); - if (rwops != NULL) { + if (rwops) { rwops->size = mem_size; rwops->seek = mem_seek; rwops->read = mem_read; @@ -582,7 +582,7 @@ SDL_RWops *SDL_RWFromConstMem(const void *mem, size_t size) { SDL_RWops *rwops = NULL; - if (mem == NULL) { + if (!mem) { SDL_InvalidParamError("mem"); return NULL; } @@ -592,7 +592,7 @@ SDL_RWops *SDL_RWFromConstMem(const void *mem, size_t size) } rwops = SDL_CreateRW(); - if (rwops != NULL) { + if (rwops) { rwops->size = mem_size; rwops->seek = mem_seek; rwops->read = mem_read; @@ -609,7 +609,7 @@ SDL_RWops *SDL_CreateRW(void) SDL_RWops *context; context = (SDL_RWops *)SDL_calloc(1, sizeof(*context)); - if (context == NULL) { + if (!context) { SDL_OutOfMemory(); } else { context->type = SDL_RWOPS_UNKNOWN; @@ -632,7 +632,7 @@ void *SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, SDL_bool freesrc) char *data = NULL, *newdata; SDL_bool loading_chunks = SDL_FALSE; - if (src == NULL) { + if (!src) { SDL_InvalidParamError("src"); return NULL; } @@ -662,7 +662,7 @@ void *SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, SDL_bool freesrc) } else { newdata = SDL_realloc(data, (size_t)(size + 1)); } - if (newdata == NULL) { + if (!newdata) { SDL_free(data); data = NULL; SDL_OutOfMemory(); diff --git a/src/file/n3ds/SDL_rwopsromfs.c b/src/file/n3ds/SDL_rwopsromfs.c index acb8701a2..a1bde5494 100644 --- a/src/file/n3ds/SDL_rwopsromfs.c +++ b/src/file/n3ds/SDL_rwopsromfs.c @@ -65,7 +65,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); } diff --git a/src/filesystem/android/SDL_sysfilesystem.c b/src/filesystem/android/SDL_sysfilesystem.c index d14f78921..a287b005e 100644 --- a/src/filesystem/android/SDL_sysfilesystem.c +++ b/src/filesystem/android/SDL_sysfilesystem.c @@ -40,7 +40,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; } diff --git a/src/filesystem/emscripten/SDL_sysfilesystem.c b/src/filesystem/emscripten/SDL_sysfilesystem.c index 389eff087..5c87840b3 100644 --- a/src/filesystem/emscripten/SDL_sysfilesystem.c +++ b/src/filesystem/emscripten/SDL_sysfilesystem.c @@ -42,17 +42,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; } diff --git a/src/filesystem/gdk/SDL_sysfilesystem.cpp b/src/filesystem/gdk/SDL_sysfilesystem.cpp index 517524bdb..3bbfca311 100644 --- a/src/filesystem/gdk/SDL_sysfilesystem.cpp +++ b/src/filesystem/gdk/SDL_sysfilesystem.cpp @@ -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:\\"); } diff --git a/src/filesystem/haiku/SDL_sysfilesystem.cc b/src/filesystem/haiku/SDL_sysfilesystem.cc index 466a2576a..a70e297bd 100644 --- a/src/filesystem/haiku/SDL_sysfilesystem.cc +++ b/src/filesystem/haiku/SDL_sysfilesystem.cc @@ -47,11 +47,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; } @@ -70,11 +70,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 = ""; } @@ -83,7 +83,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) { diff --git a/src/filesystem/n3ds/SDL_sysfilesystem.c b/src/filesystem/n3ds/SDL_sysfilesystem.c index 7bde83102..00ac71fc8 100644 --- a/src/filesystem/n3ds/SDL_sysfilesystem.c +++ b/src/filesystem/n3ds/SDL_sysfilesystem.c @@ -41,13 +41,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; } diff --git a/src/filesystem/ps2/SDL_sysfilesystem.c b/src/filesystem/ps2/SDL_sysfilesystem.c index b52fdea35..e81460a24 100644 --- a/src/filesystem/ps2/SDL_sysfilesystem.c +++ b/src/filesystem/ps2/SDL_sysfilesystem.c @@ -79,11 +79,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 = ""; } diff --git a/src/filesystem/psp/SDL_sysfilesystem.c b/src/filesystem/psp/SDL_sysfilesystem.c index 239e67436..f262af55f 100644 --- a/src/filesystem/psp/SDL_sysfilesystem.c +++ b/src/filesystem/psp/SDL_sysfilesystem.c @@ -47,11 +47,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 = ""; } diff --git a/src/filesystem/riscos/SDL_sysfilesystem.c b/src/filesystem/riscos/SDL_sysfilesystem.c index 17d6625b7..842d62e38 100644 --- a/src/filesystem/riscos/SDL_sysfilesystem.c +++ b/src/filesystem/riscos/SDL_sysfilesystem.c @@ -34,21 +34,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); } @@ -88,7 +88,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; } @@ -117,7 +117,7 @@ static _kernel_oserror *createDirectoryRecursive(char *path) *ptr = '\0'; error = _kernel_swi(OS_File, ®s, ®s); *ptr = '.'; - if (error != NULL) { + if (error) { return error; } } @@ -137,13 +137,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'; } @@ -158,22 +158,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("", "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; @@ -188,7 +188,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; diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c index 88a3a3537..d75dd5066 100644 --- a/src/filesystem/unix/SDL_sysfilesystem.c +++ b/src/filesystem/unix/SDL_sysfilesystem.c @@ -47,7 +47,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; } @@ -78,18 +78,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); @@ -110,7 +110,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); @@ -130,7 +130,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; } @@ -144,13 +144,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; @@ -172,7 +172,7 @@ char *SDL_GetBasePath(void) } if (exe) { - if (pwddst == NULL) { + if (!pwddst) { if (realpath(exe, realpathbuf) != NULL) { retval = realpathbuf; } @@ -188,7 +188,7 @@ char *SDL_GetBasePath(void) } } - if (retval == NULL) { + if (!retval) { SDL_free(realpathbuf); } @@ -197,7 +197,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. */ @@ -209,7 +209,7 @@ char *SDL_GetBasePath(void) retval = readSymLink("/proc/self/path/a.out"); #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), @@ -225,9 +225,9 @@ char *SDL_GetBasePath(void) #ifdef __SOLARIS__ /* try this as a fallback if /proc didn't pan out */ if (!retval) { const char *path = getexecname(); - if ((path != NULL) && (path[0] == '/')) { /* must be absolute path... */ + if ((path) && (path[0] == '/')) { /* must be absolute path... */ retval = SDL_strdup(path); - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); return NULL; } @@ -237,9 +237,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); @@ -247,10 +247,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. */ } } @@ -273,18 +273,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; @@ -301,7 +301,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; } @@ -372,15 +372,15 @@ static char *xdg_user_dir_lookup_with_fallback (const char *type, const char *fa home_dir = SDL_getenv ("HOME"); - if (home_dir == NULL) + if (!home_dir) goto error; config_home = SDL_getenv ("XDG_CONFIG_HOME"); - if (config_home == NULL || config_home[0] == 0) + if (!config_home || config_home[0] == 0) { l = SDL_strlen (home_dir) + SDL_strlen ("/.config/user-dirs.dirs") + 1; config_file = (char*) SDL_malloc (l); - if (config_file == NULL) + if (!config_file) goto error; SDL_strlcpy (config_file, home_dir, l); @@ -390,7 +390,7 @@ static char *xdg_user_dir_lookup_with_fallback (const char *type, const char *fa { l = SDL_strlen (config_home) + SDL_strlen ("/user-dirs.dirs") + 1; config_file = (char*) SDL_malloc (l); - if (config_file == NULL) + if (!config_file) goto error; SDL_strlcpy (config_file, config_home, l); @@ -399,7 +399,7 @@ static char *xdg_user_dir_lookup_with_fallback (const char *type, const char *fa file = fopen (config_file, "r"); SDL_free (config_file); - if (file == NULL) + if (!file) goto error; user_dir = NULL; @@ -452,7 +452,7 @@ static char *xdg_user_dir_lookup_with_fallback (const char *type, const char *fa { l = SDL_strlen (home_dir) + 1 + SDL_strlen (p) + 1; user_dir = (char*) SDL_malloc (l); - if (user_dir == NULL) + if (!user_dir) goto error2; SDL_strlcpy (user_dir, home_dir, l); @@ -461,7 +461,7 @@ static char *xdg_user_dir_lookup_with_fallback (const char *type, const char *fa else { user_dir = (char*) SDL_malloc (SDL_strlen (p) + 1); - if (user_dir == NULL) + if (!user_dir) goto error2; *user_dir = 0; @@ -493,12 +493,12 @@ static char *xdg_user_dir_lookup (const char *type) char *dir, *home_dir, *user_dir; dir = xdg_user_dir_lookup_with_fallback(type, NULL); - if (dir != NULL) + if (dir) return dir; home_dir = SDL_getenv("HOME"); - if (home_dir == NULL) + if (!home_dir) return NULL; /* Special case desktop for historical compatibility */ @@ -506,7 +506,7 @@ static char *xdg_user_dir_lookup (const char *type) { user_dir = (char*) SDL_malloc(SDL_strlen(home_dir) + SDL_strlen("/Desktop") + 1); - if (user_dir == NULL) + if (!user_dir) return NULL; strcpy(user_dir, home_dir); diff --git a/src/filesystem/vita/SDL_sysfilesystem.c b/src/filesystem/vita/SDL_sysfilesystem.c index 836416abf..e06664908 100644 --- a/src/filesystem/vita/SDL_sysfilesystem.c +++ b/src/filesystem/vita/SDL_sysfilesystem.c @@ -48,11 +48,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 = ""; } @@ -60,7 +60,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; } diff --git a/src/filesystem/windows/SDL_sysfilesystem.c b/src/filesystem/windows/SDL_sysfilesystem.c index 3027fb00e..d31193af2 100644 --- a/src/filesystem/windows/SDL_sysfilesystem.c +++ b/src/filesystem/windows/SDL_sysfilesystem.c @@ -51,7 +51,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; @@ -108,11 +108,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 = ""; } @@ -122,13 +122,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; diff --git a/src/filesystem/winrt/SDL_sysfilesystem.cpp b/src/filesystem/winrt/SDL_sysfilesystem.cpp index a5e85b4a9..d442d2603 100644 --- a/src/filesystem/winrt/SDL_sysfilesystem.cpp +++ b/src/filesystem/winrt/SDL_sysfilesystem.cpp @@ -106,7 +106,7 @@ SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType) } const wchar_t *ucs2Path = SDL_WinRTGetFSPathUNICODE(pathType); - if (ucs2Path == NULL) { + if (!ucs2Path) { return NULL; } @@ -123,14 +123,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; } @@ -156,16 +156,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; } @@ -177,13 +177,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; diff --git a/src/haptic/SDL_haptic.c b/src/haptic/SDL_haptic.c index fbd776282..ad70f274a 100644 --- a/src/haptic/SDL_haptic.c +++ b/src/haptic/SDL_haptic.c @@ -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. */ diff --git a/src/haptic/android/SDL_syshaptic.c b/src/haptic/android/SDL_syshaptic.c index f65a26eff..65e7b3920 100644 --- a/src/haptic/android/SDL_syshaptic.c +++ b/src/haptic/android/SDL_syshaptic.c @@ -59,7 +59,7 @@ static SDL_hapticlist_item *HapticByOrder(int index) return NULL; } while (index > 0) { - SDL_assert(item != NULL); + SDL_assert(item); --index; item = item->next; } @@ -69,7 +69,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; @@ -81,7 +81,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; } @@ -90,11 +90,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; } @@ -106,7 +106,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; } @@ -138,7 +138,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) @@ -246,18 +246,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; @@ -273,12 +273,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); diff --git a/src/haptic/darwin/SDL_syshaptic.c b/src/haptic/darwin/SDL_syshaptic.c index d9e590482..9d50ac643 100644 --- a/src/haptic/darwin/SDL_syshaptic.c +++ b/src/haptic/darwin/SDL_syshaptic.c @@ -154,7 +154,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."); } @@ -193,7 +193,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; } @@ -226,7 +226,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"); } @@ -262,7 +262,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; @@ -284,12 +284,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); @@ -475,7 +475,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; } @@ -512,7 +512,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; } @@ -526,7 +526,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; } @@ -699,7 +699,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); @@ -772,7 +772,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)); @@ -787,7 +787,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. */ @@ -805,7 +805,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)); @@ -847,7 +847,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)); @@ -892,7 +892,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)); @@ -935,7 +935,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)); @@ -973,7 +973,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)); @@ -1033,7 +1033,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); @@ -1108,14 +1108,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; } diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c index a32e391f6..d1375c180 100644 --- a/src/haptic/linux/SDL_syshaptic.c +++ b/src/haptic/linux/SDL_syshaptic.c @@ -188,7 +188,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; } @@ -199,7 +199,7 @@ static SDL_hapticlist_item *HapticByDevIndex(int device_index) #ifdef 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; } @@ -225,7 +225,7 @@ static int MaybeAddDevice(const char *path) int success; SDL_hapticlist_item *item; - if (path == NULL) { + if (!path) { return -1; } @@ -235,7 +235,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. */ } @@ -259,12 +259,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; } @@ -272,7 +272,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; @@ -292,16 +292,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); @@ -358,7 +358,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; } @@ -376,7 +376,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; } @@ -396,7 +396,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; } @@ -409,7 +409,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; } @@ -904,7 +904,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(); } diff --git a/src/haptic/windows/SDL_dinputhaptic.c b/src/haptic/windows/SDL_dinputhaptic.c index 20901a165..a1225dd67 100644 --- a/src/haptic/windows/SDL_dinputhaptic.c +++ b/src/haptic/windows/SDL_dinputhaptic.c @@ -92,7 +92,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()); @@ -133,7 +133,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. */ } @@ -166,7 +166,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(); } @@ -188,11 +188,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); @@ -287,7 +287,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)); @@ -401,7 +401,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; } @@ -474,7 +474,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); @@ -540,7 +540,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); @@ -614,7 +614,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)); @@ -629,7 +629,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. */ @@ -647,7 +647,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)); @@ -689,7 +689,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)); @@ -733,7 +733,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)); @@ -774,7 +774,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)); @@ -812,7 +812,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)); @@ -871,7 +871,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); @@ -937,7 +937,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."); } diff --git a/src/haptic/windows/SDL_windowshaptic.c b/src/haptic/windows/SDL_windowshaptic.c index 1a2d5d638..a203f3e28 100644 --- a/src/haptic/windows/SDL_windowshaptic.c +++ b/src/haptic/windows/SDL_windowshaptic.c @@ -75,7 +75,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; @@ -91,7 +91,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); @@ -120,7 +120,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; } @@ -159,7 +159,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; } @@ -293,7 +293,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; } diff --git a/src/haptic/windows/SDL_xinputhaptic.c b/src/haptic/windows/SDL_xinputhaptic.c index d4add0da6..961f29407 100644 --- a/src/haptic/windows/SDL_xinputhaptic.c +++ b/src/haptic/windows/SDL_xinputhaptic.c @@ -79,7 +79,7 @@ int SDL_XINPUT_HapticMaybeAddDevice(const DWORD dwUserid) } item = (SDL_hapticlist_item *)SDL_malloc(sizeof(SDL_hapticlist_item)); - if (item == NULL) { + if (!item) { return SDL_OutOfMemory(); } @@ -114,7 +114,7 @@ int SDL_XINPUT_HapticMaybeRemoveDevice(const DWORD dwUserid) return -1; } - for (item = SDL_hapticlist; item != NULL; item = item->next) { + for (item = SDL_hapticlist; item; item = item->next) { if (item->bXInputHaptic && item->userid == userid) { /* found it, remove it. */ return SDL_SYS_RemoveHapticDevice(prev, item); @@ -173,7 +173,7 @@ static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 us /* Prepare effects memory. */ haptic->effects = (struct haptic_effect *) SDL_malloc(sizeof(struct haptic_effect) * haptic->neffects); - if (haptic->effects == NULL) { + if (!haptic->effects) { return SDL_OutOfMemory(); } /* Clear the memory */ @@ -181,7 +181,7 @@ static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 us sizeof(struct haptic_effect) * haptic->neffects); haptic->hwdata = (struct haptic_hwdata *)SDL_malloc(sizeof(*haptic->hwdata)); - if (haptic->hwdata == NULL) { + if (!haptic->hwdata) { SDL_free(haptic->effects); haptic->effects = NULL; return SDL_OutOfMemory(); @@ -192,7 +192,7 @@ static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 us haptic->hwdata->userid = userid; haptic->hwdata->mutex = SDL_CreateMutex(); - if (haptic->hwdata->mutex == NULL) { + if (!haptic->hwdata->mutex) { SDL_free(haptic->effects); SDL_free(haptic->hwdata); haptic->effects = NULL; @@ -202,7 +202,7 @@ static int SDL_XINPUT_HapticOpenFromUserIndex(SDL_Haptic *haptic, const Uint8 us (void)SDL_snprintf(threadName, sizeof(threadName), "SDLXInputDev%d", userid); haptic->hwdata->thread = SDL_CreateThreadInternal(SDL_RunXInputHaptic, threadName, 64 * 1024, haptic->hwdata); - if (haptic->hwdata->thread == NULL) { + if (!haptic->hwdata->thread) { SDL_DestroyMutex(haptic->hwdata->mutex); SDL_free(haptic->effects); SDL_free(haptic->hwdata); @@ -229,7 +229,7 @@ int SDL_XINPUT_HapticOpenFromJoystick(SDL_Haptic *haptic, SDL_Joystick *joystick Uint8 index = 0; /* 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 && item->userid == joystick->hwdata->userid) { haptic->index = index; return SDL_XINPUT_HapticOpenFromUserIndex(haptic, joystick->hwdata->userid); diff --git a/src/joystick/SDL_gamepad.c b/src/joystick/SDL_gamepad.c index 1af2159a5..7bba99801 100644 --- a/src/joystick/SDL_gamepad.c +++ b/src/joystick/SDL_gamepad.c @@ -197,7 +197,7 @@ static void HandleJoystickAxis(Uint64 timestamp, SDL_Gamepad *gamepad, int axis, } } - if (last_match && (match == NULL || !HasSameOutput(last_match, match))) { + if (last_match && (!match || !HasSameOutput(last_match, match))) { /* Clear the last input that this axis generated */ ResetOutput(timestamp, gamepad, last_match); } @@ -987,7 +987,7 @@ SDL_GamepadType SDL_GetGamepadTypeFromString(const char *str) { int i; - if (str == NULL || str[0] == '\0') { + if (!str || str[0] == '\0') { return SDL_GAMEPAD_TYPE_UNKNOWN; } @@ -1031,7 +1031,7 @@ SDL_GamepadAxis SDL_GetGamepadAxisFromString(const char *str) { int i; - if (str == NULL || str[0] == '\0') { + if (!str || str[0] == '\0') { return SDL_GAMEPAD_AXIS_INVALID; } @@ -1090,7 +1090,7 @@ SDL_GamepadButton SDL_GetGamepadButtonFromString(const char *str) { int i; - if (str == NULL || str[0] == '\0') { + if (!str || str[0] == '\0') { return SDL_GAMEPAD_BUTTON_INVALID; } @@ -1269,7 +1269,7 @@ static void SDL_PrivateLoadButtonMapping(SDL_Gamepad *gamepad, GamepadMapping_t gamepad->name = pGamepadMapping->name; gamepad->num_bindings = 0; gamepad->mapping = pGamepadMapping; - if (gamepad->joystick->naxes != 0 && gamepad->last_match_axis != NULL) { + if (gamepad->joystick->naxes != 0 && gamepad->last_match_axis) { SDL_memset(gamepad->last_match_axis, 0, gamepad->joystick->naxes * sizeof(*gamepad->last_match_axis)); } @@ -1298,7 +1298,7 @@ static char *SDL_PrivateGetGamepadGUIDFromMappingString(const char *pMapping) const char *pFirstComma = SDL_strchr(pMapping, ','); if (pFirstComma) { char *pchGUID = SDL_malloc(pFirstComma - pMapping + 1); - if (pchGUID == NULL) { + if (!pchGUID) { SDL_OutOfMemory(); return NULL; } @@ -1337,17 +1337,17 @@ static char *SDL_PrivateGetGamepadNameFromMappingString(const char *pMapping) char *pchName; pFirstComma = SDL_strchr(pMapping, ','); - if (pFirstComma == NULL) { + if (!pFirstComma) { return NULL; } pSecondComma = SDL_strchr(pFirstComma + 1, ','); - if (pSecondComma == NULL) { + if (!pSecondComma) { return NULL; } pchName = SDL_malloc(pSecondComma - pFirstComma); - if (pchName == NULL) { + if (!pchName) { SDL_OutOfMemory(); return NULL; } @@ -1366,12 +1366,12 @@ static char *SDL_PrivateGetGamepadMappingFromMappingString(const char *pMapping) size_t length; pFirstComma = SDL_strchr(pMapping, ','); - if (pFirstComma == NULL) { + if (!pFirstComma) { return NULL; } pSecondComma = SDL_strchr(pFirstComma + 1, ','); - if (pSecondComma == NULL) { + if (!pSecondComma) { return NULL; } @@ -1405,13 +1405,13 @@ static GamepadMapping_t *SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, co SDL_AssertJoysticksLocked(); pchName = SDL_PrivateGetGamepadNameFromMappingString(mappingString); - if (pchName == NULL) { + if (!pchName) { SDL_SetError("Couldn't parse name from %s", mappingString); return NULL; } pchMapping = SDL_PrivateGetGamepadMappingFromMappingString(mappingString); - if (pchMapping == NULL) { + if (!pchMapping) { SDL_free(pchName); SDL_SetError("Couldn't parse %s", mappingString); return NULL; @@ -1481,7 +1481,7 @@ static GamepadMapping_t *SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, co AddMappingChangeTracking(pGamepadMapping); } else { pGamepadMapping = SDL_malloc(sizeof(*pGamepadMapping)); - if (pGamepadMapping == NULL) { + if (!pGamepadMapping) { PopMappingChangeTracking(); SDL_free(pchName); SDL_free(pchMapping); @@ -1532,7 +1532,7 @@ static GamepadMapping_t *SDL_PrivateGetGamepadMappingForNameAndGUID(const char * mapping = SDL_PrivateGetGamepadMappingForGUID(guid, SDL_FALSE); #ifdef __LINUX__ - if (mapping == NULL && name) { + if (!mapping && name) { if (SDL_strstr(name, "Xbox 360 Wireless Receiver")) { /* The Linux driver xpad.c maps the wireless dpad to buttons */ SDL_bool existing; @@ -1543,7 +1543,7 @@ static GamepadMapping_t *SDL_PrivateGetGamepadMappingForNameAndGUID(const char * } #endif /* __LINUX__ */ - if (mapping == NULL) { + if (!mapping) { mapping = s_pDefaultMapping; } return mapping; @@ -1641,7 +1641,7 @@ static GamepadMapping_t *SDL_PrivateGetGamepadMapping(SDL_JoystickID instance_id name = SDL_GetJoystickInstanceName(instance_id); guid = SDL_GetJoystickInstanceGUID(instance_id); mapping = SDL_PrivateGetGamepadMappingForNameAndGUID(name, guid); - if (mapping == NULL) { + if (!mapping) { SDL_GamepadMapping raw_map; SDL_zero(raw_map); @@ -1665,7 +1665,7 @@ int SDL_AddGamepadMappingsFromRW(SDL_RWops *src, SDL_bool freesrc) size_t platform_len; buf = (char *)SDL_LoadFile_RW(src, &db_size, freesrc); - if (buf == NULL) { + if (!buf) { return SDL_SetError("Could not allocate space to read DB into memory"); } line = buf; @@ -1676,7 +1676,7 @@ int SDL_AddGamepadMappingsFromRW(SDL_RWops *src, SDL_bool freesrc) while (line < buf + db_size) { line_end = SDL_strchr(line, '\n'); - if (line_end != NULL) { + if (line_end) { *line_end = '\0'; } else { line_end = buf + db_size; @@ -1684,10 +1684,10 @@ int SDL_AddGamepadMappingsFromRW(SDL_RWops *src, SDL_bool freesrc) /* Extract and verify the platform */ tmp = SDL_strstr(line, SDL_GAMEPAD_PLATFORM_FIELD); - if (tmp != NULL) { + if (tmp) { tmp += SDL_GAMEPAD_PLATFORM_FIELD_SIZE; comma = SDL_strchr(tmp, ','); - if (comma != NULL) { + if (comma) { platform_len = comma - tmp + 1; if (platform_len + 1 < SDL_arraysize(line_platform)) { SDL_strlcpy(line_platform, tmp, platform_len); @@ -1751,7 +1751,7 @@ static int SDL_PrivateAddGamepadMapping(const char *mappingString, SDL_GamepadMa SDL_AssertJoysticksLocked(); - if (mappingString == NULL) { + if (!mappingString) { return SDL_InvalidParamError("mappingString"); } @@ -1759,7 +1759,7 @@ static int SDL_PrivateAddGamepadMapping(const char *mappingString, SDL_GamepadMa const char *tmp; tmp = SDL_strstr(mappingString, SDL_GAMEPAD_HINT_FIELD); - if (tmp != NULL) { + if (tmp) { SDL_bool default_value, value, negate; int len; char hint[128]; @@ -1801,14 +1801,14 @@ static int SDL_PrivateAddGamepadMapping(const char *mappingString, SDL_GamepadMa const char *tmp; tmp = SDL_strstr(mappingString, SDL_GAMEPAD_SDKGE_FIELD); - if (tmp != NULL) { + if (tmp) { tmp += SDL_GAMEPAD_SDKGE_FIELD_SIZE; if (!(SDL_GetAndroidSDKVersion() >= SDL_atoi(tmp))) { return SDL_SetError("SDK version %d < minimum version %d", SDL_GetAndroidSDKVersion(), SDL_atoi(tmp)); } } tmp = SDL_strstr(mappingString, SDL_GAMEPAD_SDKLE_FIELD); - if (tmp != NULL) { + if (tmp) { tmp += SDL_GAMEPAD_SDKLE_FIELD_SIZE; if (!(SDL_GetAndroidSDKVersion() <= SDL_atoi(tmp))) { return SDL_SetError("SDK version %d > maximum version %d", SDL_GetAndroidSDKVersion(), SDL_atoi(tmp)); @@ -1818,7 +1818,7 @@ static int SDL_PrivateAddGamepadMapping(const char *mappingString, SDL_GamepadMa #endif pchGUID = SDL_PrivateGetGamepadGUIDFromMappingString(mappingString); - if (pchGUID == NULL) { + if (!pchGUID) { return SDL_SetError("Couldn't parse GUID from %s", mappingString); } if (!SDL_strcasecmp(pchGUID, "default")) { @@ -1830,7 +1830,7 @@ static int SDL_PrivateAddGamepadMapping(const char *mappingString, SDL_GamepadMa SDL_free(pchGUID); pGamepadMapping = SDL_PrivateAddMappingForGUID(jGUID, mappingString, &existing, priority); - if (pGamepadMapping == NULL) { + if (!pGamepadMapping) { return -1; } @@ -1914,7 +1914,7 @@ static char *CreateMappingString(GamepadMapping_t *mapping, SDL_JoystickGUID gui } pMappingString = SDL_malloc(needed); - if (pMappingString == NULL) { + if (!pMappingString) { SDL_OutOfMemory(); return NULL; } @@ -1965,7 +1965,7 @@ char *SDL_GetGamepadMappingForIndex(int mapping_index) } SDL_UnlockJoysticks(); - if (retval == NULL) { + if (!retval) { SDL_SetError("Mapping not available"); } return retval; @@ -2179,7 +2179,7 @@ const char *SDL_GetGamepadInstanceName(SDL_JoystickID instance_id) SDL_LockJoysticks(); { GamepadMapping_t *mapping = SDL_PrivateGetGamepadMapping(instance_id); - if (mapping != NULL) { + if (mapping) { if (SDL_strcmp(mapping->name, "*") == 0) { retval = SDL_GetJoystickInstanceName(instance_id); } else { @@ -2229,14 +2229,14 @@ SDL_GamepadType SDL_GetGamepadInstanceType(SDL_JoystickID instance_id) SDL_LockJoysticks(); { GamepadMapping_t *mapping = SDL_PrivateGetGamepadMapping(instance_id); - if (mapping != NULL) { + if (mapping) { char *type_string, *comma; type_string = SDL_strstr(mapping->mapping, SDL_GAMEPAD_TYPE_FIELD); - if (type_string != NULL) { + if (type_string) { type_string += SDL_GAMEPAD_TYPE_FIELD_SIZE; comma = SDL_strchr(type_string, ','); - if (comma != NULL) { + if (comma) { *comma = '\0'; type = SDL_GetGamepadTypeFromString(type_string); *comma = ','; @@ -2265,7 +2265,7 @@ char *SDL_GetGamepadInstanceMapping(SDL_JoystickID instance_id) SDL_LockJoysticks(); { GamepadMapping_t *mapping = SDL_PrivateGetGamepadMapping(instance_id); - if (mapping != NULL) { + if (mapping) { SDL_JoystickGUID guid; char pchGUID[33]; size_t needed; @@ -2274,7 +2274,7 @@ char *SDL_GetGamepadInstanceMapping(SDL_JoystickID instance_id) /* allocate enough memory for GUID + ',' + name + ',' + mapping + \0 */ needed = SDL_strlen(pchGUID) + 1 + SDL_strlen(mapping->name) + 1 + SDL_strlen(mapping->mapping) + 1; retval = (char *)SDL_malloc(needed); - if (retval != NULL) { + if (retval) { (void)SDL_snprintf(retval, needed, "%s,%s,%s", pchGUID, mapping->name, mapping->mapping); } else { SDL_OutOfMemory(); @@ -2409,7 +2409,7 @@ SDL_Gamepad *SDL_OpenGamepad(SDL_JoystickID instance_id) gamepadlist = SDL_gamepads; /* If the gamepad is already open, return it */ - while (gamepadlist != NULL) { + while (gamepadlist) { if (instance_id == gamepadlist->joystick->instance_id) { gamepad = gamepadlist; ++gamepad->ref_count; @@ -2421,7 +2421,7 @@ SDL_Gamepad *SDL_OpenGamepad(SDL_JoystickID instance_id) /* Find a gamepad mapping */ pSupportedGamepad = SDL_PrivateGetGamepadMapping(instance_id); - if (pSupportedGamepad == NULL) { + if (!pSupportedGamepad) { SDL_SetError("Couldn't find mapping for device (%" SDL_PRIu32 ")", instance_id); SDL_UnlockJoysticks(); return NULL; @@ -2429,7 +2429,7 @@ SDL_Gamepad *SDL_OpenGamepad(SDL_JoystickID instance_id) /* Create and initialize the gamepad */ gamepad = (SDL_Gamepad *)SDL_calloc(1, sizeof(*gamepad)); - if (gamepad == NULL) { + if (!gamepad) { SDL_OutOfMemory(); SDL_UnlockJoysticks(); return NULL; @@ -2437,7 +2437,7 @@ SDL_Gamepad *SDL_OpenGamepad(SDL_JoystickID instance_id) gamepad->magic = &gamepad_magic; gamepad->joystick = SDL_OpenJoystick(instance_id); - if (gamepad->joystick == NULL) { + if (!gamepad->joystick) { SDL_free(gamepad); SDL_UnlockJoysticks(); return NULL; @@ -2923,7 +2923,7 @@ SDL_JoystickID SDL_GetGamepadInstanceID(SDL_Gamepad *gamepad) { SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad); - if (joystick == NULL) { + if (!joystick) { return 0; } return SDL_GetJoystickInstanceID(joystick); @@ -2967,7 +2967,7 @@ const char *SDL_GetGamepadPath(SDL_Gamepad *gamepad) { SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad); - if (joystick == NULL) { + if (!joystick) { return NULL; } return SDL_GetJoystickPath(joystick); @@ -2992,7 +2992,7 @@ SDL_GamepadType SDL_GetRealGamepadType(SDL_Gamepad *gamepad) { SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad); - if (joystick == NULL) { + if (!joystick) { return SDL_GAMEPAD_TYPE_UNKNOWN; } return SDL_GetGamepadTypeFromGUID(SDL_GetJoystickGUID(joystick), SDL_GetJoystickName(joystick)); @@ -3002,7 +3002,7 @@ int SDL_GetGamepadPlayerIndex(SDL_Gamepad *gamepad) { SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad); - if (joystick == NULL) { + if (!joystick) { return -1; } return SDL_GetJoystickPlayerIndex(joystick); @@ -3015,7 +3015,7 @@ int SDL_SetGamepadPlayerIndex(SDL_Gamepad *gamepad, int player_index) { SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad); - if (joystick == NULL) { + if (!joystick) { /* SDL_SetError() will have been called already by SDL_GetGamepadJoystick() */ return -1; } @@ -3026,7 +3026,7 @@ Uint16 SDL_GetGamepadVendor(SDL_Gamepad *gamepad) { SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad); - if (joystick == NULL) { + if (!joystick) { return 0; } return SDL_GetJoystickVendor(joystick); @@ -3036,7 +3036,7 @@ Uint16 SDL_GetGamepadProduct(SDL_Gamepad *gamepad) { SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad); - if (joystick == NULL) { + if (!joystick) { return 0; } return SDL_GetJoystickProduct(joystick); @@ -3046,7 +3046,7 @@ Uint16 SDL_GetGamepadProductVersion(SDL_Gamepad *gamepad) { SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad); - if (joystick == NULL) { + if (!joystick) { return 0; } return SDL_GetJoystickProductVersion(joystick); @@ -3056,7 +3056,7 @@ Uint16 SDL_GetGamepadFirmwareVersion(SDL_Gamepad *gamepad) { SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad); - if (joystick == NULL) { + if (!joystick) { return 0; } return SDL_GetJoystickFirmwareVersion(joystick); @@ -3066,7 +3066,7 @@ const char * SDL_GetGamepadSerial(SDL_Gamepad *gamepad) { SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad); - if (joystick == NULL) { + if (!joystick) { return NULL; } return SDL_GetJoystickSerial(joystick); @@ -3076,7 +3076,7 @@ SDL_JoystickPowerLevel SDL_GetGamepadPowerLevel(SDL_Gamepad *gamepad) { SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad); - if (joystick == NULL) { + if (!joystick) { return SDL_JOYSTICK_POWER_UNKNOWN; } return SDL_GetJoystickPowerLevel(joystick); @@ -3090,7 +3090,7 @@ SDL_bool SDL_GamepadConnected(SDL_Gamepad *gamepad) { SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad); - if (joystick == NULL) { + if (!joystick) { return SDL_FALSE; } return SDL_JoystickConnected(joystick); @@ -3196,7 +3196,7 @@ int SDL_RumbleGamepad(SDL_Gamepad *gamepad, Uint16 low_frequency_rumble, Uint16 { SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad); - if (joystick == NULL) { + if (!joystick) { return -1; } return SDL_RumbleJoystick(joystick, low_frequency_rumble, high_frequency_rumble, duration_ms); @@ -3206,7 +3206,7 @@ int SDL_RumbleGamepadTriggers(SDL_Gamepad *gamepad, Uint16 left_rumble, Uint16 r { SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad); - if (joystick == NULL) { + if (!joystick) { return -1; } return SDL_RumbleJoystickTriggers(joystick, left_rumble, right_rumble, duration_ms); @@ -3216,7 +3216,7 @@ SDL_bool SDL_GamepadHasLED(SDL_Gamepad *gamepad) { SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad); - if (joystick == NULL) { + if (!joystick) { return SDL_FALSE; } return SDL_JoystickHasLED(joystick); @@ -3226,7 +3226,7 @@ SDL_bool SDL_GamepadHasRumble(SDL_Gamepad *gamepad) { SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad); - if (joystick == NULL) { + if (!joystick) { return SDL_FALSE; } return SDL_JoystickHasRumble(joystick); @@ -3236,7 +3236,7 @@ SDL_bool SDL_GamepadHasRumbleTriggers(SDL_Gamepad *gamepad) { SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad); - if (joystick == NULL) { + if (!joystick) { return SDL_FALSE; } return SDL_JoystickHasRumbleTriggers(joystick); @@ -3246,7 +3246,7 @@ int SDL_SetGamepadLED(SDL_Gamepad *gamepad, Uint8 red, Uint8 green, Uint8 blue) { SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad); - if (joystick == NULL) { + if (!joystick) { return -1; } return SDL_SetJoystickLED(joystick, red, green, blue); @@ -3256,7 +3256,7 @@ int SDL_SendGamepadEffect(SDL_Gamepad *gamepad, const void *data, int size) { SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad); - if (joystick == NULL) { + if (!joystick) { return -1; } return SDL_SendJoystickEffect(joystick, data, size); @@ -3268,7 +3268,7 @@ void SDL_CloseGamepad(SDL_Gamepad *gamepad) SDL_LockJoysticks(); - if (gamepad == NULL || gamepad->magic != &gamepad_magic) { + if (!gamepad || gamepad->magic != &gamepad_magic) { SDL_UnlockJoysticks(); return; } diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index 062d0626a..3d030e179 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -269,7 +269,7 @@ static SDL_bool SDL_SetJoystickIDForPlayerIndex(int player_index, SDL_JoystickID if (player_index >= SDL_joystick_player_count) { SDL_JoystickID *new_players = (SDL_JoystickID *)SDL_realloc(SDL_joystick_players, (player_index + 1) * sizeof(*SDL_joystick_players)); - if (new_players == NULL) { + if (!new_players) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -447,7 +447,7 @@ const char *SDL_GetJoystickInstancePath(SDL_JoystickID instance_id) SDL_UnlockJoysticks(); /* FIXME: Really we should reference count this path so it doesn't go away after unlock */ - if (path == NULL) { + if (!path) { SDL_Unsupported(); } return path; @@ -754,7 +754,7 @@ SDL_Joystick *SDL_OpenJoystick(SDL_JoystickID instance_id) /* Create and initialize the joystick */ joystick = (SDL_Joystick *)SDL_calloc(sizeof(*joystick), 1); - if (joystick == NULL) { + if (!joystick) { SDL_OutOfMemory(); SDL_UnlockJoysticks(); return NULL; @@ -2145,10 +2145,10 @@ char *SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_n return SDL_strdup(custom_name); } - if (vendor_name == NULL) { + if (!vendor_name) { vendor_name = ""; } - if (product_name == NULL) { + if (!product_name) { product_name = ""; } @@ -2191,7 +2191,7 @@ char *SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_n default: len = (6 + 1 + 6 + 1); name = (char *)SDL_malloc(len); - if (name != NULL) { + if (name) { (void)SDL_snprintf(name, len, "0x%.4x/0x%.4x", vendor, product); } break; @@ -2200,7 +2200,7 @@ char *SDL_CreateJoystickName(Uint16 vendor, Uint16 product, const char *vendor_n name = SDL_strdup("Controller"); } - if (name == NULL) { + if (!name) { return NULL; } @@ -2264,7 +2264,7 @@ SDL_JoystickGUID SDL_CreateJoystickGUID(Uint16 bus, Uint16 vendor, Uint16 produc SDL_zero(guid); - if (name == NULL) { + if (!name) { name = ""; } @@ -3367,7 +3367,7 @@ void SDL_LoadVIDPIDListFromHint(const char *hint, SDL_vidpid_list *list) spot = (char *)hint; } - if (spot == NULL) { + if (!spot) { return; } @@ -3375,7 +3375,7 @@ void SDL_LoadVIDPIDListFromHint(const char *hint, SDL_vidpid_list *list) entry = (Uint16)SDL_strtol(spot, &spot, 0); entry <<= 16; spot = SDL_strstr(spot, "0x"); - if (spot == NULL) { + if (!spot) { break; } entry |= (Uint16)SDL_strtol(spot, &spot, 0); @@ -3383,7 +3383,7 @@ void SDL_LoadVIDPIDListFromHint(const char *hint, SDL_vidpid_list *list) if (list->num_entries == list->max_entries) { int max_entries = list->max_entries + 16; Uint32 *entries = (Uint32 *)SDL_realloc(list->entries, max_entries * sizeof(*list->entries)); - if (entries == NULL) { + if (!entries) { /* Out of memory, go with what we have already */ break; } diff --git a/src/joystick/android/SDL_sysjoystick.c b/src/joystick/android/SDL_sysjoystick.c index 0b635ba5c..7333b18d8 100644 --- a/src/joystick/android/SDL_sysjoystick.c +++ b/src/joystick/android/SDL_sysjoystick.c @@ -319,7 +319,7 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v } } - if (JoystickByDeviceId(device_id) != NULL || name == NULL) { + if (JoystickByDeviceId(device_id) != NULL || !name) { goto done; } @@ -353,7 +353,7 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v } item = (SDL_joylist_item *)SDL_malloc(sizeof(SDL_joylist_item)); - if (item == NULL) { + if (!item) { goto done; } @@ -361,7 +361,7 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v item->guid = guid; item->device_id = device_id; item->name = SDL_CreateJoystickName(vendor_id, product_id, NULL, name); - if (item->name == NULL) { + if (!item->name) { SDL_free(item); goto done; } @@ -379,7 +379,7 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v item->naxes = naxes; item->nhats = nhats; item->device_instance = SDL_GetNextObjectID(); - if (SDL_joylist_tail == NULL) { + if (!SDL_joylist_tail) { SDL_joylist = SDL_joylist_tail = item; } else { SDL_joylist_tail->next = item; @@ -412,7 +412,7 @@ int Android_RemoveJoystick(int device_id) SDL_LockJoysticks(); /* Don't call JoystickByDeviceId here or there'll be an infinite loop! */ - while (item != NULL) { + while (item) { if (item->device_id == device_id) { break; } @@ -420,7 +420,7 @@ int Android_RemoveJoystick(int device_id) item = item->next; } - if (item == NULL) { + if (!item) { goto done; } @@ -428,7 +428,7 @@ int Android_RemoveJoystick(int device_id) item->joystick->hwdata = NULL; } - if (prev != NULL) { + if (prev) { prev->next = item->next; } else { SDL_assert(SDL_joylist == item); @@ -499,7 +499,7 @@ static SDL_joylist_item *GetJoystickByDevIndex(int device_index) } while (device_index > 0) { - SDL_assert(item != NULL); + SDL_assert(item); device_index--; item = item->next; } @@ -511,7 +511,7 @@ static SDL_joylist_item *JoystickByDeviceId(int device_id) { SDL_joylist_item *item = SDL_joylist; - while (item != NULL) { + while (item) { if (item->device_id == device_id) { return item; } @@ -521,7 +521,7 @@ static SDL_joylist_item *JoystickByDeviceId(int device_id) /* Joystick not found, try adding it */ ANDROID_JoystickDetect(); - while (item != NULL) { + while (item) { if (item->device_id == device_id) { return item; } @@ -564,11 +564,11 @@ static int ANDROID_JoystickOpen(SDL_Joystick *joystick, int device_index) { SDL_joylist_item *item = GetJoystickByDevIndex(device_index); - if (item == NULL) { + if (!item) { return SDL_SetError("No such device"); } - if (item->joystick != NULL) { + if (item->joystick) { return SDL_SetError("Joystick already opened"); } @@ -616,7 +616,7 @@ static void ANDROID_JoystickUpdate(SDL_Joystick *joystick) { SDL_joylist_item *item = (SDL_joylist_item *)joystick->hwdata; - if (item == NULL) { + if (!item) { return; } diff --git a/src/joystick/bsd/SDL_bsdjoystick.c b/src/joystick/bsd/SDL_bsdjoystick.c index 176e5eebd..f764d16f6 100644 --- a/src/joystick/bsd/SDL_bsdjoystick.c +++ b/src/joystick/bsd/SDL_bsdjoystick.c @@ -268,7 +268,7 @@ CreateHwData(const char *path) hw = (struct joystick_hwdata *) SDL_calloc(1, sizeof(struct joystick_hwdata)); - if (hw == NULL) { + if (!hw) { close(fd); SDL_OutOfMemory(); return NULL; @@ -291,7 +291,7 @@ CreateHwData(const char *path) } } hw->repdesc = hid_get_report_desc(fd); - if (hw->repdesc == NULL) { + if (!hw->repdesc) { SDL_SetError("%s: USB_GET_REPORT_DESC: %s", path, strerror(errno)); goto usberr; @@ -318,7 +318,7 @@ CreateHwData(const char *path) #else hdata = hid_start_parse(hw->repdesc, 1 << hid_input); #endif - if (hdata == NULL) { + if (!hdata) { SDL_SetError("%s: Cannot start HID parser", path); goto usberr; } @@ -398,7 +398,7 @@ static int MaybeAddDevice(const char *path) SDL_joylist_item *item; struct joystick_hwdata *hw; - if (path == NULL) { + if (!path) { return -1; } @@ -407,14 +407,14 @@ static int MaybeAddDevice(const char *path) } /* Check to make sure it's not already in list. */ - for (item = SDL_joylist; item != NULL; item = item->next) { + for (item = SDL_joylist; item; item = item->next) { if (sb.st_rdev == item->devnum) { return -1; /* already have this one */ } } hw = CreateHwData(path); - if (hw == NULL) { + if (!hw) { return -1; } @@ -444,14 +444,14 @@ static int MaybeAddDevice(const char *path) } #endif /* USB_GET_DEVICEINFO */ } - if (name == NULL) { + if (!name) { name = SDL_strdup(path); guid = SDL_CreateJoystickGUIDForName(name); } FreeHwData(hw); item = (SDL_joylist_item *)SDL_calloc(1, sizeof(SDL_joylist_item)); - if (item == NULL) { + if (!item) { SDL_free(name); return -1; } @@ -461,13 +461,13 @@ static int MaybeAddDevice(const char *path) item->name = name; item->guid = guid; - if ((item->path == NULL) || (item->name == NULL)) { + if ((!item->path) || (!item->name)) { FreeJoylistItem(item); return -1; } item->device_instance = SDL_GetNextObjectID(); - if (SDL_joylist_tail == NULL) { + if (!SDL_joylist_tail) { SDL_joylist = SDL_joylist_tail = item; } else { SDL_joylist_tail->next = item; @@ -526,7 +526,7 @@ static SDL_joylist_item *GetJoystickByDevIndex(int device_index) } while (device_index > 0) { - SDL_assert(item != NULL); + SDL_assert(item); device_index--; item = item->next; } @@ -583,12 +583,12 @@ static int BSD_JoystickOpen(SDL_Joystick *joy, int device_index) SDL_joylist_item *item = GetJoystickByDevIndex(device_index); struct joystick_hwdata *hw; - if (item == NULL) { + if (!item) { return SDL_SetError("No such device"); } hw = CreateHwData(item->path); - if (hw == NULL) { + if (!hw) { return -1; } @@ -664,7 +664,7 @@ static void BSD_JoystickUpdate(SDL_Joystick *joy) #else hdata = hid_start_parse(joy->hwdata->repdesc, 1 << hid_input); #endif - if (hdata == NULL) { + if (!hdata) { /*fprintf(stderr, "%s: Cannot start HID parser\n", joy->hwdata->path);*/ continue; } @@ -793,7 +793,7 @@ static int report_alloc(struct report *r, struct report_desc *rd, int repind) r->buf = SDL_malloc(sizeof(*r->buf) - sizeof(REP_BUF_DATA(r)) + r->size); #endif - if (r->buf == NULL) { + if (!r->buf) { return SDL_OutOfMemory(); } } else { diff --git a/src/joystick/darwin/SDL_iokitjoystick.c b/src/joystick/darwin/SDL_iokitjoystick.c index 92650b7d4..288909504 100644 --- a/src/joystick/darwin/SDL_iokitjoystick.c +++ b/src/joystick/darwin/SDL_iokitjoystick.c @@ -40,7 +40,7 @@ static recDevice *gpDeviceList = NULL; void FreeRumbleEffectData(FFEFFECT *effect) { - if (effect == NULL) { + if (!effect) { return; } SDL_free(effect->rgdwAxes); @@ -56,7 +56,7 @@ FFEFFECT *CreateRumbleEffectData(Sint16 magnitude) /* Create the effect */ effect = (FFEFFECT *)SDL_calloc(1, sizeof(*effect)); - if (effect == NULL) { + if (!effect) { return NULL; } effect->dwSize = sizeof(*effect); @@ -80,7 +80,7 @@ FFEFFECT *CreateRumbleEffectData(Sint16 magnitude) effect->dwFlags |= FFEFF_CARTESIAN; periodic = (FFPERIODIC *)SDL_calloc(1, sizeof(*periodic)); - if (periodic == NULL) { + if (!periodic) { FreeRumbleEffectData(effect); return NULL; } @@ -506,7 +506,7 @@ static SDL_bool JoystickAlreadyKnown(IOHIDDeviceRef ioHIDDeviceObject) } #endif - for (i = gpDeviceList; i != NULL; i = i->pNext) { + for (i = gpDeviceList; i; i = i->pNext) { if (i->deviceRef == ioHIDDeviceObject) { return SDL_TRUE; } @@ -528,7 +528,7 @@ static void JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender } device = (recDevice *)SDL_calloc(1, sizeof(recDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return; } @@ -561,13 +561,13 @@ static void JoystickDeviceWasAddedCallback(void *ctx, IOReturn res, void *sender } /* Add device to the end of the list */ - if (gpDeviceList == NULL) { + if (!gpDeviceList) { gpDeviceList = device; } else { recDevice *curdevice; curdevice = gpDeviceList; - while (curdevice->pNext != NULL) { + while (curdevice->pNext) { curdevice = curdevice->pNext; } curdevice->pNext = device; @@ -851,7 +851,7 @@ static int DARWIN_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_ru /* Scale and average the two rumble strengths */ Sint16 magnitude = (Sint16)(((low_frequency_rumble / 2) + (high_frequency_rumble / 2)) / 2); - if (device == NULL) { + if (!device) { return SDL_SetError("Rumble failed, device disconnected"); } @@ -892,7 +892,7 @@ static Uint32 DARWIN_JoystickGetCapabilities(SDL_Joystick *joystick) recDevice *device = joystick->hwdata; Uint32 result = 0; - if (device == NULL) { + if (!device) { return 0; } @@ -926,7 +926,7 @@ static void DARWIN_JoystickUpdate(SDL_Joystick *joystick) int i, goodRead = SDL_FALSE; Uint64 timestamp = SDL_GetTicksNS(); - if (device == NULL) { + if (!device) { return; } diff --git a/src/joystick/emscripten/SDL_sysjoystick.c b/src/joystick/emscripten/SDL_sysjoystick.c index dbce13375..abf074d9b 100644 --- a/src/joystick/emscripten/SDL_sysjoystick.c +++ b/src/joystick/emscripten/SDL_sysjoystick.c @@ -45,7 +45,7 @@ static EM_BOOL Emscripten_JoyStickConnected(int eventType, const EmscriptenGamep } item = (SDL_joylist_item *)SDL_malloc(sizeof(SDL_joylist_item)); - if (item == NULL) { + if (!item) { return 1; } @@ -53,13 +53,13 @@ static EM_BOOL Emscripten_JoyStickConnected(int eventType, const EmscriptenGamep item->index = gamepadEvent->index; item->name = SDL_CreateJoystickName(0, 0, NULL, gamepadEvent->id); - if (item->name == NULL) { + if (!item->name) { SDL_free(item); return 1; } item->mapping = SDL_strdup(gamepadEvent->mapping); - if (item->mapping == NULL) { + if (!item->mapping) { SDL_free(item->name); SDL_free(item); return 1; @@ -80,7 +80,7 @@ static EM_BOOL Emscripten_JoyStickConnected(int eventType, const EmscriptenGamep item->digitalButton[i] = gamepadEvent->digitalButton[i]; } - if (SDL_joylist_tail == NULL) { + if (!SDL_joylist_tail) { SDL_joylist = SDL_joylist_tail = item; } else { SDL_joylist_tail->next = item; @@ -106,7 +106,7 @@ static EM_BOOL Emscripten_JoyStickDisconnected(int eventType, const EmscriptenGa SDL_joylist_item *item = SDL_joylist; SDL_joylist_item *prev = NULL; - while (item != NULL) { + while (item) { if (item->index == gamepadEvent->index) { break; } @@ -114,7 +114,7 @@ static EM_BOOL Emscripten_JoyStickDisconnected(int eventType, const EmscriptenGa item = item->next; } - if (item == NULL) { + if (!item) { return 1; } @@ -122,7 +122,7 @@ static EM_BOOL Emscripten_JoyStickDisconnected(int eventType, const EmscriptenGa item->joystick->hwdata = NULL; } - if (prev != NULL) { + if (prev) { prev->next = item->next; } else { SDL_assert(SDL_joylist == item); @@ -240,7 +240,7 @@ static SDL_joylist_item *JoystickByIndex(int index) return NULL; } - while (item != NULL) { + while (item) { if (item->index == index) { break; } @@ -292,11 +292,11 @@ static int EMSCRIPTEN_JoystickOpen(SDL_Joystick *joystick, int device_index) { SDL_joylist_item *item = JoystickByDeviceIndex(device_index); - if (item == NULL) { + if (!item) { return SDL_SetError("No such device"); } - if (item->joystick != NULL) { + if (item->joystick) { return SDL_SetError("Joystick already opened"); } diff --git a/src/joystick/hidapi/SDL_hidapi_gamecube.c b/src/joystick/hidapi/SDL_hidapi_gamecube.c index c108e5cc0..182f00b1b 100644 --- a/src/joystick/hidapi/SDL_hidapi_gamecube.c +++ b/src/joystick/hidapi/SDL_hidapi_gamecube.c @@ -135,7 +135,7 @@ static SDL_bool HIDAPI_DriverGameCube_InitDevice(SDL_HIDAPI_Device *device) #endif ctx = (SDL_DriverGameCube_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -245,7 +245,7 @@ static void HIDAPI_DriverGameCube_HandleJoystickPacket(SDL_HIDAPI_Device *device } joystick = SDL_GetJoystickFromInstanceID(ctx->joysticks[i]); - if (joystick == NULL) { + if (!joystick) { /* Hasn't been opened yet, skip */ return; } @@ -322,7 +322,7 @@ static void HIDAPI_DriverGameCube_HandleNintendoPacket(SDL_HIDAPI_Device *device joystick = SDL_GetJoystickFromInstanceID(ctx->joysticks[i]); /* Hasn't been opened yet, skip */ - if (joystick == NULL) { + if (!joystick) { continue; } } else { diff --git a/src/joystick/hidapi/SDL_hidapi_luna.c b/src/joystick/hidapi/SDL_hidapi_luna.c index f0f1923c5..d4ee4ada8 100644 --- a/src/joystick/hidapi/SDL_hidapi_luna.c +++ b/src/joystick/hidapi/SDL_hidapi_luna.c @@ -72,7 +72,7 @@ static SDL_bool HIDAPI_DriverLuna_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverLuna_Context *ctx; ctx = (SDL_DriverLuna_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -393,7 +393,7 @@ static SDL_bool HIDAPI_DriverLuna_UpdateDevice(SDL_HIDAPI_Device *device) #ifdef DEBUG_LUNA_PROTOCOL HIDAPI_DumpPacket("Amazon Luna packet: size = %d", data, size); #endif - if (joystick == NULL) { + if (!joystick) { continue; } diff --git a/src/joystick/hidapi/SDL_hidapi_ps3.c b/src/joystick/hidapi/SDL_hidapi_ps3.c index a84dd4b47..da309f7ef 100644 --- a/src/joystick/hidapi/SDL_hidapi_ps3.c +++ b/src/joystick/hidapi/SDL_hidapi_ps3.c @@ -134,7 +134,7 @@ static SDL_bool HIDAPI_DriverPS3_InitDevice(SDL_HIDAPI_Device *device) } ctx = (SDL_DriverPS3_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -215,7 +215,7 @@ static void HIDAPI_DriverPS3_SetDevicePlayerIndex(SDL_HIDAPI_Device *device, SDL { SDL_DriverPS3_Context *ctx = (SDL_DriverPS3_Context *)device->context; - if (ctx == NULL) { + if (!ctx) { return; } @@ -491,7 +491,7 @@ static SDL_bool HIDAPI_DriverPS3_UpdateDevice(SDL_HIDAPI_Device *device) #ifdef DEBUG_PS3_PROTOCOL HIDAPI_DumpPacket("PS3 packet: size = %d", data, size); #endif - if (joystick == NULL) { + if (!joystick) { continue; } @@ -604,7 +604,7 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverPS3_Context *ctx; ctx = (SDL_DriverPS3_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -932,7 +932,7 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_UpdateDevice(SDL_HIDAPI_Device *devic #ifdef DEBUG_PS3_PROTOCOL HIDAPI_DumpPacket("PS3 packet: size = %d", data, size); #endif - if (joystick == NULL) { + if (!joystick) { continue; } diff --git a/src/joystick/hidapi/SDL_hidapi_ps4.c b/src/joystick/hidapi/SDL_hidapi_ps4.c index 1fb377bfa..d43e35604 100644 --- a/src/joystick/hidapi/SDL_hidapi_ps4.c +++ b/src/joystick/hidapi/SDL_hidapi_ps4.c @@ -275,7 +275,7 @@ static SDL_bool HIDAPI_DriverPS4_InitDevice(SDL_HIDAPI_Device *device) SDL_JoystickType joystick_type = SDL_JOYSTICK_TYPE_GAMEPAD; ctx = (SDL_DriverPS4_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -1207,7 +1207,7 @@ static SDL_bool HIDAPI_DriverPS4_UpdateDevice(SDL_HIDAPI_Device *device) ++packet_count; ctx->last_packet = now; - if (joystick == NULL) { + if (!joystick) { continue; } diff --git a/src/joystick/hidapi/SDL_hidapi_ps5.c b/src/joystick/hidapi/SDL_hidapi_ps5.c index f4b628a18..35712a47d 100644 --- a/src/joystick/hidapi/SDL_hidapi_ps5.c +++ b/src/joystick/hidapi/SDL_hidapi_ps5.c @@ -373,7 +373,7 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device) SDL_JoystickType joystick_type = SDL_JOYSTICK_TYPE_GAMEPAD; ctx = (SDL_DriverPS5_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -1476,7 +1476,7 @@ static SDL_bool HIDAPI_DriverPS5_UpdateDevice(SDL_HIDAPI_Device *device) ++packet_count; ctx->last_packet = now; - if (joystick == NULL) { + if (!joystick) { continue; } diff --git a/src/joystick/hidapi/SDL_hidapi_rumble.c b/src/joystick/hidapi/SDL_hidapi_rumble.c index 4035b45fe..b29088cd1 100644 --- a/src/joystick/hidapi/SDL_hidapi_rumble.c +++ b/src/joystick/hidapi/SDL_hidapi_rumble.c @@ -214,7 +214,7 @@ int SDL_HIDAPI_SendRumbleWithCallbackAndUnlock(SDL_HIDAPI_Device *device, const } request = (SDL_HIDAPI_RumbleRequest *)SDL_calloc(1, sizeof(*request)); - if (request == NULL) { + if (!request) { SDL_HIDAPI_UnlockRumble(); return SDL_OutOfMemory(); } diff --git a/src/joystick/hidapi/SDL_hidapi_shield.c b/src/joystick/hidapi/SDL_hidapi_shield.c index 25f81a3d1..77b16da49 100644 --- a/src/joystick/hidapi/SDL_hidapi_shield.c +++ b/src/joystick/hidapi/SDL_hidapi_shield.c @@ -114,7 +114,7 @@ static SDL_bool HIDAPI_DriverShield_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverShield_Context *ctx; ctx = (SDL_DriverShield_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -489,7 +489,7 @@ static SDL_bool HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device) /* Byte 0 is HID report ID */ switch (data[0]) { case k_ShieldReportIdControllerState: - if (joystick == NULL) { + if (!joystick) { break; } if (size == 16) { @@ -499,7 +499,7 @@ static SDL_bool HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device) } break; case k_ShieldReportIdControllerTouch: - if (joystick == NULL) { + if (!joystick) { break; } HIDAPI_DriverShield_HandleTouchPacketV103(joystick, ctx, data, size); diff --git a/src/joystick/hidapi/SDL_hidapi_stadia.c b/src/joystick/hidapi/SDL_hidapi_stadia.c index 9d7bb0bcf..d2d4fcc0e 100644 --- a/src/joystick/hidapi/SDL_hidapi_stadia.c +++ b/src/joystick/hidapi/SDL_hidapi_stadia.c @@ -69,7 +69,7 @@ static SDL_bool HIDAPI_DriverStadia_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverStadia_Context *ctx; ctx = (SDL_DriverStadia_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -285,7 +285,7 @@ static SDL_bool HIDAPI_DriverStadia_UpdateDevice(SDL_HIDAPI_Device *device) #ifdef DEBUG_STADIA_PROTOCOL HIDAPI_DumpPacket("Google Stadia packet: size = %d", data, size); #endif - if (joystick == NULL) { + if (!joystick) { continue; } diff --git a/src/joystick/hidapi/SDL_hidapi_steam.c b/src/joystick/hidapi/SDL_hidapi_steam.c index d01d56420..0576a4496 100644 --- a/src/joystick/hidapi/SDL_hidapi_steam.c +++ b/src/joystick/hidapi/SDL_hidapi_steam.c @@ -973,7 +973,7 @@ static SDL_bool HIDAPI_DriverSteam_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverSteam_Context *ctx; ctx = (SDL_DriverSteam_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -1105,7 +1105,7 @@ static SDL_bool HIDAPI_DriverSteam_UpdateDevice(SDL_HIDAPI_Device *device) break; } - if (joystick == NULL) { + if (!joystick) { continue; } diff --git a/src/joystick/hidapi/SDL_hidapi_switch.c b/src/joystick/hidapi/SDL_hidapi_switch.c index f5b0f1855..124bb5f5c 100644 --- a/src/joystick/hidapi/SDL_hidapi_switch.c +++ b/src/joystick/hidapi/SDL_hidapi_switch.c @@ -438,7 +438,7 @@ static SDL_bool WriteSubcommand(SDL_DriverSwitch_Context *ctx, ESwitchSubcommand SwitchSubcommandInputPacket_t *reply = NULL; int nTries; - for (nTries = 1; reply == NULL && nTries <= ctx->m_nMaxWriteAttempts; ++nTries) { + for (nTries = 1; !reply && nTries <= ctx->m_nMaxWriteAttempts; ++nTries) { SwitchSubcommandOutputPacket_t commandPacket; ConstructSubcommand(ctx, ucCommandID, pBuf, ucLen, &commandPacket); @@ -462,7 +462,7 @@ static SDL_bool WriteProprietary(SDL_DriverSwitch_Context *ctx, ESwitchProprieta for (nTries = 1; nTries <= ctx->m_nMaxWriteAttempts; ++nTries) { SwitchProprietaryOutputPacket_t packet; - if ((pBuf == NULL && ucLen > 0) || ucLen > sizeof(packet.rgucProprietaryData)) { + if ((!pBuf && ucLen > 0) || ucLen > sizeof(packet.rgucProprietaryData)) { return SDL_FALSE; } @@ -1272,7 +1272,7 @@ static SDL_bool HIDAPI_DriverSwitch_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverSwitch_Context *ctx; ctx = (SDL_DriverSwitch_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -2203,7 +2203,7 @@ static SDL_bool HIDAPI_DriverSwitch_UpdateDevice(SDL_HIDAPI_Device *device) ++packet_count; ctx->m_ulLastInput = now; - if (joystick == NULL) { + if (!joystick) { continue; } diff --git a/src/joystick/hidapi/SDL_hidapi_wii.c b/src/joystick/hidapi/SDL_hidapi_wii.c index 037cf0252..836f54dcd 100644 --- a/src/joystick/hidapi/SDL_hidapi_wii.c +++ b/src/joystick/hidapi/SDL_hidapi_wii.c @@ -231,7 +231,7 @@ static SDL_bool ReadInputSync(SDL_DriverWii_Context *ctx, EWiiInputReportIDs exp int nRead = 0; while ((nRead = ReadInput(ctx)) != -1) { if (nRead > 0) { - if (ctx->m_rgucReadBuffer[0] == expectedID && (isMine == NULL || isMine(ctx->m_rgucReadBuffer))) { + if (ctx->m_rgucReadBuffer[0] == expectedID && (!isMine || isMine(ctx->m_rgucReadBuffer))) { return SDL_TRUE; } } else { @@ -725,7 +725,7 @@ static SDL_bool HIDAPI_DriverWii_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverWii_Context *ctx; ctx = (SDL_DriverWii_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } diff --git a/src/joystick/hidapi/SDL_hidapi_xbox360.c b/src/joystick/hidapi/SDL_hidapi_xbox360.c index cefde2b8d..c83cc3dcd 100644 --- a/src/joystick/hidapi/SDL_hidapi_xbox360.c +++ b/src/joystick/hidapi/SDL_hidapi_xbox360.c @@ -139,7 +139,7 @@ static SDL_bool HIDAPI_DriverXbox360_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverXbox360_Context *ctx; ctx = (SDL_DriverXbox360_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -329,7 +329,7 @@ static SDL_bool HIDAPI_DriverXbox360_UpdateDevice(SDL_HIDAPI_Device *device) #ifdef DEBUG_XBOX_PROTOCOL HIDAPI_DumpPacket("Xbox 360 packet: size = %d", data, size); #endif - if (joystick == NULL) { + if (!joystick) { continue; } diff --git a/src/joystick/hidapi/SDL_hidapi_xbox360w.c b/src/joystick/hidapi/SDL_hidapi_xbox360w.c index 30db93a2c..04e8010ae 100644 --- a/src/joystick/hidapi/SDL_hidapi_xbox360w.c +++ b/src/joystick/hidapi/SDL_hidapi_xbox360w.c @@ -131,7 +131,7 @@ static SDL_bool HIDAPI_DriverXbox360W_InitDevice(SDL_HIDAPI_Device *device) HIDAPI_SetDeviceName(device, "Xbox 360 Wireless Controller"); ctx = (SDL_DriverXbox360W_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -158,7 +158,7 @@ static void HIDAPI_DriverXbox360W_SetDevicePlayerIndex(SDL_HIDAPI_Device *device { SDL_DriverXbox360W_Context *ctx = (SDL_DriverXbox360W_Context *)device->context; - if (ctx == NULL) { + if (!ctx) { return; } diff --git a/src/joystick/hidapi/SDL_hidapi_xboxone.c b/src/joystick/hidapi/SDL_hidapi_xboxone.c index dc86c0718..b1a1af208 100644 --- a/src/joystick/hidapi/SDL_hidapi_xboxone.c +++ b/src/joystick/hidapi/SDL_hidapi_xboxone.c @@ -359,7 +359,7 @@ static SDL_bool HIDAPI_DriverXboxOne_InitDevice(SDL_HIDAPI_Device *device) SDL_DriverXboxOne_Context *ctx; ctx = (SDL_DriverXboxOne_Context *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -1401,7 +1401,7 @@ static SDL_bool HIDAPI_GIP_DispatchPacket(SDL_Joystick *joystick, SDL_DriverXbox /* Ignore this packet */ break; case GIP_CMD_VIRTUAL_KEY: - if (joystick == NULL) { + if (!joystick) { break; } HIDAPI_DriverXboxOne_HandleModePacket(joystick, ctx, data, size); @@ -1436,13 +1436,13 @@ static SDL_bool HIDAPI_GIP_DispatchPacket(SDL_Joystick *joystick, SDL_DriverXbox #endif break; } - if (joystick == NULL) { + if (!joystick) { break; } HIDAPI_DriverXboxOne_HandleStatePacket(joystick, ctx, data, size); break; case GIP_CMD_UNMAPPED_STATE: - if (joystick == NULL) { + if (!joystick) { break; } HIDAPI_DriverXboxOne_HandleUnmappedStatePacket(joystick, ctx, data, size); @@ -1568,7 +1568,7 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) if (device->is_bluetooth) { switch (data[0]) { case 0x01: - if (joystick == NULL) { + if (!joystick) { break; } if (size >= 16) { @@ -1580,13 +1580,13 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) } break; case 0x02: - if (joystick == NULL) { + if (!joystick) { break; } HIDAPI_DriverXboxOneBluetooth_HandleGuidePacket(joystick, ctx, data, size); break; case 0x04: - if (joystick == NULL) { + if (!joystick) { break; } HIDAPI_DriverXboxOneBluetooth_HandleBatteryPacket(joystick, ctx, data, size); diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c index 39cadbaf8..01e442864 100644 --- a/src/joystick/hidapi/SDL_hidapijoystick.c +++ b/src/joystick/hidapi/SDL_hidapijoystick.c @@ -99,7 +99,7 @@ static char *HIDAPI_ConvertString(const wchar_t *wide_string) if (wide_string) { string = SDL_iconv_string("UTF-8", "WCHAR_T", (char *)wide_string, (SDL_wcslen(wide_string) + 1) * sizeof(wchar_t)); - if (string == NULL) { + if (!string) { switch (sizeof(wchar_t)) { case 2: string = SDL_iconv_string("UTF-8", "UCS-2-INTERNAL", (char *)wide_string, (SDL_wcslen(wide_string) + 1) * sizeof(wchar_t)); @@ -608,7 +608,7 @@ static int HIDAPI_JoystickInit(void) static SDL_bool HIDAPI_AddJoystickInstanceToDevice(SDL_HIDAPI_Device *device, SDL_JoystickID joystickID) { SDL_JoystickID *joysticks = (SDL_JoystickID *)SDL_realloc(device->joysticks, (device->num_joysticks + 1) * sizeof(*device->joysticks)); - if (joysticks == NULL) { + if (!joysticks) { return SDL_FALSE; } @@ -730,7 +730,7 @@ SDL_bool HIDAPI_HasConnectedUSBDevice(const char *serial) SDL_AssertJoysticksLocked(); - if (serial == NULL) { + if (!serial) { return SDL_FALSE; } @@ -756,7 +756,7 @@ void HIDAPI_DisconnectBluetoothDevice(const char *serial) SDL_AssertJoysticksLocked(); - if (serial == NULL) { + if (!serial) { return; } @@ -866,7 +866,7 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf } device = (SDL_HIDAPI_Device *)SDL_calloc(1, sizeof(*device)); - if (device == NULL) { + if (!device) { return NULL; } device->magic = &SDL_HIDAPI_device_magic; @@ -950,7 +950,9 @@ static SDL_HIDAPI_Device *HIDAPI_AddDevice(const struct SDL_hid_device_info *inf } #ifdef DEBUG_HIDAPI - SDL_Log("Added HIDAPI device '%s' VID 0x%.4x, PID 0x%.4x, version %d, serial %s, interface %d, interface_class %d, interface_subclass %d, interface_protocol %d, usage page 0x%.4x, usage 0x%.4x, path = %s, driver = %s (%s)\n", device->name, device->vendor_id, device->product_id, device->version, device->serial ? device->serial : "NONE", device->interface_number, device->interface_class, device->interface_subclass, device->interface_protocol, device->usage_page, device->usage, device->path, device->driver ? device->driver->name : "NONE", device->driver && device->driver->enabled ? "ENABLED" : "DISABLED"); + SDL_Log("Added HIDAPI device '%s' VID 0x%.4x, PID 0x%.4x, version %d, serial %s, interface %d, interface_class %d, interface_subclass %d, interface_protocol %d, usage page 0x%.4x, usage 0x%.4x, path = %s, driver = %s (%s)\n", device->name, device->vendor_id, device->product_id, device->version, + device->serial ? device->serial : "NONE", device->interface_number, device->interface_class, device->interface_subclass, device->interface_protocol, device->usage_page, device->usage, + device->path, device->driver ? device->driver->name : "NONE", device->driver && device->driver->enabled ? "ENABLED" : "DISABLED"); #endif return device; @@ -964,7 +966,9 @@ static void HIDAPI_DelDevice(SDL_HIDAPI_Device *device) SDL_AssertJoysticksLocked(); #ifdef DEBUG_HIDAPI - SDL_Log("Removing HIDAPI device '%s' VID 0x%.4x, PID 0x%.4x, version %d, serial %s, interface %d, interface_class %d, interface_subclass %d, interface_protocol %d, usage page 0x%.4x, usage 0x%.4x, path = %s, driver = %s (%s)\n", device->name, device->vendor_id, device->product_id, device->version, device->serial ? device->serial : "NONE", device->interface_number, device->interface_class, device->interface_subclass, device->interface_protocol, device->usage_page, device->usage, device->path, device->driver ? device->driver->name : "NONE", device->driver && device->driver->enabled ? "ENABLED" : "DISABLED"); + SDL_Log("Removing HIDAPI device '%s' VID 0x%.4x, PID 0x%.4x, version %d, serial %s, interface %d, interface_class %d, interface_subclass %d, interface_protocol %d, usage page 0x%.4x, usage 0x%.4x, path = %s, driver = %s (%s)\n", device->name, device->vendor_id, device->product_id, device->version, + device->serial ? device->serial : "NONE", device->interface_number, device->interface_class, device->interface_subclass, device->interface_protocol, device->usage_page, device->usage, + device->path, device->driver ? device->driver->name : "NONE", device->driver && device->driver->enabled ? "ENABLED" : "DISABLED"); #endif for (curr = SDL_HIDAPI_devices, last = NULL; curr; last = curr, curr = curr->next) { @@ -1038,7 +1042,7 @@ static SDL_bool HIDAPI_CreateCombinedJoyCons(void) if (joycons[0] && joycons[1]) { SDL_hid_device_info info; SDL_HIDAPI_Device **children = (SDL_HIDAPI_Device **)SDL_malloc(2 * sizeof(SDL_HIDAPI_Device *)); - if (children == NULL) { + if (!children) { return SDL_FALSE; } children[0] = joycons[0]; @@ -1423,13 +1427,13 @@ static int HIDAPI_JoystickOpen(SDL_Joystick *joystick, int device_index) SDL_AssertJoysticksLocked(); - if (device == NULL || !device->driver) { + if (!device || !device->driver) { /* This should never happen - validated before being called */ return SDL_SetError("Couldn't find HIDAPI device at index %d\n", device_index); } hwdata = (struct joystick_hwdata *)SDL_calloc(1, sizeof(*hwdata)); - if (hwdata == NULL) { + if (!hwdata) { return SDL_OutOfMemory(); } hwdata->device = device; diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c index 9d776f543..0430a7380 100644 --- a/src/joystick/linux/SDL_sysjoystick.c +++ b/src/joystick/linux/SDL_sysjoystick.c @@ -286,7 +286,7 @@ static int IsJoystick(const char *path, int fd, char **name_return, SDL_Joystick } name = SDL_CreateJoystickName(inpid.vendor, inpid.product, NULL, product_string); - if (name == NULL) { + if (!name) { return 0; } @@ -335,7 +335,7 @@ static int IsSensor(const char *path, int fd) #ifdef SDL_USE_LIBUDEV static void joystick_udev_callback(SDL_UDEV_deviceevent udev_type, int udev_class, const char *devpath) { - if (devpath == NULL) { + if (!devpath) { return; } @@ -393,7 +393,7 @@ static void MaybeAddDevice(const char *path) SDL_joylist_item *item; SDL_sensorlist_item *item_sensor; - if (path == NULL) { + if (!path) { return; } @@ -404,12 +404,12 @@ static void MaybeAddDevice(const char *path) SDL_LockJoysticks(); /* Check to make sure it's not already in list. */ - for (item = SDL_joylist; item != NULL; item = item->next) { + for (item = SDL_joylist; item; item = item->next) { if (sb.st_rdev == item->devnum) { goto done; /* already have this one */ } } - for (item_sensor = SDL_sensorlist; item_sensor != NULL; item_sensor = item_sensor->next) { + for (item_sensor = SDL_sensorlist; item_sensor; item_sensor = item_sensor->next) { if (sb.st_rdev == item_sensor->devnum) { goto done; /* already have this one */ } @@ -430,7 +430,7 @@ static void MaybeAddDevice(const char *path) #endif close(fd); item = (SDL_joylist_item *)SDL_calloc(1, sizeof(SDL_joylist_item)); - if (item == NULL) { + if (!item) { SDL_free(name); goto done; } @@ -440,13 +440,13 @@ static void MaybeAddDevice(const char *path) item->name = name; item->guid = guid; - if ((item->path == NULL) || (item->name == NULL)) { + if ((!item->path) || (!item->name)) { FreeJoylistItem(item); goto done; } item->device_instance = SDL_GetNextObjectID(); - if (SDL_joylist_tail == NULL) { + if (!SDL_joylist_tail) { SDL_joylist = SDL_joylist_tail = item; } else { SDL_joylist_tail->next = item; @@ -466,13 +466,13 @@ static void MaybeAddDevice(const char *path) #endif close(fd); item_sensor = (SDL_sensorlist_item *)SDL_calloc(1, sizeof(SDL_sensorlist_item)); - if (item_sensor == NULL) { + if (!item_sensor) { goto done; } item_sensor->devnum = sb.st_rdev; item_sensor->path = SDL_strdup(path); - if (item_sensor->path == NULL) { + if (!item_sensor->path) { FreeSensorlistItem(item_sensor); goto done; } @@ -495,7 +495,7 @@ static void RemoveJoylistItem(SDL_joylist_item *item, SDL_joylist_item *prev) item->hwdata->item = NULL; } - if (prev != NULL) { + if (prev) { prev->next = item->next; } else { SDL_assert(SDL_joylist == item); @@ -521,7 +521,7 @@ static void RemoveSensorlistItem(SDL_sensorlist_item *item, SDL_sensorlist_item item->hwdata->item_sensor = NULL; } - if (prev != NULL) { + if (prev) { prev->next = item->next; } else { SDL_assert(SDL_sensorlist == item); @@ -540,12 +540,12 @@ static void MaybeRemoveDevice(const char *path) SDL_sensorlist_item *item_sensor; SDL_sensorlist_item *prev_sensor = NULL; - if (path == NULL) { + if (!path) { return; } SDL_LockJoysticks(); - for (item = SDL_joylist; item != NULL; item = item->next) { + for (item = SDL_joylist; item; item = item->next) { /* found it, remove it. */ if (SDL_strcmp(path, item->path) == 0) { RemoveJoylistItem(item, prev); @@ -553,7 +553,7 @@ static void MaybeRemoveDevice(const char *path) } prev = item; } - for (item_sensor = SDL_sensorlist; item_sensor != NULL; item_sensor = item_sensor->next) { + for (item_sensor = SDL_sensorlist; item_sensor; item_sensor = item_sensor->next) { /* found it, remove it. */ if (SDL_strcmp(path, item_sensor->path) == 0) { RemoveSensorlistItem(item_sensor, prev_sensor); @@ -575,11 +575,11 @@ static void HandlePendingRemovals(void) SDL_AssertJoysticksLocked(); item = SDL_joylist; - while (item != NULL) { + while (item) { if (item->hwdata && item->hwdata->gone) { RemoveJoylistItem(item, prev); - if (prev != NULL) { + if (prev) { item = prev->next; } else { item = SDL_joylist; @@ -591,11 +591,11 @@ static void HandlePendingRemovals(void) } item_sensor = SDL_sensorlist; - while (item_sensor != NULL) { + while (item_sensor) { if (item_sensor->hwdata && item_sensor->hwdata->sensor_gone) { RemoveSensorlistItem(item_sensor, prev_sensor); - if (prev_sensor != NULL) { + if (prev_sensor) { item_sensor = prev_sensor->next; } else { item_sensor = SDL_sensorlist; @@ -612,7 +612,7 @@ static SDL_bool SteamControllerConnectedCallback(const char *name, SDL_JoystickG SDL_joylist_item *item; item = (SDL_joylist_item *)SDL_calloc(1, sizeof(SDL_joylist_item)); - if (item == NULL) { + if (!item) { return SDL_FALSE; } @@ -621,14 +621,14 @@ static SDL_bool SteamControllerConnectedCallback(const char *name, SDL_JoystickG item->guid = guid; item->m_bSteamController = SDL_TRUE; - if ((item->path == NULL) || (item->name == NULL)) { + if ((!item->path) || (!item->name)) { FreeJoylistItem(item); return SDL_FALSE; } *device_instance = item->device_instance = SDL_GetNextObjectID(); SDL_LockJoysticks(); - if (SDL_joylist_tail == NULL) { + if (!SDL_joylist_tail) { SDL_joylist = SDL_joylist_tail = item; } else { SDL_joylist_tail->next = item; @@ -650,7 +650,7 @@ static void SteamControllerDisconnectedCallback(SDL_JoystickID device_instance) SDL_joylist_item *prev = NULL; SDL_LockJoysticks(); - for (item = SDL_joylist; item != NULL; item = item->next) { + for (item = SDL_joylist; item; item = item->next) { /* found it, remove it. */ if (item->device_instance == device_instance) { RemoveJoylistItem(item, prev); @@ -895,13 +895,13 @@ static int LINUX_JoystickInit(void) enumeration_method = ENUMERATION_UNSET; /* First see if the user specified one or more joysticks to use */ - if (devices != NULL) { + if (devices) { char *envcopy, *envpath, *delim; envcopy = SDL_strdup(devices); envpath = envcopy; - while (envpath != NULL) { + while (envpath) { delim = SDL_strchr(envpath, ':'); - if (delim != NULL) { + if (delim) { *delim++ = '\0'; } MaybeAddDevice(envpath); @@ -1001,7 +1001,7 @@ static SDL_joylist_item *GetJoystickByDevIndex(int device_index) item = SDL_joylist; while (device_index > 0) { - SDL_assert(item != NULL); + SDL_assert(item); device_index--; item = item->next; } @@ -1048,7 +1048,7 @@ static int allocate_hatdata(SDL_Joystick *joystick) joystick->hwdata->hats = (struct hwdata_hat *)SDL_malloc(joystick->nhats * sizeof(struct hwdata_hat)); - if (joystick->hwdata->hats == NULL) { + if (!joystick->hwdata->hats) { return -1; } for (i = 0; i < joystick->nhats; ++i) { @@ -1067,7 +1067,7 @@ static SDL_bool GuessIfAxesAreDigitalHat(struct input_absinfo *absinfo_x, struct * other continuous analog axis, so we have to guess. */ /* If both axes are missing, they're not anything. */ - if (absinfo_x == NULL && absinfo_y == NULL) { + if (!absinfo_x && !absinfo_y) { return SDL_FALSE; } @@ -1077,12 +1077,12 @@ static SDL_bool GuessIfAxesAreDigitalHat(struct input_absinfo *absinfo_x, struct } /* If both axes have ranges constrained between -1 and 1, they're definitely digital. */ - if ((absinfo_x == NULL || (absinfo_x->minimum == -1 && absinfo_x->maximum == 1)) && (absinfo_y == NULL || (absinfo_y->minimum == -1 && absinfo_y->maximum == 1))) { + if ((!absinfo_x || (absinfo_x->minimum == -1 && absinfo_x->maximum == 1)) && (!absinfo_y || (absinfo_y->minimum == -1 && absinfo_y->maximum == 1))) { return SDL_TRUE; } /* If both axes lack fuzz, flat, and resolution values, they're probably digital. */ - if ((absinfo_x == NULL || (!absinfo_x->fuzz && !absinfo_x->flat && !absinfo_x->resolution)) && (absinfo_y == NULL || (!absinfo_y->fuzz && !absinfo_y->flat && !absinfo_y->resolution))) { + if ((!absinfo_x || (!absinfo_x->fuzz && !absinfo_x->flat && !absinfo_x->resolution)) && (!absinfo_y || (!absinfo_y->fuzz && !absinfo_y->flat && !absinfo_y->resolution))) { return SDL_TRUE; } @@ -1369,14 +1369,14 @@ static int PrepareJoystickHwdata(SDL_Joystick *joystick, SDL_joylist_item *item, return SDL_SetError("Unable to open %s", item->path); } /* If opening sensor fail, continue with buttons and axes only */ - if (item_sensor != NULL) { + if (item_sensor) { fd_sensor = open(item_sensor->path, O_RDONLY | O_CLOEXEC, 0); } joystick->hwdata->fd = fd; joystick->hwdata->fd_sensor = fd_sensor; joystick->hwdata->fname = SDL_strdup(item->path); - if (joystick->hwdata->fname == NULL) { + if (!joystick->hwdata->fname) { close(fd); if (fd_sensor >= 0) { close(fd_sensor); @@ -1404,7 +1404,7 @@ static SDL_sensorlist_item *GetSensor(SDL_joylist_item *item) SDL_AssertJoysticksLocked(); - if (item == NULL || SDL_sensorlist == NULL) { + if (!item || !SDL_sensorlist) { return NULL; } @@ -1421,10 +1421,10 @@ static SDL_sensorlist_item *GetSensor(SDL_joylist_item *item) SDL_Log("Joystick UNIQ: %s\n", uniq_item); #endif /* DEBUG_INPUT_EVENTS */ - for (item_sensor = SDL_sensorlist; item_sensor != NULL; item_sensor = item_sensor->next) { + for (item_sensor = SDL_sensorlist; item_sensor; item_sensor = item_sensor->next) { char uniq_sensor[128]; int fd_sensor = -1; - if (item_sensor->hwdata != NULL) { + if (item_sensor->hwdata) { /* already associated with another joystick */ continue; } @@ -1463,14 +1463,14 @@ static int LINUX_JoystickOpen(SDL_Joystick *joystick, int device_index) SDL_AssertJoysticksLocked(); item = GetJoystickByDevIndex(device_index); - if (item == NULL) { + if (!item) { return SDL_SetError("No such device"); } joystick->instance_id = item->device_instance; joystick->hwdata = (struct joystick_hwdata *) SDL_calloc(1, sizeof(*joystick->hwdata)); - if (joystick->hwdata == NULL) { + if (!joystick->hwdata) { return SDL_OutOfMemory(); } @@ -1481,10 +1481,10 @@ static int LINUX_JoystickOpen(SDL_Joystick *joystick, int device_index) return -1; /* SDL_SetError will already have been called */ } - SDL_assert(item->hwdata == NULL); - SDL_assert(!item_sensor || item_sensor->hwdata == NULL); + SDL_assert(!item->hwdata); + SDL_assert(!item_sensor || !item_sensor->hwdata); item->hwdata = joystick->hwdata; - if (item_sensor != NULL) { + if (item_sensor) { item_sensor->hwdata = joystick->hwdata; } @@ -1589,7 +1589,7 @@ static int LINUX_JoystickSetSensorsEnabled(SDL_Joystick *joystick, SDL_bool enab } if (enabled) { - if (joystick->hwdata->item_sensor == NULL) { + if (!joystick->hwdata->item_sensor) { return SDL_SetError("Sensors unplugged."); } joystick->hwdata->fd_sensor = open(joystick->hwdata->item_sensor->path, O_RDONLY | O_CLOEXEC, 0); @@ -2146,7 +2146,7 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap /* We temporarily open the device to check how it's configured. Make a fake SDL_Joystick object to do so. */ joystick = (SDL_Joystick *)SDL_calloc(sizeof(*joystick), 1); - if (joystick == NULL) { + if (!joystick) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -2155,7 +2155,7 @@ static SDL_bool LINUX_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap joystick->hwdata = (struct joystick_hwdata *) SDL_calloc(1, sizeof(*joystick->hwdata)); - if (joystick->hwdata == NULL) { + if (!joystick->hwdata) { SDL_free(joystick); SDL_OutOfMemory(); return SDL_FALSE; diff --git a/src/joystick/virtual/SDL_virtualjoystick.c b/src/joystick/virtual/SDL_virtualjoystick.c index 29ec65f98..d8ce2f831 100644 --- a/src/joystick/virtual/SDL_virtualjoystick.c +++ b/src/joystick/virtual/SDL_virtualjoystick.c @@ -66,7 +66,7 @@ static void VIRTUAL_FreeHWData(joystick_hwdata *hwdata) SDL_AssertJoysticksLocked(); - if (hwdata == NULL) { + if (!hwdata) { return; } @@ -114,7 +114,7 @@ SDL_JoystickID SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *des SDL_AssertJoysticksLocked(); - if (desc == NULL) { + if (!desc) { return SDL_InvalidParamError("desc"); } if (desc->version != SDL_VIRTUAL_JOYSTICK_DESC_VERSION) { @@ -123,7 +123,7 @@ SDL_JoystickID SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *des } hwdata = SDL_calloc(1, sizeof(joystick_hwdata)); - if (hwdata == NULL) { + if (!hwdata) { VIRTUAL_FreeHWData(hwdata); return SDL_OutOfMemory(); } @@ -257,7 +257,7 @@ SDL_JoystickID SDL_JoystickAttachVirtualInner(const SDL_VirtualJoystickDesc *des int SDL_JoystickDetachVirtualInner(SDL_JoystickID instance_id) { joystick_hwdata *hwdata = VIRTUAL_HWDataForInstance(instance_id); - if (hwdata == NULL) { + if (!hwdata) { return SDL_SetError("Virtual joystick data not found"); } VIRTUAL_FreeHWData(hwdata); @@ -271,7 +271,7 @@ int SDL_SetJoystickVirtualAxisInner(SDL_Joystick *joystick, int axis, Sint16 val SDL_AssertJoysticksLocked(); - if (joystick == NULL || !joystick->hwdata) { + if (!joystick || !joystick->hwdata) { SDL_UnlockJoysticks(); return SDL_SetError("Invalid joystick"); } @@ -293,7 +293,7 @@ int SDL_SetJoystickVirtualButtonInner(SDL_Joystick *joystick, int button, Uint8 SDL_AssertJoysticksLocked(); - if (joystick == NULL || !joystick->hwdata) { + if (!joystick || !joystick->hwdata) { SDL_UnlockJoysticks(); return SDL_SetError("Invalid joystick"); } @@ -315,7 +315,7 @@ int SDL_SetJoystickVirtualHatInner(SDL_Joystick *joystick, int hat, Uint8 value) SDL_AssertJoysticksLocked(); - if (joystick == NULL || !joystick->hwdata) { + if (!joystick || !joystick->hwdata) { SDL_UnlockJoysticks(); return SDL_SetError("Invalid joystick"); } @@ -356,7 +356,7 @@ static void VIRTUAL_JoystickDetect(void) static const char *VIRTUAL_JoystickGetDeviceName(int device_index) { joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index); - if (hwdata == NULL) { + if (!hwdata) { return NULL; } return hwdata->name; @@ -384,7 +384,7 @@ static void VIRTUAL_JoystickSetDevicePlayerIndex(int device_index, int player_in static SDL_JoystickGUID VIRTUAL_JoystickGetDeviceGUID(int device_index) { joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index); - if (hwdata == NULL) { + if (!hwdata) { SDL_JoystickGUID guid; SDL_zero(guid); return guid; @@ -395,7 +395,7 @@ static SDL_JoystickGUID VIRTUAL_JoystickGetDeviceGUID(int device_index) static SDL_JoystickID VIRTUAL_JoystickGetDeviceInstanceID(int device_index) { joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index); - if (hwdata == NULL) { + if (!hwdata) { return 0; } return hwdata->instance_id; @@ -408,7 +408,7 @@ static int VIRTUAL_JoystickOpen(SDL_Joystick *joystick, int device_index) SDL_AssertJoysticksLocked(); hwdata = VIRTUAL_HWDataForIndex(device_index); - if (hwdata == NULL) { + if (!hwdata) { return SDL_SetError("No such device"); } joystick->instance_id = hwdata->instance_id; @@ -535,7 +535,7 @@ static void VIRTUAL_JoystickUpdate(SDL_Joystick *joystick) SDL_AssertJoysticksLocked(); - if (joystick == NULL) { + if (!joystick) { return; } if (!joystick->hwdata) { diff --git a/src/joystick/windows/SDL_dinputjoystick.c b/src/joystick/windows/SDL_dinputjoystick.c index b6868891a..ef57755b5 100644 --- a/src/joystick/windows/SDL_dinputjoystick.c +++ b/src/joystick/windows/SDL_dinputjoystick.c @@ -271,7 +271,7 @@ static SDL_bool QueryDeviceName(LPDIRECTINPUTDEVICE8 device, char **device_name) { DIPROPSTRING dipstr; - if (!device || device_name == NULL) { + if (!device || !device_name) { return SDL_FALSE; } @@ -293,7 +293,7 @@ static SDL_bool QueryDevicePath(LPDIRECTINPUTDEVICE8 device, char **device_path) { DIPROPGUIDANDPATH dippath; - if (!device || device_path == NULL) { + if (!device || !device_path) { return SDL_FALSE; } @@ -318,7 +318,7 @@ static SDL_bool QueryDeviceInfo(LPDIRECTINPUTDEVICE8 device, Uint16 *vendor_id, { DIPROPDWORD dipdw; - if (!device || vendor_id == NULL || product_id == NULL) { + if (!device || !vendor_id || !product_id) { return SDL_FALSE; } @@ -340,7 +340,7 @@ static SDL_bool QueryDeviceInfo(LPDIRECTINPUTDEVICE8 device, Uint16 *vendor_id, void FreeRumbleEffectData(DIEFFECT *effect) { - if (effect == NULL) { + if (!effect) { return; } SDL_free(effect->rgdwAxes); @@ -356,7 +356,7 @@ DIEFFECT *CreateRumbleEffectData(Sint16 magnitude) /* Create the effect */ effect = (DIEFFECT *)SDL_calloc(1, sizeof(*effect)); - if (effect == NULL) { + if (!effect) { return NULL; } effect->dwSize = sizeof(*effect); @@ -380,7 +380,7 @@ DIEFFECT *CreateRumbleEffectData(Sint16 magnitude) effect->dwFlags |= DIEFF_CARTESIAN; periodic = (DIPERIODIC *)SDL_calloc(1, sizeof(*periodic)); - if (periodic == NULL) { + if (!periodic) { FreeRumbleEffectData(effect); return NULL; } @@ -420,7 +420,7 @@ int SDL_DINPUT_JoystickInit(void) /* Because we used CoCreateInstance, we need to Initialize it, first. */ instance = GetModuleHandle(NULL); - if (instance == NULL) { + if (!instance) { IDirectInput8_Release(dinput); dinput = NULL; return SDL_SetError("GetModuleHandle() failed with error code %lu.", GetLastError()); @@ -543,7 +543,7 @@ err: void SDL_DINPUT_JoystickDetect(JoyStick_DeviceData **pContext) { - if (dinput == NULL) { + if (!dinput) { return; } @@ -595,7 +595,7 @@ SDL_bool SDL_DINPUT_JoystickPresent(Uint16 vendor_id, Uint16 product_id, Uint16 { Joystick_PresentData data; - if (dinput == NULL) { + if (!dinput) { return SDL_FALSE; } diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c index 2d8d1aa86..e9f8636d6 100644 --- a/src/joystick/windows/SDL_rawinputjoystick.c +++ b/src/joystick/windows/SDL_rawinputjoystick.c @@ -472,7 +472,7 @@ static const IID IID_IEventHandler_Gamepad = { 0x8a7639ee, 0x624a, 0x501a, { 0xb static HRESULT STDMETHODCALLTYPE IEventHandler_CGamepadVtbl_QueryInterface(__FIEventHandler_1_Windows__CGaming__CInput__CGamepad *This, REFIID riid, void **ppvObject) { - if (ppvObject == NULL) { + if (!ppvObject) { return E_INVALIDARG; } @@ -622,7 +622,7 @@ static int RAWINPUT_UpdateWindowsGamingInput() return SDL_OutOfMemory(); } gamepad_state = SDL_calloc(1, sizeof(*gamepad_state)); - if (gamepad_state == NULL) { + if (!gamepad_state) { return SDL_OutOfMemory(); } wgi_state.per_gamepad[wgi_state.per_gamepad_count - 1] = gamepad_state; @@ -1224,7 +1224,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) ULONG i; ctx = (RAWINPUT_DeviceContext *)SDL_calloc(1, sizeof(RAWINPUT_DeviceContext)); - if (ctx == NULL) { + if (!ctx) { return SDL_OutOfMemory(); } joystick->hwdata = ctx; @@ -1237,7 +1237,7 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT xinput_device_change = SDL_TRUE; ctx->xinput_enabled = SDL_GetHintBoolean(SDL_HINT_JOYSTICK_RAWINPUT_CORRELATE_XINPUT, SDL_TRUE); - if (ctx->xinput_enabled && (WIN_LoadXInputDLL() < 0 || XINPUTGETSTATE == NULL)) { + if (ctx->xinput_enabled && (WIN_LoadXInputDLL() < 0 || !XINPUTGETSTATE)) { ctx->xinput_enabled = SDL_FALSE; } ctx->xinput_slot = XUSER_INDEX_ANY; @@ -1423,7 +1423,7 @@ static int RAWINPUT_JoystickRumble(SDL_Joystick *joystick, Uint16 low_frequency_ if (!rumbled && ctx->xinput_correlated) { XINPUT_VIBRATION XVibration; - if (XINPUTSETSTATE == NULL) { + if (!XINPUTSETSTATE) { return SDL_Unsupported(); } diff --git a/src/joystick/windows/SDL_windows_gaming_input.c b/src/joystick/windows/SDL_windows_gaming_input.c index d939ea6cc..5f4ddab20 100644 --- a/src/joystick/windows/SDL_windows_gaming_input.c +++ b/src/joystick/windows/SDL_windows_gaming_input.c @@ -127,7 +127,7 @@ static SDL_bool SDL_IsXInputDevice(Uint16 vendor, Uint16 product) } raw_devices = (PRAWINPUTDEVICELIST)SDL_malloc(sizeof(RAWINPUTDEVICELIST) * raw_device_count); - if (raw_devices == NULL) { + if (!raw_devices) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -349,7 +349,7 @@ typedef struct RawGameControllerDelegate static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_QueryInterface(__FIEventHandler_1_Windows__CGaming__CInput__CRawGameController *This, REFIID riid, void **ppvObject) { - if (ppvObject == NULL) { + if (!ppvObject) { return E_INVALIDARG; } @@ -439,7 +439,7 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde } __x_ABI_CWindows_CGaming_CInput_CIRawGameController2_Release(controller2); } - if (name == NULL) { + if (!name) { name = SDL_strdup(""); } @@ -719,7 +719,7 @@ static int WGI_JoystickOpen(SDL_Joystick *joystick, int device_index) boolean wireless = SDL_FALSE; hwdata = (struct joystick_hwdata *)SDL_calloc(1, sizeof(*hwdata)); - if (hwdata == NULL) { + if (!hwdata) { return SDL_OutOfMemory(); } joystick->hwdata = hwdata; diff --git a/src/joystick/windows/SDL_windowsjoystick.c b/src/joystick/windows/SDL_windowsjoystick.c index a329ebfb2..bb95a53ac 100644 --- a/src/joystick/windows/SDL_windowsjoystick.c +++ b/src/joystick/windows/SDL_windowsjoystick.c @@ -176,7 +176,7 @@ static DWORD CALLBACK SDL_DeviceNotificationFunc(HCMNOTIFICATION hNotify, PVOID static void SDL_CleanupDeviceNotificationFunc(void) { if (cfgmgr32_lib_handle) { - if (s_DeviceNotificationFuncHandle != NULL && CM_Unregister_Notification != NULL) { + if (s_DeviceNotificationFuncHandle != NULL && CM_Unregister_Notification) { CM_Unregister_Notification(s_DeviceNotificationFuncHandle); s_DeviceNotificationFuncHandle = NULL; } @@ -294,7 +294,7 @@ static int SDL_CreateDeviceNotification(SDL_DeviceNotificationData *data) } data->messageWindow = CreateWindowEx(0, TEXT("Message"), NULL, 0, 0, 0, 0, 0, HWND_MESSAGE, NULL, NULL, NULL); - if (data->messageWindow == NULL) { + if (!data->messageWindow) { WIN_SetError("Failed to create message window for joystick autodetect"); SDL_CleanupDeviceNotification(data); return -1; @@ -404,18 +404,18 @@ static int SDLCALL SDL_JoystickThread(void *_data) static int SDL_StartJoystickThread(void) { s_mutexJoyStickEnum = SDL_CreateMutex(); - if (s_mutexJoyStickEnum == NULL) { + if (!s_mutexJoyStickEnum) { return -1; } s_condJoystickThread = SDL_CreateCondition(); - if (s_condJoystickThread == NULL) { + if (!s_condJoystickThread) { return -1; } s_bJoystickThreadQuit = SDL_FALSE; s_joystickThread = SDL_CreateThreadInternal(SDL_JoystickThread, "SDL_joystick", 64 * 1024, NULL); - if (s_joystickThread == NULL) { + if (!s_joystickThread) { return -1; } return 0; @@ -423,7 +423,7 @@ static int SDL_StartJoystickThread(void) static void SDL_StopJoystickThread(void) { - if (s_joystickThread == NULL) { + if (!s_joystickThread) { return; } @@ -672,7 +672,7 @@ static int WINDOWS_JoystickOpen(SDL_Joystick *joystick, int device_index) joystick->instance_id = device->nInstanceID; joystick->hwdata = (struct joystick_hwdata *)SDL_malloc(sizeof(struct joystick_hwdata)); - if (joystick->hwdata == NULL) { + if (!joystick->hwdata) { return SDL_OutOfMemory(); } SDL_zerop(joystick->hwdata); diff --git a/src/joystick/windows/SDL_xinputjoystick.c b/src/joystick/windows/SDL_xinputjoystick.c index 253e7e108..2c5668d7e 100644 --- a/src/joystick/windows/SDL_xinputjoystick.c +++ b/src/joystick/windows/SDL_xinputjoystick.c @@ -128,7 +128,7 @@ static void GuessXInputDevice(Uint8 userid, Uint16 *pVID, Uint16 *pPID, Uint16 * } devices = (PRAWINPUTDEVICELIST)SDL_malloc(sizeof(RAWINPUTDEVICELIST) * device_count); - if (devices == NULL) { + if (!devices) { return; } @@ -275,7 +275,7 @@ static void AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pC } pNewJoystick = (JoyStick_DeviceData *)SDL_calloc(1, sizeof(JoyStick_DeviceData)); - if (pNewJoystick == NULL) { + if (!pNewJoystick) { return; /* better luck next time? */ } diff --git a/src/loadso/dlopen/SDL_sysloadso.c b/src/loadso/dlopen/SDL_sysloadso.c index 43ec162b0..a8f8849d9 100644 --- a/src/loadso/dlopen/SDL_sysloadso.c +++ b/src/loadso/dlopen/SDL_sysloadso.c @@ -46,7 +46,7 @@ void *SDL_LoadObject(const char *sofile) handle = dlopen(sofile, RTLD_NOW | RTLD_LOCAL); loaderror = dlerror(); - if (handle == NULL) { + if (!handle) { SDL_SetError("Failed loading %s: %s", sofile, loaderror); } return handle; @@ -55,7 +55,7 @@ void *SDL_LoadObject(const char *sofile) SDL_FunctionPointer SDL_LoadFunction(void *handle, const char *name) { void *symbol = dlsym(handle, name); - if (symbol == NULL) { + if (!symbol) { /* prepend an underscore for platforms that need that. */ SDL_bool isstack; size_t len = SDL_strlen(name) + 1; @@ -64,7 +64,7 @@ SDL_FunctionPointer SDL_LoadFunction(void *handle, const char *name) SDL_memcpy(&_name[1], name, len); symbol = dlsym(handle, _name); SDL_small_free(_name, isstack); - if (symbol == NULL) { + if (!symbol) { SDL_SetError("Failed loading %s: %s", name, (const char *)dlerror()); } @@ -74,7 +74,7 @@ SDL_FunctionPointer SDL_LoadFunction(void *handle, const char *name) void SDL_UnloadObject(void *handle) { - if (handle != NULL) { + if (handle) { dlclose(handle); } } diff --git a/src/loadso/windows/SDL_sysloadso.c b/src/loadso/windows/SDL_sysloadso.c index 94198f16c..5eebf2168 100644 --- a/src/loadso/windows/SDL_sysloadso.c +++ b/src/loadso/windows/SDL_sysloadso.c @@ -32,7 +32,7 @@ void *SDL_LoadObject(const char *sofile) void *handle; LPTSTR tstr; - if (sofile == NULL) { + if (!sofile) { SDL_InvalidParamError("sofile"); return NULL; } @@ -49,7 +49,7 @@ void *SDL_LoadObject(const char *sofile) SDL_free(tstr); /* Generate an error message if all loads failed */ - if (handle == NULL) { + if (!handle) { char errbuf[512]; SDL_strlcpy(errbuf, "Failed loading ", SDL_arraysize(errbuf)); SDL_strlcat(errbuf, sofile, SDL_arraysize(errbuf)); @@ -61,7 +61,7 @@ void *SDL_LoadObject(const char *sofile) SDL_FunctionPointer SDL_LoadFunction(void *handle, const char *name) { void *symbol = (void *)GetProcAddress((HMODULE)handle, name); - if (symbol == NULL) { + if (!symbol) { char errbuf[512]; SDL_strlcpy(errbuf, "Failed loading ", SDL_arraysize(errbuf)); SDL_strlcat(errbuf, name, SDL_arraysize(errbuf)); @@ -72,7 +72,7 @@ SDL_FunctionPointer SDL_LoadFunction(void *handle, const char *name) void SDL_UnloadObject(void *handle) { - if (handle != NULL) { + if (handle) { FreeLibrary((HMODULE)handle); } } diff --git a/src/locale/SDL_locale.c b/src/locale/SDL_locale.c index 46a5a5db4..363d0dd86 100644 --- a/src/locale/SDL_locale.c +++ b/src/locale/SDL_locale.c @@ -31,7 +31,7 @@ static SDL_Locale *build_locales_from_csv_string(char *csv) SDL_Locale *loc; SDL_Locale *retval; - if (csv == NULL || !csv[0]) { + if (!csv || !csv[0]) { return NULL; /* nothing to report */ } @@ -47,7 +47,7 @@ static SDL_Locale *build_locales_from_csv_string(char *csv) alloclen = slen + (num_locales * sizeof(SDL_Locale)); loc = retval = (SDL_Locale *)SDL_calloc(1, alloclen); - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); return NULL; /* oh well */ } diff --git a/src/locale/unix/SDL_syslocale.c b/src/locale/unix/SDL_syslocale.c index cf48be967..bf10e3b19 100644 --- a/src/locale/unix/SDL_syslocale.c +++ b/src/locale/unix/SDL_syslocale.c @@ -27,12 +27,12 @@ static void normalize_locale_str(char *dst, char *str, size_t buflen) char *ptr; ptr = SDL_strchr(str, '.'); /* chop off encoding if specified. */ - if (ptr != NULL) { + if (ptr) { *ptr = '\0'; } ptr = SDL_strchr(str, '@'); /* chop off extra bits if specified. */ - if (ptr != NULL) { + if (ptr) { *ptr = '\0'; } @@ -71,7 +71,7 @@ int SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) SDL_assert(buflen > 0); tmp = SDL_small_alloc(char, buflen, &isstack); - if (tmp == NULL) { + if (!tmp) { return SDL_OutOfMemory(); } diff --git a/src/locale/windows/SDL_syslocale.c b/src/locale/windows/SDL_syslocale.c index 60dc98eb4..634e8370a 100644 --- a/src/locale/windows/SDL_syslocale.c +++ b/src/locale/windows/SDL_syslocale.c @@ -61,11 +61,11 @@ static int SDL_SYS_GetPreferredLocales_vista(char *buf, size_t buflen) ULONG wbuflen = 0; SDL_bool isstack; - SDL_assert(pGetUserPreferredUILanguages != NULL); + SDL_assert(pGetUserPreferredUILanguages); pGetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &numlangs, NULL, &wbuflen); wbuf = SDL_small_alloc(WCHAR, wbuflen, &isstack); - if (wbuf == NULL) { + if (!wbuf) { return SDL_OutOfMemory(); } @@ -102,7 +102,7 @@ int SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) } } - if (pGetUserPreferredUILanguages == NULL) { + if (!pGetUserPreferredUILanguages) { SDL_SYS_GetPreferredLocales_winxp(buf, buflen); /* this is always available */ } else { SDL_SYS_GetPreferredLocales_vista(buf, buflen); /* available on Vista and later. */ diff --git a/src/misc/SDL_url.c b/src/misc/SDL_url.c index a79a109ea..aa58b536e 100644 --- a/src/misc/SDL_url.c +++ b/src/misc/SDL_url.c @@ -24,7 +24,7 @@ int SDL_OpenURL(const char *url) { - if (url == NULL) { + if (!url) { return SDL_InvalidParamError("url"); } return SDL_SYS_OpenURL(url); diff --git a/src/misc/windows/SDL_sysurl.c b/src/misc/windows/SDL_sysurl.c index 03ac819f8..bb89d55f6 100644 --- a/src/misc/windows/SDL_sysurl.c +++ b/src/misc/windows/SDL_sysurl.c @@ -45,7 +45,7 @@ int SDL_SYS_OpenURL(const char *url) } wurl = WIN_UTF8ToStringW(url); - if (wurl == NULL) { + if (!wurl) { WIN_CoUninitialize(); return SDL_OutOfMemory(); } diff --git a/src/power/SDL_power.c b/src/power/SDL_power.c index 8676a316d..61921703b 100644 --- a/src/power/SDL_power.c +++ b/src/power/SDL_power.c @@ -94,10 +94,10 @@ SDL_PowerState SDL_GetPowerInfo(int *seconds, int *percent) int _seconds, _percent; /* Make these never NULL for platform-specific implementations. */ - if (seconds == NULL) { + if (!seconds) { seconds = &_seconds; } - if (percent == NULL) { + if (!percent) { percent = &_percent; } diff --git a/src/power/linux/SDL_syspower.c b/src/power/linux/SDL_syspower.c index 53fb6f53b..410dc6b00 100644 --- a/src/power/linux/SDL_syspower.c +++ b/src/power/linux/SDL_syspower.c @@ -45,7 +45,7 @@ static int open_power_file(const char *base, const char *node, const char *key) int fd; const size_t pathlen = SDL_strlen(base) + SDL_strlen(node) + SDL_strlen(key) + 3; char *path = SDL_stack_alloc(char, pathlen); - if (path == NULL) { + if (!path) { return -1; /* oh well. */ } @@ -241,7 +241,7 @@ SDL_bool SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState *state, int *seconds, i *state = SDL_POWERSTATE_UNKNOWN; dirp = opendir(proc_acpi_battery_path); - if (dirp == NULL) { + if (!dirp) { return SDL_FALSE; /* can't use this interface. */ } else { while ((dent = readdir(dirp)) != NULL) { @@ -253,7 +253,7 @@ SDL_bool SDL_GetPowerInfo_Linux_proc_acpi(SDL_PowerState *state, int *seconds, i } dirp = opendir(proc_acpi_ac_adapter_path); - if (dirp == NULL) { + if (!dirp) { return SDL_FALSE; /* can't use this interface. */ } else { while ((dent = readdir(dirp)) != NULL) { @@ -424,7 +424,7 @@ SDL_bool SDL_GetPowerInfo_Linux_sys_class_power_supply(SDL_PowerState *state, in DIR *dirp; dirp = opendir(base); - if (dirp == NULL) { + if (!dirp) { return SDL_FALSE; } @@ -623,7 +623,7 @@ SDL_bool SDL_GetPowerInfo_Linux_org_freedesktop_upower(SDL_PowerState *state, in char **paths = NULL; int i, numpaths = 0; - if (dbus == NULL || !SDL_DBus_CallMethodOnConnection(dbus->system_conn, UPOWER_DBUS_NODE, UPOWER_DBUS_PATH, UPOWER_DBUS_INTERFACE, "EnumerateDevices", + if (!dbus || !SDL_DBus_CallMethodOnConnection(dbus->system_conn, UPOWER_DBUS_NODE, UPOWER_DBUS_PATH, UPOWER_DBUS_INTERFACE, "EnumerateDevices", DBUS_TYPE_INVALID, DBUS_TYPE_ARRAY, DBUS_TYPE_OBJECT_PATH, &paths, &numpaths, DBUS_TYPE_INVALID)) { return SDL_FALSE; /* try a different approach than UPower. */ diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 1d55c87b7..8bf12cc83 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -229,9 +229,9 @@ static int FlushRenderCommands(SDL_Renderer *renderer) { int retval; - SDL_assert((renderer->render_commands == NULL) == (renderer->render_commands_tail == NULL)); + SDL_assert((!renderer->render_commands) == (!renderer->render_commands_tail)); - if (renderer->render_commands == NULL) { /* nothing to do! */ + if (!renderer->render_commands) { /* nothing to do! */ SDL_assert(renderer->vertex_data_used == 0); return 0; } @@ -241,7 +241,7 @@ static int FlushRenderCommands(SDL_Renderer *renderer) retval = renderer->RunCommandQueue(renderer, renderer->render_commands, renderer->vertex_data, renderer->vertex_data_used); /* Move the whole render command queue to the unused pool so we can reuse them next time. */ - if (renderer->render_commands_tail != NULL) { + if (renderer->render_commands_tail) { renderer->render_commands_tail->next = renderer->render_commands_pool; renderer->render_commands_pool = renderer->render_commands; renderer->render_commands_tail = NULL; @@ -293,7 +293,7 @@ void *SDL_AllocateRenderVertices(SDL_Renderer *renderer, const size_t numbytes, ptr = SDL_realloc(renderer->vertex_data, newsize); - if (ptr == NULL) { + if (!ptr) { SDL_OutOfMemory(); return NULL; } @@ -316,19 +316,19 @@ static SDL_RenderCommand *AllocateRenderCommand(SDL_Renderer *renderer) /* !!! FIXME: are there threading limitations in SDL's render API? If not, we need to mutex this. */ retval = renderer->render_commands_pool; - if (retval != NULL) { + if (retval) { renderer->render_commands_pool = retval->next; retval->next = NULL; } else { retval = SDL_calloc(1, sizeof(*retval)); - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); return NULL; } } - SDL_assert((renderer->render_commands == NULL) == (renderer->render_commands_tail == NULL)); - if (renderer->render_commands_tail != NULL) { + SDL_assert((!renderer->render_commands) == (!renderer->render_commands_tail)); + if (renderer->render_commands_tail) { renderer->render_commands_tail->next = retval; } else { renderer->render_commands = retval; @@ -364,7 +364,7 @@ static int QueueCmdSetViewport(SDL_Renderer *renderer) if (!renderer->viewport_queued || SDL_memcmp(&viewport, &renderer->last_queued_viewport, sizeof(viewport)) != 0) { SDL_RenderCommand *cmd = AllocateRenderCommand(renderer); - if (cmd != NULL) { + if (cmd) { cmd->command = SDL_RENDERCMD_SETVIEWPORT; cmd->data.viewport.first = 0; /* render backend will fill this in. */ SDL_copyp(&cmd->data.viewport.rect, &viewport); @@ -396,7 +396,7 @@ static int QueueCmdSetClipRect(SDL_Renderer *renderer) renderer->view->clipping_enabled != renderer->last_queued_cliprect_enabled || SDL_memcmp(&clip_rect, &renderer->last_queued_cliprect, sizeof(clip_rect)) != 0) { SDL_RenderCommand *cmd = AllocateRenderCommand(renderer); - if (cmd != NULL) { + if (cmd) { cmd->command = SDL_RENDERCMD_SETCLIPRECT; cmd->data.cliprect.enabled = renderer->view->clipping_enabled; SDL_copyp(&cmd->data.cliprect.rect, &clip_rect); @@ -419,7 +419,7 @@ static int QueueCmdSetDrawColor(SDL_Renderer *renderer, SDL_Color *col) SDL_RenderCommand *cmd = AllocateRenderCommand(renderer); retval = -1; - if (cmd != NULL) { + if (cmd) { cmd->command = SDL_RENDERCMD_SETDRAWCOLOR; cmd->data.color.first = 0; /* render backend will fill this in. */ cmd->data.color.r = col->r; @@ -441,7 +441,7 @@ static int QueueCmdSetDrawColor(SDL_Renderer *renderer, SDL_Color *col) static int QueueCmdClear(SDL_Renderer *renderer) { SDL_RenderCommand *cmd = AllocateRenderCommand(renderer); - if (cmd == NULL) { + if (!cmd) { return -1; } @@ -484,7 +484,7 @@ static SDL_RenderCommand *PrepQueueCmdDraw(SDL_Renderer *renderer, const SDL_Ren if (retval == 0) { cmd = AllocateRenderCommand(renderer); - if (cmd != NULL) { + if (cmd) { cmd->command = cmdtype; cmd->data.draw.first = 0; /* render backend will fill this in. */ cmd->data.draw.count = 0; /* render backend will fill this in. */ @@ -503,7 +503,7 @@ static int QueueCmdDrawPoints(SDL_Renderer *renderer, const SDL_FPoint *points, { SDL_RenderCommand *cmd = PrepQueueCmdDraw(renderer, SDL_RENDERCMD_DRAW_POINTS, NULL); int retval = -1; - if (cmd != NULL) { + if (cmd) { retval = renderer->QueueDrawPoints(renderer, cmd, points, count); if (retval < 0) { cmd->command = SDL_RENDERCMD_NO_OP; @@ -516,7 +516,7 @@ static int QueueCmdDrawLines(SDL_Renderer *renderer, const SDL_FPoint *points, c { SDL_RenderCommand *cmd = PrepQueueCmdDraw(renderer, SDL_RENDERCMD_DRAW_LINES, NULL); int retval = -1; - if (cmd != NULL) { + if (cmd) { retval = renderer->QueueDrawLines(renderer, cmd, points, count); if (retval < 0) { cmd->command = SDL_RENDERCMD_NO_OP; @@ -529,11 +529,11 @@ static int QueueCmdFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, con { SDL_RenderCommand *cmd; int retval = -1; - const int use_rendergeometry = (renderer->QueueFillRects == NULL); + const int use_rendergeometry = (!renderer->QueueFillRects); cmd = PrepQueueCmdDraw(renderer, (use_rendergeometry ? SDL_RENDERCMD_GEOMETRY : SDL_RENDERCMD_FILL_RECTS), NULL); - if (cmd != NULL) { + if (cmd) { if (use_rendergeometry) { SDL_bool isstack1; SDL_bool isstack2; @@ -603,7 +603,7 @@ static int QueueCmdCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_ { SDL_RenderCommand *cmd = PrepQueueCmdDraw(renderer, SDL_RENDERCMD_COPY, texture); int retval = -1; - if (cmd != NULL) { + if (cmd) { retval = renderer->QueueCopy(renderer, cmd, texture, srcrect, dstrect); if (retval < 0) { cmd->command = SDL_RENDERCMD_NO_OP; @@ -618,7 +618,7 @@ static int QueueCmdCopyEx(SDL_Renderer *renderer, SDL_Texture *texture, { SDL_RenderCommand *cmd = PrepQueueCmdDraw(renderer, SDL_RENDERCMD_COPY_EX, texture); int retval = -1; - if (cmd != NULL) { + if (cmd) { retval = renderer->QueueCopyEx(renderer, cmd, texture, srcquad, dstrect, angle, center, flip, scale_x, scale_y); if (retval < 0) { cmd->command = SDL_RENDERCMD_NO_OP; @@ -638,7 +638,7 @@ static int QueueCmdGeometry(SDL_Renderer *renderer, SDL_Texture *texture, SDL_RenderCommand *cmd; int retval = -1; cmd = PrepQueueCmdDraw(renderer, SDL_RENDERCMD_GEOMETRY, texture); - if (cmd != NULL) { + if (cmd) { retval = renderer->QueueGeometry(renderer, cmd, texture, xy, xy_stride, color, color_stride, uv, uv_stride, @@ -751,13 +751,13 @@ static SDL_INLINE void VerifyDrawQueueFunctions(const SDL_Renderer *renderer) { /* all of these functions are required to be implemented, even as no-ops, so we don't have to check that they aren't NULL over and over. */ - SDL_assert(renderer->QueueSetViewport != NULL); - SDL_assert(renderer->QueueSetDrawColor != NULL); - SDL_assert(renderer->QueueDrawPoints != NULL); - SDL_assert(renderer->QueueDrawLines != NULL || renderer->QueueGeometry != NULL); - SDL_assert(renderer->QueueFillRects != NULL || renderer->QueueGeometry != NULL); - SDL_assert(renderer->QueueCopy != NULL || renderer->QueueGeometry != NULL); - SDL_assert(renderer->RunCommandQueue != NULL); + SDL_assert(renderer->QueueSetViewport); + SDL_assert(renderer->QueueSetDrawColor); + SDL_assert(renderer->QueueDrawPoints); + SDL_assert(renderer->QueueDrawLines || renderer->QueueGeometry); + SDL_assert(renderer->QueueFillRects || renderer->QueueGeometry); + SDL_assert(renderer->QueueCopy || renderer->QueueGeometry); + SDL_assert(renderer->RunCommandQueue); } static SDL_RenderLineMethod SDL_GetRenderLineMethod(void) @@ -817,7 +817,7 @@ SDL_Renderer *SDL_CreateRenderer(SDL_Window *window, const char *name, Uint32 fl Android_ActivityMutex_Lock_Running(); #endif - if (window == NULL) { + if (!window) { SDL_InvalidParamError("window"); goto error; } @@ -871,7 +871,7 @@ SDL_Renderer *SDL_CreateRenderer(SDL_Window *window, const char *name, Uint32 fl } } - if (renderer == NULL) { + if (!renderer) { SDL_SetError("Couldn't find matching render driver"); goto error; } @@ -1105,7 +1105,7 @@ static SDL_ScaleMode SDL_GetScaleMode(void) { const char *hint = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY); - if (hint == NULL || SDL_strcasecmp(hint, "nearest") == 0) { + if (!hint || SDL_strcasecmp(hint, "nearest") == 0) { return SDL_SCALEMODE_NEAREST; } else if (SDL_strcasecmp(hint, "linear") == 0) { return SDL_SCALEMODE_LINEAR; @@ -1146,7 +1146,7 @@ SDL_Texture *SDL_CreateTexture(SDL_Renderer *renderer, Uint32 format, int access return NULL; } texture = (SDL_Texture *)SDL_calloc(1, sizeof(*texture)); - if (texture == NULL) { + if (!texture) { SDL_OutOfMemory(); return NULL; } @@ -1243,7 +1243,7 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s CHECK_RENDERER_MAGIC(renderer, NULL); - if (surface == NULL) { + if (!surface) { SDL_InvalidParamError("SDL_CreateTextureFromSurface(): surface"); return NULL; } @@ -1307,7 +1307,7 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s texture = SDL_CreateTexture(renderer, format, SDL_TEXTUREACCESS_STATIC, surface->w, surface->h); - if (texture == NULL) { + if (!texture) { return NULL; } @@ -1339,7 +1339,7 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s /* Set up a destination surface for the texture update */ dst_fmt = SDL_CreatePixelFormat(format); - if (dst_fmt == NULL) { + if (!dst_fmt) { SDL_DestroyTexture(texture); return NULL; } @@ -1541,7 +1541,7 @@ static int SDL_UpdateTextureYUV(SDL_Texture *texture, const SDL_Rect *rect, const size_t alloclen = (size_t)rect->h * temp_pitch; if (alloclen > 0) { void *temp_pixels = SDL_malloc(alloclen); - if (temp_pixels == NULL) { + if (!temp_pixels) { return SDL_OutOfMemory(); } SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format, @@ -1581,7 +1581,7 @@ static int SDL_UpdateTextureNative(SDL_Texture *texture, const SDL_Rect *rect, const size_t alloclen = (size_t)rect->h * temp_pitch; if (alloclen > 0) { void *temp_pixels = SDL_malloc(alloclen); - if (temp_pixels == NULL) { + if (!temp_pixels) { return SDL_OutOfMemory(); } SDL_ConvertPixels(rect->w, rect->h, @@ -1600,7 +1600,7 @@ int SDL_UpdateTexture(SDL_Texture *texture, const SDL_Rect *rect, const void *pi CHECK_TEXTURE_MAGIC(texture, -1); - if (pixels == NULL) { + if (!pixels) { return SDL_InvalidParamError("pixels"); } if (!pitch) { @@ -1674,7 +1674,7 @@ static int SDL_UpdateTextureYUVPlanar(SDL_Texture *texture, const SDL_Rect *rect const size_t alloclen = (size_t)rect->h * temp_pitch; if (alloclen > 0) { void *temp_pixels = SDL_malloc(alloclen); - if (temp_pixels == NULL) { + if (!temp_pixels) { return SDL_OutOfMemory(); } SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format, @@ -1724,7 +1724,7 @@ static int SDL_UpdateTextureNVPlanar(SDL_Texture *texture, const SDL_Rect *rect, const size_t alloclen = (size_t)rect->h * temp_pitch; if (alloclen > 0) { void *temp_pixels = SDL_malloc(alloclen); - if (temp_pixels == NULL) { + if (!temp_pixels) { return SDL_OutOfMemory(); } SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format, @@ -1749,19 +1749,19 @@ int SDL_UpdateYUVTexture(SDL_Texture *texture, const SDL_Rect *rect, CHECK_TEXTURE_MAGIC(texture, -1); - if (Yplane == NULL) { + if (!Yplane) { return SDL_InvalidParamError("Yplane"); } if (!Ypitch) { return SDL_InvalidParamError("Ypitch"); } - if (Uplane == NULL) { + if (!Uplane) { return SDL_InvalidParamError("Uplane"); } if (!Upitch) { return SDL_InvalidParamError("Upitch"); } - if (Vplane == NULL) { + if (!Vplane) { return SDL_InvalidParamError("Vplane"); } if (!Vpitch) { @@ -1815,13 +1815,13 @@ int SDL_UpdateNVTexture(SDL_Texture *texture, const SDL_Rect *rect, CHECK_TEXTURE_MAGIC(texture, -1); - if (Yplane == NULL) { + if (!Yplane) { return SDL_InvalidParamError("Yplane"); } if (!Ypitch) { return SDL_InvalidParamError("Ypitch"); } - if (UVplane == NULL) { + if (!UVplane) { return SDL_InvalidParamError("UVplane"); } if (!UVpitch) { @@ -1894,7 +1894,7 @@ int SDL_LockTexture(SDL_Texture *texture, const SDL_Rect *rect, void **pixels, i return SDL_SetError("SDL_LockTexture(): texture must be streaming"); } - if (rect == NULL) { + if (!rect) { full_rect.x = 0; full_rect.y = 0; full_rect.w = texture->w; @@ -1929,7 +1929,7 @@ int SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, SDL_Sur int pitch = 0; /* fix static analysis */ int ret; - if (texture == NULL || surface == NULL) { + if (!texture || !surface) { return -1; } @@ -1947,7 +1947,7 @@ int SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, SDL_Sur } texture->locked_surface = SDL_CreateSurfaceFrom(pixels, real_rect.w, real_rect.h, pitch, texture->format); - if (texture->locked_surface == NULL) { + if (!texture->locked_surface) { SDL_UnlockTexture(texture); return -1; } @@ -2074,7 +2074,7 @@ static int SDL_SetRenderTargetInternal(SDL_Renderer *renderer, SDL_Texture *text int SDL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) { - if (texture == NULL && renderer->logical_target) { + if (!texture && renderer->logical_target) { return SDL_SetRenderTargetInternal(renderer, renderer->logical_target); } else { return SDL_SetRenderTargetInternal(renderer, texture); @@ -2304,7 +2304,7 @@ static void SDL_RenderLogicalBorders(SDL_Renderer *renderer) static void SDL_RenderLogicalPresentation(SDL_Renderer *renderer) { - SDL_assert(renderer->target == NULL); + SDL_assert(!renderer->target); SDL_SetRenderViewport(renderer, NULL); SDL_SetRenderClipRect(renderer, NULL); SDL_SetRenderScale(renderer, 1.0f, 1.0f); @@ -2673,7 +2673,7 @@ static int RenderPointsWithRects(SDL_Renderer *renderer, const SDL_FPoint *fpoin } frects = SDL_small_alloc(SDL_FRect, count, &isstack); - if (frects == NULL) { + if (!frects) { return SDL_OutOfMemory(); } @@ -2697,7 +2697,7 @@ int SDL_RenderPoints(SDL_Renderer *renderer, const SDL_FPoint *points, int count CHECK_RENDERER_MAGIC(renderer, -1); - if (points == NULL) { + if (!points) { return SDL_InvalidParamError("SDL_RenderPoints(): points"); } if (count < 1) { @@ -2784,7 +2784,7 @@ static int RenderLineBresenham(SDL_Renderer *renderer, int x1, int y1, int x2, i } points = SDL_small_alloc(SDL_FPoint, numpixels, &isstack); - if (points == NULL) { + if (!points) { return SDL_OutOfMemory(); } for (i = 0; i < numpixels; ++i) { @@ -2827,7 +2827,7 @@ static int RenderLinesWithRectsF(SDL_Renderer *renderer, SDL_bool draw_last = SDL_FALSE; frects = SDL_small_alloc(SDL_FRect, count - 1, &isstack); - if (frects == NULL) { + if (!frects) { return SDL_OutOfMemory(); } @@ -2893,7 +2893,7 @@ int SDL_RenderLines(SDL_Renderer *renderer, const SDL_FPoint *points, int count) CHECK_RENDERER_MAGIC(renderer, -1); - if (points == NULL) { + if (!points) { return SDL_InvalidParamError("SDL_RenderLines(): points"); } if (count < 2) { @@ -3046,7 +3046,7 @@ int SDL_RenderRect(SDL_Renderer *renderer, const SDL_FRect *rect) CHECK_RENDERER_MAGIC(renderer, -1); /* If 'rect' == NULL, then outline the whole surface */ - if (rect == NULL) { + if (!rect) { GetRenderViewportSize(renderer, &frect); rect = &frect; } @@ -3070,7 +3070,7 @@ int SDL_RenderRects(SDL_Renderer *renderer, const SDL_FRect *rects, int count) CHECK_RENDERER_MAGIC(renderer, -1); - if (rects == NULL) { + if (!rects) { return SDL_InvalidParamError("SDL_RenderRects(): rects"); } if (count < 1) { @@ -3099,7 +3099,7 @@ int SDL_RenderFillRect(SDL_Renderer *renderer, const SDL_FRect *rect) CHECK_RENDERER_MAGIC(renderer, -1); /* If 'rect' == NULL, then fill the whole surface */ - if (rect == NULL) { + if (!rect) { GetRenderViewportSize(renderer, &frect); rect = &frect; } @@ -3115,7 +3115,7 @@ int SDL_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int coun CHECK_RENDERER_MAGIC(renderer, -1); - if (rects == NULL) { + if (!rects) { return SDL_InvalidParamError("SDL_RenderFillRects(): rects"); } if (count < 1) { @@ -3130,7 +3130,7 @@ int SDL_RenderFillRects(SDL_Renderer *renderer, const SDL_FRect *rects, int coun #endif frects = SDL_small_alloc(SDL_FRect, count, &isstack); - if (frects == NULL) { + if (!frects) { return SDL_OutOfMemory(); } for (i = 0; i < count; ++i) { @@ -3168,7 +3168,7 @@ int SDL_RenderTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_FR } #endif - use_rendergeometry = (renderer->QueueCopy == NULL); + use_rendergeometry = (!renderer->QueueCopy); real_srcrect.x = 0.0f; real_srcrect.y = 0.0f; @@ -3283,7 +3283,7 @@ int SDL_RenderTextureRotated(SDL_Renderer *renderer, SDL_Texture *texture, } #endif - use_rendergeometry = (renderer->QueueCopyEx == NULL); + use_rendergeometry = (!renderer->QueueCopyEx); real_srcrect.x = 0.0f; real_srcrect.y = 0.0f; @@ -3823,15 +3823,15 @@ int SDL_RenderGeometryRaw(SDL_Renderer *renderer, } } - if (xy == NULL) { + if (!xy) { return SDL_InvalidParamError("xy"); } - if (color == NULL) { + if (!color) { return SDL_InvalidParamError("color"); } - if (texture && uv == NULL) { + if (texture && !uv) { return SDL_InvalidParamError("uv"); } @@ -3923,7 +3923,7 @@ int SDL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, Uint32 fo FlushRenderCommands(renderer); /* we need to render before we read the results. */ if (!format) { - if (renderer->target == NULL) { + if (!renderer->target) { format = SDL_GetWindowPixelFormat(renderer->window); } else { format = renderer->target->format; @@ -4078,7 +4078,7 @@ static void SDL_DiscardAllCommands(SDL_Renderer *renderer) { SDL_RenderCommand *cmd; - if (renderer->render_commands_tail != NULL) { + if (renderer->render_commands_tail) { renderer->render_commands_tail->next = renderer->render_commands_pool; cmd = renderer->render_commands; } else { @@ -4089,7 +4089,7 @@ static void SDL_DiscardAllCommands(SDL_Renderer *renderer) renderer->render_commands_tail = NULL; renderer->render_commands = NULL; - while (cmd != NULL) { + while (cmd) { SDL_RenderCommand *next = cmd->next; SDL_free(cmd); cmd = next; @@ -4319,7 +4319,7 @@ int SDL_SetRenderVSync(SDL_Renderer *renderer, int vsync) int SDL_GetRenderVSync(SDL_Renderer *renderer, int *vsync) { CHECK_RENDERER_MAGIC(renderer, -1); - if (vsync == NULL) { + if (!vsync) { return SDL_InvalidParamError("vsync"); } *vsync = renderer->wanted_vsync; diff --git a/src/render/SDL_yuv_sw.c b/src/render/SDL_yuv_sw.c index bcc7cdfc0..9c123dd04 100644 --- a/src/render/SDL_yuv_sw.c +++ b/src/render/SDL_yuv_sw.c @@ -46,7 +46,7 @@ SDL_SW_YUVTexture *SDL_SW_CreateYUVTexture(Uint32 format, int w, int h) } swdata = (SDL_SW_YUVTexture *)SDL_calloc(1, sizeof(*swdata)); - if (swdata == NULL) { + if (!swdata) { SDL_OutOfMemory(); return NULL; } diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index 9324087eb..7870d10eb 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -432,7 +432,7 @@ static int D3D_CreateStagingTexture(IDirect3DDevice9 *device, D3D_TextureRep *te { HRESULT result; - if (texture->staging == NULL) { + if (!texture->staging) { result = IDirect3DDevice9_CreateTexture(device, texture->w, texture->h, 1, 0, texture->d3dfmt, D3DPOOL_SYSTEMMEM, &texture->staging, NULL); if (FAILED(result)) { @@ -524,7 +524,7 @@ static int D3D_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) DWORD usage; texturedata = (D3D_TextureData *)SDL_calloc(1, sizeof(*texturedata)); - if (texturedata == NULL) { + if (!texturedata) { return SDL_OutOfMemory(); } texturedata->scaleMode = (texture->scaleMode == SDL_SCALEMODE_NEAREST) ? D3DTEXF_POINT : D3DTEXF_LINEAR; @@ -562,7 +562,7 @@ static int D3D_RecreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; - if (texturedata == NULL) { + if (!texturedata) { return 0; } @@ -589,7 +589,7 @@ static int D3D_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; - if (texturedata == NULL) { + if (!texturedata) { return SDL_SetError("Texture is not currently available"); } @@ -625,7 +625,7 @@ static int D3D_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture, D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; - if (texturedata == NULL) { + if (!texturedata) { return SDL_SetError("Texture is not currently available"); } @@ -649,7 +649,7 @@ static int D3D_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; IDirect3DDevice9 *device = data->device; - if (texturedata == NULL) { + if (!texturedata) { return SDL_SetError("Texture is not currently available"); } #if SDL_HAVE_YUV @@ -699,7 +699,7 @@ static void D3D_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) D3D_RenderData *data = (D3D_RenderData *)renderer->driverdata; D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; - if (texturedata == NULL) { + if (!texturedata) { return; } #if SDL_HAVE_YUV @@ -727,7 +727,7 @@ static void D3D_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *texture { D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; - if (texturedata == NULL) { + if (!texturedata) { return; } @@ -743,18 +743,18 @@ static int D3D_SetRenderTargetInternal(SDL_Renderer *renderer, SDL_Texture *text IDirect3DDevice9 *device = data->device; /* Release the previous render target if it wasn't the default one */ - if (data->currentRenderTarget != NULL) { + if (data->currentRenderTarget) { IDirect3DSurface9_Release(data->currentRenderTarget); data->currentRenderTarget = NULL; } - if (texture == NULL) { + if (!texture) { IDirect3DDevice9_SetRenderTarget(data->device, 0, data->defaultRenderTarget); return 0; } texturedata = (D3D_TextureData *)texture->driverdata; - if (texturedata == NULL) { + if (!texturedata) { return SDL_SetError("Texture is not currently available"); } @@ -809,7 +809,7 @@ static int D3D_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, c Vertex *verts = (Vertex *)SDL_AllocateRenderVertices(renderer, vertslen, 0, &cmd->data.draw.first); int i; - if (verts == NULL) { + if (!verts) { return -1; } @@ -834,7 +834,7 @@ static int D3D_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL int count = indices ? num_indices : num_vertices; Vertex *verts = (Vertex *)SDL_AllocateRenderVertices(renderer, count * sizeof(Vertex), 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -928,9 +928,9 @@ static int SetupTextureState(D3D_RenderData *data, SDL_Texture *texture, LPDIREC { D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; - SDL_assert(*shader == NULL); + SDL_assert(!*shader); - if (texturedata == NULL) { + if (!texturedata) { return SDL_SetError("Texture is not currently available"); } @@ -982,11 +982,11 @@ static int SetDrawState(D3D_RenderData *data, const SDL_RenderCommand *cmd) LPDIRECT3DPIXELSHADER9 shader = NULL; /* disable any enabled textures we aren't going to use, let SetupTextureState() do the rest. */ - if (texture == NULL) { + if (!texture) { IDirect3DDevice9_SetTexture(data->device, 0, NULL); } #if SDL_HAVE_YUV - if ((newtexturedata == NULL || !newtexturedata->yuv) && (oldtexturedata && oldtexturedata->yuv)) { + if ((!newtexturedata || !newtexturedata->yuv) && (oldtexturedata && oldtexturedata->yuv)) { IDirect3DDevice9_SetTexture(data->device, 1, NULL); IDirect3DDevice9_SetTexture(data->device, 2, NULL); } @@ -1380,7 +1380,7 @@ static void D3D_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) #endif } - if (data == NULL) { + if (!data) { return; } @@ -1406,7 +1406,7 @@ static void D3D_DestroyRenderer(SDL_Renderer *renderer) IDirect3DSurface9_Release(data->defaultRenderTarget); data->defaultRenderTarget = NULL; } - if (data->currentRenderTarget != NULL) { + if (data->currentRenderTarget) { IDirect3DSurface9_Release(data->currentRenderTarget); data->currentRenderTarget = NULL; } @@ -1457,7 +1457,7 @@ static int D3D_Reset(SDL_Renderer *renderer) IDirect3DSurface9_Release(data->defaultRenderTarget); data->defaultRenderTarget = NULL; } - if (data->currentRenderTarget != NULL) { + if (data->currentRenderTarget) { IDirect3DSurface9_Release(data->currentRenderTarget); data->currentRenderTarget = NULL; } @@ -1550,14 +1550,14 @@ SDL_Renderer *D3D_CreateRenderer(SDL_Window *window, Uint32 flags) const SDL_DisplayMode *fullscreen_mode = NULL; renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); return NULL; } renderer->magic = &SDL_renderer_magic; data = (D3D_RenderData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { SDL_free(renderer); SDL_OutOfMemory(); return NULL; diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c index ef11c7de3..b66cd4fd5 100644 --- a/src/render/direct3d11/SDL_render_d3d11.c +++ b/src/render/direct3d11/SDL_render_d3d11.c @@ -397,7 +397,7 @@ static ID3D11BlendState *D3D11_CreateBlendState(SDL_Renderer *renderer, SDL_Blen } blendModes = (D3D11_BlendMode *)SDL_realloc(data->blendModes, (data->blendModesCount + 1) * sizeof(*blendModes)); - if (blendModes == NULL) { + if (!blendModes) { SAFE_RELEASE(blendState); SDL_OutOfMemory(); return NULL; @@ -454,7 +454,7 @@ static HRESULT D3D11_CreateDeviceResources(SDL_Renderer *renderer) } CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(data->hDXGIMod, "CreateDXGIFactory"); - if (CreateDXGIFactoryFunc == NULL) { + if (!CreateDXGIFactoryFunc) { result = E_FAIL; goto done; } @@ -754,7 +754,7 @@ static HRESULT D3D11_CreateSwapChain(SDL_Renderer *renderer, int w, int h) D3D11_RenderData *data = (D3D11_RenderData *)renderer->driverdata; #ifdef __WINRT__ IUnknown *coreWindow = D3D11_GetCoreWindowFromSDLRenderer(renderer); - const BOOL usingXAML = (coreWindow == NULL); + const BOOL usingXAML = (!coreWindow); #else IUnknown *coreWindow = NULL; const BOOL usingXAML = FALSE; @@ -941,7 +941,7 @@ static HRESULT D3D11_CreateWindowSizeDependentResources(SDL_Renderer *renderer) #endif } else { result = D3D11_CreateSwapChain(renderer, w, h); - if (FAILED(result) || data->swapChain == NULL) { + if (FAILED(result) || !data->swapChain) { goto done; } } @@ -1075,7 +1075,7 @@ static int D3D11_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) } textureData = (D3D11_TextureData *)SDL_calloc(1, sizeof(*textureData)); - if (textureData == NULL) { + if (!textureData) { SDL_OutOfMemory(); return -1; } @@ -1220,7 +1220,7 @@ static void D3D11_DestroyTexture(SDL_Renderer *renderer, { D3D11_TextureData *data = (D3D11_TextureData *)texture->driverdata; - if (data == NULL) { + if (!data) { return; } @@ -1331,7 +1331,7 @@ static int D3D11_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return SDL_SetError("Texture is not currently available"); } @@ -1367,7 +1367,7 @@ static int D3D11_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture, D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return SDL_SetError("Texture is not currently available"); } @@ -1399,7 +1399,7 @@ static int D3D11_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture, D3D11_TEXTURE2D_DESC stagingTextureDesc; D3D11_MAPPED_SUBRESOURCE textureMemory; - if (textureData == NULL) { + if (!textureData) { return SDL_SetError("Texture is not currently available"); } @@ -1507,7 +1507,7 @@ static int D3D11_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, D3D11_TEXTURE2D_DESC stagingTextureDesc; D3D11_MAPPED_SUBRESOURCE textureMemory; - if (textureData == NULL) { + if (!textureData) { return SDL_SetError("Texture is not currently available"); } #if SDL_HAVE_YUV @@ -1586,7 +1586,7 @@ static void D3D11_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return; } #if SDL_HAVE_YUV @@ -1622,7 +1622,7 @@ static void D3D11_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *textu { D3D11_TextureData *textureData = (D3D11_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return; } @@ -1635,7 +1635,7 @@ static IDXGIResource *D3D11_GetTextureDXGIResource(SDL_Texture *texture) IDXGIResource *resource = NULL; HRESULT result; - if (textureData == NULL || textureData->mainTexture == NULL) { + if (!textureData || !textureData->mainTexture) { SDL_SetError("Texture is not currently available"); return NULL; } @@ -1654,7 +1654,7 @@ static int D3D11_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) D3D11_RenderData *rendererData = (D3D11_RenderData *)renderer->driverdata; D3D11_TextureData *textureData = NULL; - if (texture == NULL) { + if (!texture) { rendererData->currentOffscreenRenderTargetView = NULL; return 0; } @@ -1685,7 +1685,7 @@ static int D3D11_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, color.b = cmd->data.draw.b; color.a = cmd->data.draw.a; - if (verts == NULL) { + if (!verts) { return -1; } @@ -1712,7 +1712,7 @@ static int D3D11_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S int count = indices ? num_indices : num_vertices; VertexPositionColor *verts = (VertexPositionColor *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertexPositionColor), 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -1984,9 +1984,9 @@ static int D3D11_SetDrawState(SDL_Renderer *renderer, const SDL_RenderCommand *c break; } } - if (blendState == NULL) { + if (!blendState) { blendState = D3D11_CreateBlendState(renderer, blendMode); - if (blendState == NULL) { + if (!blendState) { return -1; } } @@ -2239,13 +2239,13 @@ static int D3D11_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, D3D11_MAPPED_SUBRESOURCE textureMemory; renderTargetView = D3D11_GetCurrentRenderTargetView(renderer); - if (renderTargetView == NULL) { + if (!renderTargetView) { SDL_SetError("%s, ID3D11DeviceContext::OMGetRenderTargets failed", __FUNCTION__); goto done; } ID3D11View_GetResource(renderTargetView, (ID3D11Resource **)&backBuffer); - if (backBuffer == NULL) { + if (!backBuffer) { SDL_SetError("%s, ID3D11View::GetResource failed", __FUNCTION__); goto done; } @@ -2400,14 +2400,14 @@ SDL_Renderer *D3D11_CreateRenderer(SDL_Window *window, Uint32 flags) D3D11_RenderData *data; renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); return NULL; } renderer->magic = &SDL_renderer_magic; data = (D3D11_RenderData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { SDL_free(renderer); SDL_OutOfMemory(); return NULL; diff --git a/src/render/direct3d12/SDL_render_d3d12.c b/src/render/direct3d12/SDL_render_d3d12.c index 8e89185a0..00b24aec1 100644 --- a/src/render/direct3d12/SDL_render_d3d12.c +++ b/src/render/direct3d12/SDL_render_d3d12.c @@ -642,7 +642,7 @@ static D3D12_PipelineState *D3D12_CreatePipelineState(SDL_Renderer *renderer, } pipelineStates = (D3D12_PipelineState *)SDL_realloc(data->pipelineStates, (data->pipelineStateCount + 1) * sizeof(*pipelineStates)); - if (pipelineStates == NULL) { + if (!pipelineStates) { SAFE_RELEASE(pipelineState); SDL_OutOfMemory(); return NULL; @@ -757,7 +757,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) } } #endif - if (CreateEventExFunc == NULL) { + if (!CreateEventExFunc) { result = E_FAIL; goto done; } @@ -770,7 +770,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) } CreateDXGIFactoryFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(data->hDXGIMod, "CreateDXGIFactory2"); - if (CreateDXGIFactoryFunc == NULL) { + if (!CreateDXGIFactoryFunc) { result = E_FAIL; goto done; } @@ -814,7 +814,7 @@ static HRESULT D3D12_CreateDeviceResources(SDL_Renderer *renderer) /* If the debug hint is set, also create the DXGI factory in debug mode */ DXGIGetDebugInterfaceFunc = (PFN_CREATE_DXGI_FACTORY)SDL_LoadFunction(data->hDXGIMod, "DXGIGetDebugInterface1"); - if (DXGIGetDebugInterfaceFunc == NULL) { + if (!DXGIGetDebugInterfaceFunc) { result = E_FAIL; goto done; } @@ -1445,7 +1445,7 @@ static int D3D12_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) } textureData = (D3D12_TextureData *)SDL_calloc(1, sizeof(*textureData)); - if (textureData == NULL) { + if (!textureData) { SDL_OutOfMemory(); return -1; } @@ -1603,7 +1603,7 @@ static void D3D12_DestroyTexture(SDL_Renderer *renderer, D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return; } @@ -1770,7 +1770,7 @@ static int D3D12_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return SDL_SetError("Texture is not currently available"); } @@ -1815,7 +1815,7 @@ static int D3D12_UpdateTextureYUV(SDL_Renderer *renderer, SDL_Texture *texture, D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return SDL_SetError("Texture is not currently available"); } @@ -1839,7 +1839,7 @@ static int D3D12_UpdateTextureNV(SDL_Renderer *renderer, SDL_Texture *texture, D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return SDL_SetError("Texture is not currently available"); } @@ -1868,7 +1868,7 @@ static int D3D12_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, BYTE *textureMemory; int bpp; - if (textureData == NULL) { + if (!textureData) { return SDL_SetError("Texture is not currently available"); } #if SDL_HAVE_YUV @@ -1987,7 +1987,7 @@ static void D3D12_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) D3D12_TEXTURE_COPY_LOCATION dstLocation; int bpp; - if (textureData == NULL) { + if (!textureData) { return; } #if SDL_HAVE_YUV @@ -2058,7 +2058,7 @@ static void D3D12_SetTextureScaleMode(SDL_Renderer *renderer, SDL_Texture *textu { D3D12_TextureData *textureData = (D3D12_TextureData *)texture->driverdata; - if (textureData == NULL) { + if (!textureData) { return; } @@ -2071,7 +2071,7 @@ static IDXGIResource *D3D12_GetTextureDXGIResource(SDL_Texture *texture) IDXGIResource *resource = NULL; HRESULT result; - if (textureData == NULL || textureData->mainTexture == NULL) { + if (!textureData || !textureData->mainTexture) { SDL_SetError("Texture is not currently available"); return NULL; } @@ -2089,7 +2089,7 @@ static int D3D12_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) D3D12_RenderData *rendererData = (D3D12_RenderData *)renderer->driverdata; D3D12_TextureData *textureData = NULL; - if (texture == NULL) { + if (!texture) { if (rendererData->textureRenderTarget) { D3D12_TransitionResource(rendererData, rendererData->textureRenderTarget->mainTexture, @@ -2132,7 +2132,7 @@ static int D3D12_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, color.b = cmd->data.draw.b; color.a = cmd->data.draw.a; - if (verts == NULL) { + if (!verts) { return -1; } @@ -2159,7 +2159,7 @@ static int D3D12_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S int count = indices ? num_indices : num_vertices; VertexPositionColor *verts = (VertexPositionColor *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertexPositionColor), 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -2958,14 +2958,14 @@ SDL_Renderer *D3D12_CreateRenderer(SDL_Window *window, Uint32 flags) D3D12_RenderData *data; renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); return NULL; } renderer->magic = &SDL_renderer_magic; data = (D3D12_RenderData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { SDL_free(renderer); SDL_OutOfMemory(); return NULL; diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c index 2d7da7466..41a6cce73 100644 --- a/src/render/opengl/SDL_render_gl.c +++ b/src/render/opengl/SDL_render_gl.c @@ -183,7 +183,7 @@ static void GL_ClearErrors(SDL_Renderer *renderer) data->errors = 0; data->error_messages = NULL; } - } else if (data->glGetError != NULL) { + } else if (data->glGetError) { while (data->glGetError() != GL_NO_ERROR) { /* continue; */ } @@ -302,7 +302,7 @@ static GL_FBOList *GL_GetFBO(GL_RenderData *data, Uint32 w, Uint32 h) result = result->next; } - if (result == NULL) { + if (!result) { result = SDL_malloc(sizeof(GL_FBOList)); if (result) { result->w = w; @@ -460,7 +460,7 @@ static int GL_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) } data = (GL_TextureData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } @@ -877,7 +877,7 @@ static int GL_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) data->drawstate.viewport_dirty = SDL_TRUE; - if (texture == NULL) { + if (!texture) { data->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); return 0; } @@ -907,7 +907,7 @@ static int GL_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, co GLfloat *verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, count * 2 * sizeof(GLfloat), 0, &cmd->data.draw.first); int i; - if (verts == NULL) { + if (!verts) { return -1; } @@ -927,7 +927,7 @@ static int GL_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, con const size_t vertlen = (sizeof(GLfloat) * 2) * count; GLfloat *verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, vertlen, 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } cmd->data.draw.count = count; @@ -972,7 +972,7 @@ static int GL_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_ size_t sz = 2 * sizeof(GLfloat) + 4 * sizeof(Uint8) + (texture ? 2 : 0) * sizeof(GLfloat); verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, count * sz, 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -1078,7 +1078,7 @@ static int SetDrawState(GL_RenderData *data, const SDL_RenderCommand *cmd, const } if ((cmd->data.draw.texture != NULL) != data->drawstate.texturing) { - if (cmd->data.draw.texture == NULL) { + if (!cmd->data.draw.texture) { data->glDisable(data->textype); data->drawstate.texturing = SDL_FALSE; } else { @@ -1283,7 +1283,7 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo SDL_RenderCommand *nextcmd = cmd->next; SDL_BlendMode thisblend = cmd->data.draw.blend; - while (nextcmd != NULL) { + while (nextcmd) { const SDL_RenderCommandType nextcmdtype = nextcmd->command; if (nextcmdtype != SDL_RENDERCMD_DRAW_LINES) { break; /* can't go any further on this draw call, different render command up next. */ @@ -1317,7 +1317,7 @@ static int GL_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo SDL_RenderCommand *nextcmd = cmd->next; size_t count = cmd->data.draw.count; int ret; - while (nextcmd != NULL) { + while (nextcmd) { const SDL_RenderCommandType nextcmdtype = nextcmd->command; if (nextcmdtype != thiscmdtype) { break; /* can't go any further on this draw call, different render command up next. */ @@ -1426,7 +1426,7 @@ static int GL_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format); temp_pixels = SDL_malloc((size_t)rect->h * temp_pitch); - if (temp_pixels == NULL) { + if (!temp_pixels) { return SDL_OutOfMemory(); } @@ -1491,7 +1491,7 @@ static void GL_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) renderdata->drawstate.target = NULL; } - if (data == NULL) { + if (!data) { return; } if (data->texture) { @@ -1513,7 +1513,7 @@ static void GL_DestroyRenderer(SDL_Renderer *renderer) GL_RenderData *data = (GL_RenderData *)renderer->driverdata; if (data) { - if (data->context != NULL) { + if (data->context) { /* make sure we delete the right resources! */ GL_ActivateRenderer(renderer); } @@ -1728,13 +1728,13 @@ static SDL_Renderer *GL_CreateRenderer(SDL_Window *window, Uint32 flags) #endif renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); goto error; } data = (GL_RenderData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { SDL_free(renderer); SDL_OutOfMemory(); goto error; @@ -1836,7 +1836,7 @@ static SDL_Renderer *GL_CreateRenderer(SDL_Window *window, Uint32 flags) } hint = SDL_getenv("GL_ARB_texture_non_power_of_two"); - if (hint == NULL || *hint != '0') { + if (!hint || *hint != '0') { SDL_bool isGL2 = SDL_FALSE; const char *verstr = (const char *)data->glGetString(GL_VERSION); if (verstr) { diff --git a/src/render/opengl/SDL_shaders_gl.c b/src/render/opengl/SDL_shaders_gl.c index 4a35e1e7f..2416038a0 100644 --- a/src/render/opengl/SDL_shaders_gl.c +++ b/src/render/opengl/SDL_shaders_gl.c @@ -495,7 +495,7 @@ GL_ShaderContext *GL_CreateShaderContext(void) int i; ctx = (GL_ShaderContext *)SDL_calloc(1, sizeof(*ctx)); - if (ctx == NULL) { + if (!ctx) { return NULL; } diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index 7216a6140..75f9e2c60 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -216,7 +216,7 @@ static int GL_CheckAllErrors(const char *prefix, SDL_Renderer *renderer, const c for (;;) { GLenum error = data->glGetError(); if (error != GL_NO_ERROR) { - if (prefix == NULL || prefix[0] == '\0') { + if (!prefix || prefix[0] == '\0') { prefix = "generic"; } SDL_SetError("%s: %s (%d): %s %s (0x%X)", prefix, file, line, function, GL_TranslateError(error), error); @@ -269,7 +269,7 @@ static GLES2_FBOList *GLES2_GetFBO(GLES2_RenderData *data, Uint32 w, Uint32 h) while ((result) && ((result->w != w) || (result->h != h))) { result = result->next; } - if (result == NULL) { + if (!result) { result = SDL_malloc(sizeof(GLES2_FBOList)); result->w = w; result->h = h; @@ -415,7 +415,7 @@ static GLES2_ProgramCacheEntry *GLES2_CacheProgram(GLES2_RenderData *data, GLuin /* Create a program cache entry */ entry = (GLES2_ProgramCacheEntry *)SDL_calloc(1, sizeof(GLES2_ProgramCacheEntry)); - if (entry == NULL) { + if (!entry) { SDL_OutOfMemory(); return NULL; } @@ -476,7 +476,7 @@ static GLES2_ProgramCacheEntry *GLES2_CacheProgram(GLES2_RenderData *data, GLuin if (data->program_cache.count > GLES2_MAX_CACHED_PROGRAMS) { data->glDeleteProgram(data->program_cache.tail->id); data->program_cache.tail = data->program_cache.tail->prev; - if (data->program_cache.tail != NULL) { + if (data->program_cache.tail) { SDL_free(data->program_cache.tail->next); data->program_cache.tail->next = NULL; } @@ -493,7 +493,7 @@ static GLuint GLES2_CacheShader(GLES2_RenderData *data, GLES2_ShaderType type, G const GLchar *shader_src_list[3]; const GLchar *shader_body = GLES2_GetShader(type); - if (shader_body == NULL) { + if (!shader_body) { SDL_SetError("No shader body src"); return 0; } @@ -703,7 +703,7 @@ static int GLES2_SelectProgram(GLES2_RenderData *data, GLES2_ImageSource source, /* Generate a matching program */ program = GLES2_CacheProgram(data, vertex, fragment); - if (program == NULL) { + if (!program) { goto fault; } @@ -736,7 +736,7 @@ static int GLES2_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, color.b = cmd->data.draw.b; color.a = cmd->data.draw.a; - if (verts == NULL) { + if (!verts) { return -1; } @@ -769,7 +769,7 @@ static int GLES2_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, color.b = cmd->data.draw.b; color.a = cmd->data.draw.a; - if (verts == NULL) { + if (!verts) { return -1; } @@ -827,7 +827,7 @@ static int GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S if (texture) { SDL_Vertex *verts = (SDL_Vertex *)SDL_AllocateRenderVertices(renderer, count * sizeof(*verts), 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -867,7 +867,7 @@ static int GLES2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, S } else { SDL_VertexSolid *verts = (SDL_VertexSolid *)SDL_AllocateRenderVertices(renderer, count * sizeof(*verts), 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -947,7 +947,7 @@ static int SetDrawState(GLES2_RenderData *data, const SDL_RenderCommand *cmd, co } if ((texture != NULL) != data->drawstate.texturing) { - if (texture == NULL) { + if (!texture) { data->glDisableVertexAttribArray((GLenum)GLES2_ATTRIBUTE_TEXCOORD); data->drawstate.texturing = SDL_FALSE; } else { @@ -1270,7 +1270,7 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_RenderCommand *nextcmd = cmd->next; SDL_BlendMode thisblend = cmd->data.draw.blend; - while (nextcmd != NULL) { + while (nextcmd) { const SDL_RenderCommandType nextcmdtype = nextcmd->command; if (nextcmdtype != SDL_RENDERCMD_DRAW_LINES) { break; /* can't go any further on this draw call, different render command up next. */ @@ -1304,7 +1304,7 @@ static int GLES2_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_RenderCommand *nextcmd = cmd->next; size_t count = cmd->data.draw.count; int ret; - while (nextcmd != NULL) { + while (nextcmd) { const SDL_RenderCommandType nextcmdtype = nextcmd->command; if (nextcmdtype != thiscmdtype) { break; /* can't go any further on this draw call, different render command up next. */ @@ -1443,7 +1443,7 @@ static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) /* Allocate a texture struct */ data = (GLES2_TextureData *)SDL_calloc(1, sizeof(GLES2_TextureData)); - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } data->texture = 0; @@ -1578,7 +1578,7 @@ static int GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoff src = (Uint8 *)pixels; if ((size_t)pitch != src_pitch) { blob = (Uint8 *)SDL_malloc(src_pitch * height); - if (blob == NULL) { + if (!blob) { return SDL_OutOfMemory(); } src = blob; @@ -1595,7 +1595,7 @@ static int GLES2_TexSubImage2D(GLES2_RenderData *data, GLenum target, GLint xoff int i; Uint32 *src32 = (Uint32 *)src; blob2 = (Uint32 *)SDL_malloc(src_pitch * height); - if (blob2 == NULL) { + if (!blob2) { if (blob) { SDL_free(blob); } @@ -1856,7 +1856,7 @@ static int GLES2_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) data->drawstate.viewport_dirty = SDL_TRUE; - if (texture == NULL) { + if (!texture) { data->glBindFramebuffer(GL_FRAMEBUFFER, data->window_framebuffer); } else { texturedata = (GLES2_TextureData *)texture->driverdata; @@ -1922,7 +1922,7 @@ static int GLES2_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, } temp_pixels = SDL_malloc(buflen); - if (temp_pixels == NULL) { + if (!temp_pixels) { return SDL_OutOfMemory(); } @@ -2088,13 +2088,13 @@ static SDL_Renderer *GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) /* Create the renderer struct */ renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(SDL_Renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); goto error; } data = (GLES2_RenderData *)SDL_calloc(1, sizeof(GLES2_RenderData)); - if (data == NULL) { + if (!data) { SDL_free(renderer); SDL_OutOfMemory(); goto error; diff --git a/src/render/ps2/SDL_render_ps2.c b/src/render/ps2/SDL_render_ps2.c index c1d748e32..febf7031a 100644 --- a/src/render/ps2/SDL_render_ps2.c +++ b/src/render/ps2/SDL_render_ps2.c @@ -104,7 +104,7 @@ static int PS2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) { GSTEXTURE *ps2_tex = (GSTEXTURE *)SDL_calloc(1, sizeof(GSTEXTURE)); - if (ps2_tex == NULL) { + if (!ps2_tex) { return SDL_OutOfMemory(); } @@ -201,7 +201,7 @@ static int PS2_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, c gs_rgbaq rgbaq; int i; - if (vertices == NULL) { + if (!vertices) { return -1; } @@ -236,7 +236,7 @@ static int PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL GSPRIMUVPOINT *vertices = (GSPRIMUVPOINT *) SDL_AllocateRenderVertices(renderer, count * sizeof(GSPRIMUVPOINT), 4, &cmd->data.draw.first); GSTEXTURE *ps2_tex = (GSTEXTURE *) texture->driverdata; - if (vertices == NULL) { + if (!vertices) { return -1; } @@ -269,7 +269,7 @@ static int PS2_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL } else { GSPRIMPOINT *vertices = (GSPRIMPOINT *)SDL_AllocateRenderVertices(renderer, count * sizeof(GSPRIMPOINT), 4, &cmd->data.draw.first); - if (vertices == NULL) { + if (!vertices) { return -1; } @@ -530,11 +530,11 @@ static void PS2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) GSTEXTURE *ps2_texture = (GSTEXTURE *)texture->driverdata; PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata; - if (data == NULL) { + if (!data) { return; } - if (ps2_texture == NULL) { + if (!ps2_texture) { return; } @@ -583,13 +583,13 @@ static SDL_Renderer *PS2_CreateRenderer(SDL_Window *window, Uint32 flags) SDL_bool dynamicVsync; renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); return NULL; } data = (PS2_RenderData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { PS2_DestroyRenderer(renderer); SDL_OutOfMemory(); return NULL; diff --git a/src/render/psp/SDL_render_psp.c b/src/render/psp/SDL_render_psp.c index 82b0a6b79..1f5a28385 100644 --- a/src/render/psp/SDL_render_psp.c +++ b/src/render/psp/SDL_render_psp.c @@ -281,11 +281,11 @@ static int TextureSwizzle(PSP_TextureData *psp_texture, void *dst) src = (unsigned int *)psp_texture->data; data = dst; - if (data == NULL) { + if (!data) { data = SDL_malloc(psp_texture->size); } - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } @@ -343,11 +343,11 @@ static int TextureUnswizzle(PSP_TextureData *psp_texture, void *dst) data = dst; - if (data == NULL) { + if (!data) { data = SDL_malloc(psp_texture->size); } - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } @@ -391,7 +391,7 @@ static int TextureSpillToSram(PSP_RenderData *data, PSP_TextureData *psp_texture if (psp_texture->swizzled) { // Texture was swizzled in vram, just copy to system memory void *sdata = SDL_malloc(psp_texture->size); - if (sdata == NULL) { + if (!sdata) { return SDL_OutOfMemory(); } @@ -483,7 +483,7 @@ static int PSP_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) PSP_RenderData *data = renderer->driverdata; PSP_TextureData *psp_texture = (PSP_TextureData *)SDL_calloc(1, sizeof(*psp_texture)); - if (psp_texture == NULL) { + if (!psp_texture) { return SDL_OutOfMemory(); } @@ -629,7 +629,7 @@ static int PSP_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, c VertV *verts = (VertV *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertV), 4, &cmd->data.draw.first); int i; - if (verts == NULL) { + if (!verts) { return -1; } @@ -655,10 +655,10 @@ static int PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL cmd->data.draw.count = count; size_indices = indices ? size_indices : 0; - if (texture == NULL) { + if (!texture) { VertCV *verts; verts = (VertCV *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertCV), 4, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -691,7 +691,7 @@ static int PSP_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL PSP_TextureData *psp_texture = (PSP_TextureData *)texture->driverdata; VertTCV *verts; verts = (VertTCV *)SDL_AllocateRenderVertices(renderer, count * sizeof(VertTCV), 4, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -736,7 +736,7 @@ static int PSP_QueueFillRects(SDL_Renderer *renderer, SDL_RenderCommand *cmd, co VertV *verts = (VertV *)SDL_AllocateRenderVertices(renderer, count * 2 * sizeof(VertV), 4, &cmd->data.draw.first); int i; - if (verts == NULL) { + if (!verts) { return -1; } @@ -772,7 +772,7 @@ static int PSP_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Tex if ((MathAbs(u1) - MathAbs(u0)) < 64.0f) { verts = (VertTV *)SDL_AllocateRenderVertices(renderer, 2 * sizeof(VertTV), 4, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -808,7 +808,7 @@ static int PSP_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Tex cmd->data.draw.count = count; verts = (VertTV *)SDL_AllocateRenderVertices(renderer, count * 2 * sizeof(VertTV), 4, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -859,7 +859,7 @@ static int PSP_QueueCopyEx(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_T float u1 = srcrect->x + srcrect->w; float v1 = srcrect->y + srcrect->h; - if (verts == NULL) { + if (!verts) { return -1; } @@ -1010,7 +1010,7 @@ static void PSP_SetBlendState(PSP_RenderData *data, PSP_BlendState *state) } if (state->texture != current->texture) { - if (state->texture != NULL) { + if (state->texture) { TextureActivate(state->texture); sceGuEnable(GU_TEXTURE_2D); } else { @@ -1034,7 +1034,7 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v rendering backends report a reasonable maximum, so the higher level can flush if we appear to be exceeding that. */ gpumem = (Uint8 *)sceGuGetMemory(vertsize); - if (gpumem == NULL) { + if (!gpumem) { return SDL_SetError("Couldn't obtain a %d-byte vertex buffer!", (int)vertsize); } SDL_memcpy(gpumem, vertices, vertsize); @@ -1176,7 +1176,7 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v case SDL_RENDERCMD_GEOMETRY: { const size_t count = cmd->data.draw.count; - if (cmd->data.draw.texture == NULL) { + if (!cmd->data.draw.texture) { const VertCV *verts = (VertCV *)(gpumem + cmd->data.draw.first); sceGuDisable(GU_TEXTURE_2D); /* In GU_SMOOTH mode */ @@ -1244,11 +1244,11 @@ static void PSP_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) PSP_RenderData *renderdata = (PSP_RenderData *)renderer->driverdata; PSP_TextureData *psp_texture = (PSP_TextureData *)texture->driverdata; - if (renderdata == NULL) { + if (!renderdata) { return; } - if (psp_texture == NULL) { + if (!psp_texture) { return; } @@ -1299,13 +1299,13 @@ SDL_Renderer *PSP_CreateRenderer(SDL_Window *window, Uint32 flags) void *doublebuffer = NULL; renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); return NULL; } data = (PSP_RenderData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { PSP_DestroyRenderer(renderer); SDL_OutOfMemory(); return NULL; diff --git a/src/render/software/SDL_blendfillrect.c b/src/render/software/SDL_blendfillrect.c index 72a01d7a6..73c456c1f 100644 --- a/src/render/software/SDL_blendfillrect.c +++ b/src/render/software/SDL_blendfillrect.c @@ -211,7 +211,7 @@ int SDL_BlendFillRect(SDL_Surface *dst, const SDL_Rect *rect, { SDL_Rect clipped; - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_BlendFillRect(): dst"); } @@ -281,7 +281,7 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL; int status = 0; - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_BlendFillRects(): dst"); } @@ -325,7 +325,7 @@ int SDL_BlendFillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, break; } - if (func == NULL) { + if (!func) { if (!dst->format->Amask) { func = SDL_BlendFillRect_RGB; } else { diff --git a/src/render/software/SDL_blendline.c b/src/render/software/SDL_blendline.c index 1bacf9457..83280e44b 100644 --- a/src/render/software/SDL_blendline.c +++ b/src/render/software/SDL_blendline.c @@ -798,12 +798,12 @@ int SDL_BlendLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, { BlendLineFunc func; - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_BlendLine(): dst"); } func = SDL_CalculateBlendLineFunc(dst->format); - if (func == NULL) { + if (!func) { return SDL_SetError("SDL_BlendLine(): Unsupported surface format"); } @@ -826,12 +826,12 @@ int SDL_BlendLines(SDL_Surface *dst, const SDL_Point *points, int count, SDL_bool draw_end; BlendLineFunc func; - if (dst == NULL) { + if (!dst) { return SDL_SetError("SDL_BlendLines(): Passed NULL destination surface"); } func = SDL_CalculateBlendLineFunc(dst->format); - if (func == NULL) { + if (!func) { return SDL_SetError("SDL_BlendLines(): Unsupported surface format"); } diff --git a/src/render/software/SDL_blendpoint.c b/src/render/software/SDL_blendpoint.c index 34ed59994..59b1fd6db 100644 --- a/src/render/software/SDL_blendpoint.c +++ b/src/render/software/SDL_blendpoint.c @@ -209,7 +209,7 @@ static int SDL_BlendPoint_RGBA(SDL_Surface *dst, int x, int y, SDL_BlendMode ble int SDL_BlendPoint(SDL_Surface *dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_BlendPoint(): dst"); } @@ -277,7 +277,7 @@ int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL; int status = 0; - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_BlendPoints(): dst"); } @@ -323,7 +323,7 @@ int SDL_BlendPoints(SDL_Surface *dst, const SDL_Point *points, int count, break; } - if (func == NULL) { + if (!func) { if (!dst->format->Amask) { func = SDL_BlendPoint_RGB; } else { diff --git a/src/render/software/SDL_drawline.c b/src/render/software/SDL_drawline.c index 556805740..bb7d6a3d4 100644 --- a/src/render/software/SDL_drawline.c +++ b/src/render/software/SDL_drawline.c @@ -137,12 +137,12 @@ int SDL_DrawLine(SDL_Surface *dst, int x1, int y1, int x2, int y2, Uint32 color) { DrawLineFunc func; - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_DrawLine(): dst"); } func = SDL_CalculateDrawLineFunc(dst->format); - if (func == NULL) { + if (!func) { return SDL_SetError("SDL_DrawLine(): Unsupported surface format"); } @@ -165,12 +165,12 @@ int SDL_DrawLines(SDL_Surface *dst, const SDL_Point *points, int count, SDL_bool draw_end; DrawLineFunc func; - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_DrawLines(): dst"); } func = SDL_CalculateDrawLineFunc(dst->format); - if (func == NULL) { + if (!func) { return SDL_SetError("SDL_DrawLines(): Unsupported surface format"); } diff --git a/src/render/software/SDL_drawpoint.c b/src/render/software/SDL_drawpoint.c index 7f3c2a80a..a9bd16cb9 100644 --- a/src/render/software/SDL_drawpoint.c +++ b/src/render/software/SDL_drawpoint.c @@ -27,7 +27,7 @@ int SDL_DrawPoint(SDL_Surface *dst, int x, int y, Uint32 color) { - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_DrawPoint(): dst"); } @@ -67,7 +67,7 @@ int SDL_DrawPoints(SDL_Surface *dst, const SDL_Point *points, int count, int i; int x, y; - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_DrawPoints(): dst"); } diff --git a/src/render/software/SDL_render_sw.c b/src/render/software/SDL_render_sw.c index 24e15c3e3..e6516a43b 100644 --- a/src/render/software/SDL_render_sw.c +++ b/src/render/software/SDL_render_sw.c @@ -101,7 +101,7 @@ static int SW_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) { SDL_Surface *surface = SDL_CreateSurface(texture->w, texture->h, texture->format); - if (surface == NULL) { + if (!surface) { return SDL_SetError("Cannot create surface"); } texture->driverdata = surface; @@ -191,7 +191,7 @@ static int SW_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, co SDL_Point *verts = (SDL_Point *)SDL_AllocateRenderVertices(renderer, count * sizeof(SDL_Point), 0, &cmd->data.draw.first); int i; - if (verts == NULL) { + if (!verts) { return -1; } @@ -210,7 +210,7 @@ static int SW_QueueFillRects(SDL_Renderer *renderer, SDL_RenderCommand *cmd, con SDL_Rect *verts = (SDL_Rect *)SDL_AllocateRenderVertices(renderer, count * sizeof(SDL_Rect), 0, &cmd->data.draw.first); int i; - if (verts == NULL) { + if (!verts) { return -1; } @@ -231,7 +231,7 @@ static int SW_QueueCopy(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Text { SDL_Rect *verts = (SDL_Rect *)SDL_AllocateRenderVertices(renderer, 2 * sizeof(SDL_Rect), 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -268,7 +268,7 @@ static int SW_QueueCopyEx(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_Te { CopyExData *verts = (CopyExData *)SDL_AllocateRenderVertices(renderer, sizeof(CopyExData), 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -324,7 +324,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex int blitRequired = SDL_FALSE; int isOpaque = SDL_FALSE; - if (surface == NULL) { + if (!surface) { return -1; } @@ -344,7 +344,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex * The original source surface must be treated as read-only. */ src_clone = SDL_CreateSurfaceFrom(src->pixels, src->w, src->h, src->pitch, src->format->format); - if (src_clone == NULL) { + if (!src_clone) { if (SDL_MUSTLOCK(src)) { SDL_UnlockSurface(src); } @@ -387,7 +387,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex */ if (blendmode == SDL_BLENDMODE_NONE && !isOpaque) { mask = SDL_CreateSurface(final_rect->w, final_rect->h, SDL_PIXELFORMAT_ARGB8888); - if (mask == NULL) { + if (!mask) { retval = -1; } else { SDL_SetSurfaceBlendMode(mask, SDL_BLENDMODE_MOD); @@ -400,7 +400,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex if (!retval && (blitRequired || applyModulation)) { SDL_Rect scale_rect = tmp_rect; src_scaled = SDL_CreateSurface(final_rect->w, final_rect->h, SDL_PIXELFORMAT_ARGB8888); - if (src_scaled == NULL) { + if (!src_scaled) { retval = -1; } else { SDL_SetSurfaceBlendMode(src_clone, SDL_BLENDMODE_NONE); @@ -423,15 +423,15 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex src_rotated = SDLgfx_rotateSurface(src_clone, angle, (texture->scaleMode == SDL_SCALEMODE_NEAREST) ? 0 : 1, flip & SDL_FLIP_HORIZONTAL, flip & SDL_FLIP_VERTICAL, &rect_dest, cangle, sangle, center); - if (src_rotated == NULL) { + if (!src_rotated) { retval = -1; } - if (!retval && mask != NULL) { + if (!retval && mask) { /* The mask needed for the NONE blend mode gets rotated with the same parameters. */ mask_rotated = SDLgfx_rotateSurface(mask, angle, SDL_FALSE, 0, 0, &rect_dest, cangle, sangle, center); - if (mask_rotated == NULL) { + if (!mask_rotated) { retval = -1; } } @@ -487,7 +487,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex src_rotated_rgb = SDL_CreateSurfaceFrom(src_rotated->pixels, src_rotated->w, src_rotated->h, src_rotated->pitch, f); - if (src_rotated_rgb == NULL) { + if (!src_rotated_rgb) { retval = -1; } else { SDL_SetSurfaceBlendMode(src_rotated_rgb, SDL_BLENDMODE_ADD); @@ -499,7 +499,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex } SDL_DestroySurface(mask_rotated); } - if (src_rotated != NULL) { + if (src_rotated) { SDL_DestroySurface(src_rotated); } } @@ -508,10 +508,10 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex if (SDL_MUSTLOCK(src)) { SDL_UnlockSurface(src); } - if (mask != NULL) { + if (mask) { SDL_DestroySurface(mask); } - if (src_clone != NULL) { + if (src_clone) { SDL_DestroySurface(src_clone); } return retval; @@ -538,10 +538,10 @@ static int SW_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SDL_ int i; int count = indices ? num_indices : num_vertices; void *verts; - size_t sz = texture != NULL ? sizeof(GeometryCopyData) : sizeof(GeometryFillData); + size_t sz = texture ? sizeof(GeometryCopyData) : sizeof(GeometryFillData); verts = SDL_AllocateRenderVertices(renderer, count * sz, 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -641,9 +641,9 @@ static void SetDrawState(SDL_Surface *surface, SW_DrawStateCache *drawstate) if (drawstate->surface_cliprect_dirty) { const SDL_Rect *viewport = drawstate->viewport; const SDL_Rect *cliprect = drawstate->cliprect; - SDL_assert_release(viewport != NULL); /* the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT */ + SDL_assert_release(viewport); /* the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT */ - if (cliprect != NULL) { + if (cliprect) { SDL_Rect clip_rect; clip_rect.x = cliprect->x + viewport->x; clip_rect.y = cliprect->y + viewport->y; @@ -663,7 +663,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo SDL_Surface *surface = SW_ActivateRenderer(renderer); SW_DrawStateCache drawstate; - if (surface == NULL) { + if (!surface) { return -1; } @@ -717,7 +717,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo SetDrawState(surface, &drawstate); /* Apply viewport */ - if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { int i; for (i = 0; i < count; i++) { verts[i].x += drawstate.viewport->x; @@ -745,7 +745,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo SetDrawState(surface, &drawstate); /* Apply viewport */ - if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { int i; for (i = 0; i < count; i++) { verts[i].x += drawstate.viewport->x; @@ -773,7 +773,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo SetDrawState(surface, &drawstate); /* Apply viewport */ - if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { int i; for (i = 0; i < count; i++) { verts[i].x += drawstate.viewport->x; @@ -802,7 +802,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo PrepTextureForCopy(cmd); /* Apply viewport */ - if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { dstrect->x += drawstate.viewport->x; dstrect->y += drawstate.viewport->y; } @@ -861,7 +861,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo PrepTextureForCopy(cmd); /* Apply viewport */ - if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { copydata->dstrect.x += drawstate.viewport->x; copydata->dstrect.y += drawstate.viewport->y; } @@ -890,7 +890,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo PrepTextureForCopy(cmd); /* Apply viewport */ - if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { SDL_Point vp; vp.x = drawstate.viewport->x; vp.y = drawstate.viewport->y; @@ -913,7 +913,7 @@ static int SW_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, vo GeometryFillData *ptr = (GeometryFillData *)verts; /* Apply viewport */ - if (drawstate.viewport != NULL && (drawstate.viewport->x || drawstate.viewport->y)) { + if (drawstate.viewport && (drawstate.viewport->x || drawstate.viewport->y)) { SDL_Point vp; vp.x = drawstate.viewport->x; vp.y = drawstate.viewport->y; @@ -948,7 +948,7 @@ static int SW_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, Uint32 src_format; void *src_pixels; - if (surface == NULL) { + if (!surface) { return -1; } @@ -975,7 +975,7 @@ static int SW_RenderPresent(SDL_Renderer *renderer) { SDL_Window *window = renderer->window; - if (window == NULL) { + if (!window) { return -1; } return SDL_UpdateWindowSurface(window); @@ -1098,19 +1098,19 @@ SDL_Renderer *SW_CreateRendererForSurface(SDL_Surface *surface) SDL_Renderer *renderer; SW_RenderData *data; - if (surface == NULL) { + if (!surface) { SDL_InvalidParamError("surface"); return NULL; } renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); return NULL; } data = (SW_RenderData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { SW_DestroyRenderer(renderer); SDL_OutOfMemory(); return NULL; @@ -1155,7 +1155,7 @@ static SDL_Renderer *SW_CreateRenderer(SDL_Window *window, Uint32 flags) /* Set the vsync hint based on our flags, if it's not already set */ hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC); - if (hint == NULL || !*hint) { + if (!hint || !*hint) { no_hint_set = SDL_TRUE; } else { no_hint_set = SDL_FALSE; @@ -1172,7 +1172,7 @@ static SDL_Renderer *SW_CreateRenderer(SDL_Window *window, Uint32 flags) SDL_SetHint(SDL_HINT_RENDER_VSYNC, ""); } - if (surface == NULL) { + if (!surface) { return NULL; } return SW_CreateRendererForSurface(surface); diff --git a/src/render/software/SDL_rotate.c b/src/render/software/SDL_rotate.c index b40330786..637653a5b 100644 --- a/src/render/software/SDL_rotate.c +++ b/src/render/software/SDL_rotate.c @@ -498,7 +498,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in double sangleinv, cangleinv; /* Sanity check */ - if (src == NULL) { + if (!src) { return NULL; } @@ -522,7 +522,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in if (is8bit) { /* Target surface is 8 bit */ rz_dst = SDL_CreateSurface(rect_dest->w, rect_dest->h + GUARD_ROWS, src->format->format); - if (rz_dst != NULL) { + if (rz_dst) { if (src->format->palette) { for (i = 0; i < src->format->palette->ncolors; i++) { rz_dst->format->palette->colors[i] = src->format->palette->colors[i]; @@ -536,7 +536,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in } /* Check target */ - if (rz_dst == NULL) { + if (!rz_dst) { return NULL; } diff --git a/src/render/software/SDL_triangle.c b/src/render/software/SDL_triangle.c index 576c8d989..619925c58 100644 --- a/src/render/software/SDL_triangle.c +++ b/src/render/software/SDL_triangle.c @@ -219,7 +219,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin SDL_Surface *tmp = NULL; - if (dst == NULL) { + if (!dst) { return -1; } @@ -271,7 +271,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin /* Use an intermediate surface */ tmp = SDL_CreateSurface(dstrect.w, dstrect.h, format); - if (tmp == NULL) { + if (!tmp) { ret = -1; goto end; } @@ -459,7 +459,7 @@ int SDL_SW_BlitTriangle( int has_modulation; - if (src == NULL || dst == NULL) { + if (!src || !dst) { return -1; } diff --git a/src/render/vitagxm/SDL_render_vita_gxm.c b/src/render/vitagxm/SDL_render_vita_gxm.c index de0fa7e18..289ab06f8 100644 --- a/src/render/vitagxm/SDL_render_vita_gxm.c +++ b/src/render/vitagxm/SDL_render_vita_gxm.c @@ -167,7 +167,7 @@ void StartDrawing(SDL_Renderer *renderer) // data->colorFragmentProgram = in->color; // data->textureFragmentProgram = in->texture; - if (renderer->target == NULL) { + if (!renderer->target) { sceGxmBeginScene( data->gxm_context, 0, @@ -215,13 +215,13 @@ SDL_Renderer *VITA_GXM_CreateRenderer(SDL_Window *window, Uint32 flags) VITA_GXM_RenderData *data; renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); return NULL; } data = (VITA_GXM_RenderData *)SDL_calloc(1, sizeof(VITA_GXM_RenderData)); - if (data == NULL) { + if (!data) { SDL_free(renderer); SDL_OutOfMemory(); return NULL; @@ -293,7 +293,7 @@ static int VITA_GXM_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->driverdata; VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *)SDL_calloc(1, sizeof(VITA_GXM_TextureData)); - if (vita_texture == NULL) { + if (!vita_texture) { return SDL_OutOfMemory(); } @@ -581,7 +581,7 @@ static int VITA_GXM_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, *pitch = vita_texture->pitch; // make sure that rendering is finished on render target textures - if (vita_texture->tex->gxm_rendertarget != NULL) { + if (vita_texture->tex->gxm_rendertarget) { sceGxmFinish(data->gxm_context); } @@ -731,7 +731,7 @@ static int VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd data, count * sizeof(texture_vertex)); - if (vertices == NULL) { + if (!vertices) { return -1; } @@ -770,7 +770,7 @@ static int VITA_GXM_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd data, count * sizeof(color_vertex)); - if (vertices == NULL) { + if (!vertices) { return -1; } @@ -1004,7 +1004,7 @@ static int VITA_GXM_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *c SDL_RenderCommand *nextcmd = cmd->next; size_t count = cmd->data.draw.count; int ret; - while (nextcmd != NULL) { + while (nextcmd) { const SDL_RenderCommandType nextcmdtype = nextcmd->command; if (nextcmdtype != thiscmdtype) { break; /* can't go any further on this draw call, different render command up next. */ @@ -1101,7 +1101,7 @@ static int VITA_GXM_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rec } temp_pixels = SDL_malloc(buflen); - if (temp_pixels == NULL) { + if (!temp_pixels) { return SDL_OutOfMemory(); } @@ -1184,15 +1184,15 @@ static void VITA_GXM_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture VITA_GXM_RenderData *data = (VITA_GXM_RenderData *)renderer->driverdata; VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *)texture->driverdata; - if (data == NULL) { + if (!data) { return; } - if (vita_texture == NULL) { + if (!vita_texture) { return; } - if (vita_texture->tex == NULL) { + if (!vita_texture->tex) { return; } diff --git a/src/render/vitagxm/SDL_render_vita_gxm_memory.c b/src/render/vitagxm/SDL_render_vita_gxm_memory.c index 0c29c76cf..159aa5624 100644 --- a/src/render/vitagxm/SDL_render_vita_gxm_memory.c +++ b/src/render/vitagxm/SDL_render_vita_gxm_memory.c @@ -66,7 +66,7 @@ void *vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size) { void *mem; - if (data->texturePool == NULL) { + if (!data->texturePool) { int poolsize; int ret; SceKernelFreeMemorySizeInfo info; @@ -88,7 +88,7 @@ void *vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size) } data->texturePool = sceClibMspaceCreate(mem, poolsize); - if (data->texturePool == NULL) { + if (!data->texturePool) { return NULL; } ret = sceGxmMapMemory(mem, poolsize, SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE); @@ -101,7 +101,7 @@ void *vita_gpu_mem_alloc(VITA_GXM_RenderData *data, unsigned int size) void vita_gpu_mem_free(VITA_GXM_RenderData *data, void *ptr) { - if (data->texturePool != NULL) { + if (data->texturePool) { sceClibMspaceFree(data->texturePool, ptr); } } @@ -109,7 +109,7 @@ void vita_gpu_mem_free(VITA_GXM_RenderData *data, void *ptr) void vita_gpu_mem_destroy(VITA_GXM_RenderData *data) { void *mem = NULL; - if (data->texturePool != NULL) { + if (data->texturePool) { sceClibMspaceDestroy(data->texturePool); data->texturePool = NULL; if (sceKernelGetMemBlockBase(data->texturePoolUID, &mem) < 0) { diff --git a/src/render/vitagxm/SDL_render_vita_gxm_tools.c b/src/render/vitagxm/SDL_render_vita_gxm_tools.c index 7a8b59f41..bb89fa2c4 100644 --- a/src/render/vitagxm/SDL_render_vita_gxm_tools.c +++ b/src/render/vitagxm/SDL_render_vita_gxm_tools.c @@ -1001,7 +1001,7 @@ gxm_texture *create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsig tex_size += (((aligned_w + 1) / 2) * ((h + 1) / 2)) * 2; } - if (texture == NULL) { + if (!texture) { return NULL; } @@ -1015,7 +1015,7 @@ gxm_texture *create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsig tex_size); /* Try SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE in case we're out of VRAM */ - if (texture_data == NULL) { + if (!texture_data) { SDL_LogWarn(SDL_LOG_CATEGORY_RENDER, "CDRAM texture allocation failed\n"); texture_data = vita_mem_alloc( SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE, @@ -1028,7 +1028,7 @@ gxm_texture *create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsig texture->cdram = 1; } - if (texture_data == NULL) { + if (!texture_data) { SDL_free(texture); return NULL; } diff --git a/src/sensor/SDL_sensor.c b/src/sensor/SDL_sensor.c index 3eeb9e85a..88cda800c 100644 --- a/src/sensor/SDL_sensor.c +++ b/src/sensor/SDL_sensor.c @@ -329,7 +329,7 @@ SDL_Sensor *SDL_OpenSensor(SDL_SensorID instance_id) /* Create and initialize the sensor */ sensor = (SDL_Sensor *)SDL_calloc(sizeof(*sensor), 1); - if (sensor == NULL) { + if (!sensor) { SDL_OutOfMemory(); SDL_UnlockSensors(); return NULL; diff --git a/src/sensor/android/SDL_androidsensor.c b/src/sensor/android/SDL_androidsensor.c index f2556b736..db137d5e2 100644 --- a/src/sensor/android/SDL_androidsensor.c +++ b/src/sensor/android/SDL_androidsensor.c @@ -138,7 +138,7 @@ static int SDL_ANDROID_SensorInit(void) ASensorList sensors; SDL_sensor_manager = ASensorManager_getInstance(); - if (SDL_sensor_manager == NULL) { + if (!SDL_sensor_manager) { return SDL_SetError("Couldn't create sensor manager"); } @@ -146,7 +146,7 @@ static int SDL_ANDROID_SensorInit(void) sensors_count = ASensorManager_getSensorList(SDL_sensor_manager, &sensors); if (sensors_count > 0) { SDL_sensors = (SDL_AndroidSensor *)SDL_calloc(sensors_count, sizeof(*SDL_sensors)); - if (SDL_sensors == NULL) { + if (!SDL_sensors) { return SDL_OutOfMemory(); } diff --git a/src/sensor/vita/SDL_vitasensor.c b/src/sensor/vita/SDL_vitasensor.c index 50838a46f..9495a5e2d 100644 --- a/src/sensor/vita/SDL_vitasensor.c +++ b/src/sensor/vita/SDL_vitasensor.c @@ -51,7 +51,7 @@ static int SDL_VITA_SensorInit(void) SDL_sensors_count = 2; SDL_sensors = (SDL_VitaSensor *)SDL_calloc(SDL_sensors_count, sizeof(*SDL_sensors)); - if (SDL_sensors == NULL) { + if (!SDL_sensors) { return SDL_OutOfMemory(); } @@ -118,7 +118,7 @@ static int SDL_VITA_SensorOpen(SDL_Sensor *sensor, int device_index) struct sensor_hwdata *hwdata; hwdata = (struct sensor_hwdata *)SDL_calloc(1, sizeof(*hwdata)); - if (hwdata == NULL) { + if (!hwdata) { return SDL_OutOfMemory(); } sensor->hwdata = hwdata; diff --git a/src/sensor/windows/SDL_windowssensor.c b/src/sensor/windows/SDL_windowssensor.c index 11fbe3ea3..a3bad4f51 100644 --- a/src/sensor/windows/SDL_windowssensor.c +++ b/src/sensor/windows/SDL_windowssensor.c @@ -62,7 +62,7 @@ static int DisconnectSensor(ISensor *sensor); static HRESULT STDMETHODCALLTYPE ISensorManagerEventsVtbl_QueryInterface(ISensorManagerEvents *This, REFIID riid, void **ppvObject) { - if (ppvObject == NULL) { + if (!ppvObject) { return E_INVALIDARG; } @@ -102,7 +102,7 @@ static ISensorManagerEvents sensor_manager_events = { static HRESULT STDMETHODCALLTYPE ISensorEventsVtbl_QueryInterface(ISensorEvents *This, REFIID riid, void **ppvObject) { - if (ppvObject == NULL) { + if (!ppvObject) { return E_INVALIDARG; } @@ -295,13 +295,13 @@ static int ConnectSensor(ISensor *sensor) if (bstr_name != NULL) { SysFreeString(bstr_name); } - if (name == NULL) { + if (!name) { return SDL_OutOfMemory(); } SDL_LockSensors(); new_sensors = (SDL_Windows_Sensor *)SDL_realloc(SDL_sensors, (SDL_num_sensors + 1) * sizeof(SDL_Windows_Sensor)); - if (new_sensors == NULL) { + if (!new_sensors) { SDL_UnlockSensors(); SDL_free(name); return SDL_OutOfMemory(); diff --git a/src/stdlib/SDL_getenv.c b/src/stdlib/SDL_getenv.c index 7d84cb128..b6837e584 100644 --- a/src/stdlib/SDL_getenv.c +++ b/src/stdlib/SDL_getenv.c @@ -40,7 +40,7 @@ static size_t SDL_envmemlen = 0; int SDL_setenv(const char *name, const char *value, int overwrite) { /* Input validation */ - if (name == NULL || *name == '\0' || SDL_strchr(name, '=') != NULL || value == NULL) { + if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) { return -1; } @@ -50,7 +50,7 @@ int SDL_setenv(const char *name, const char *value, int overwrite) int SDL_setenv(const char *name, const char *value, int overwrite) { /* Input validation */ - if (name == NULL || *name == '\0' || SDL_strchr(name, '=') != NULL || value == NULL) { + if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) { return -1; } @@ -72,7 +72,7 @@ int SDL_setenv(const char *name, const char *value, int overwrite) char *new_variable; /* Input validation */ - if (name == NULL || *name == '\0' || SDL_strchr(name, '=') != NULL || value == NULL) { + if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) { return -1; } @@ -87,7 +87,7 @@ int SDL_setenv(const char *name, const char *value, int overwrite) /* This leaks. Sorry. Get a better OS so we don't have to do this. */ len = SDL_strlen(name) + SDL_strlen(value) + 2; new_variable = (char *)SDL_malloc(len); - if (new_variable == NULL) { + if (!new_variable) { return -1; } @@ -104,7 +104,7 @@ int SDL_setenv(const char *name, const char *value, int overwrite) char *new_variable; /* Input validation */ - if (name == NULL || *name == '\0' || SDL_strchr(name, '=') != NULL || value == NULL) { + if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) { return -1; } @@ -116,7 +116,7 @@ int SDL_setenv(const char *name, const char *value, int overwrite) /* Allocate memory for the variable */ len = SDL_strlen(name) + SDL_strlen(value) + 2; new_variable = (char *)SDL_malloc(len); - if (new_variable == NULL) { + if (!new_variable) { return -1; } @@ -169,7 +169,7 @@ char *SDL_getenv(const char *name) #endif /* Input validation */ - if (name == NULL || *name == '\0') { + if (!name || *name == '\0') { return NULL; } @@ -181,7 +181,7 @@ char *SDL_getenv(const char *name) size_t bufferlen; /* Input validation */ - if (name == NULL || *name == '\0') { + if (!name || *name == '\0') { return NULL; } @@ -192,7 +192,7 @@ char *SDL_getenv(const char *name) } if (bufferlen > SDL_envmemlen) { char *newmem = (char *)SDL_realloc(SDL_envmem, bufferlen); - if (newmem == NULL) { + if (!newmem) { return NULL; } SDL_envmem = newmem; @@ -208,14 +208,14 @@ char *SDL_getenv(const char *name) char *value; /* Input validation */ - if (name == NULL || *name == '\0') { + if (!name || *name == '\0') { return NULL; } value = (char *)0; if (SDL_env) { len = SDL_strlen(name); - for (i = 0; SDL_env[i] && value == NULL; ++i) { + for (i = 0; SDL_env[i] && !value; ++i) { if ((SDL_strncmp(SDL_env[i], name, len) == 0) && (SDL_env[i][len] == '=')) { value = &SDL_env[i][len + 1]; diff --git a/src/stdlib/SDL_iconv.c b/src/stdlib/SDL_iconv.c index 7e8f90db4..f1ea29e63 100644 --- a/src/stdlib/SDL_iconv.c +++ b/src/stdlib/SDL_iconv.c @@ -158,28 +158,28 @@ static const char *getlocale(char *buffer, size_t bufsize) char *ptr; lang = SDL_getenv("LC_ALL"); - if (lang == NULL) { + if (!lang) { lang = SDL_getenv("LC_CTYPE"); } - if (lang == NULL) { + if (!lang) { lang = SDL_getenv("LC_MESSAGES"); } - if (lang == NULL) { + if (!lang) { lang = SDL_getenv("LANG"); } - if (lang == NULL || !*lang || SDL_strcmp(lang, "C") == 0) { + if (!lang || !*lang || SDL_strcmp(lang, "C") == 0) { lang = "ASCII"; } /* We need to trim down strings like "en_US.UTF-8@blah" to "UTF-8" */ ptr = SDL_strchr(lang, '.'); - if (ptr != NULL) { + if (ptr) { lang = ptr + 1; } SDL_strlcpy(buffer, lang, bufsize); ptr = SDL_strchr(buffer, '@'); - if (ptr != NULL) { + if (ptr) { *ptr = '\0'; /* chop end of string. */ } @@ -194,10 +194,10 @@ SDL_iconv_t SDL_iconv_open(const char *tocode, const char *fromcode) char fromcode_buffer[64]; char tocode_buffer[64]; - if (fromcode == NULL || !*fromcode) { + if (!fromcode || !*fromcode) { fromcode = getlocale(fromcode_buffer, sizeof(fromcode_buffer)); } - if (tocode == NULL || !*tocode) { + if (!tocode || !*tocode) { tocode = getlocale(tocode_buffer, sizeof(tocode_buffer)); } for (i = 0; i < SDL_arraysize(encodings); ++i) { @@ -236,11 +236,11 @@ size_t SDL_iconv(SDL_iconv_t cd, Uint32 ch = 0; size_t total; - if (inbuf == NULL || !*inbuf) { + if (!inbuf || !*inbuf) { /* Reset the context */ return 0; } - if (outbuf == NULL || !*outbuf || outbytesleft == NULL || !*outbytesleft) { + if (!outbuf || !*outbuf || !outbytesleft || !*outbytesleft) { return SDL_ICONV_E2BIG; } src = *inbuf; @@ -786,10 +786,10 @@ char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inb size_t outbytesleft; size_t retCode = 0; - if (tocode == NULL || !*tocode) { + if (!tocode || !*tocode) { tocode = "UTF-8"; } - if (fromcode == NULL || !*fromcode) { + if (!fromcode || !*fromcode) { fromcode = "UTF-8"; } cd = SDL_iconv_open(tocode, fromcode); @@ -799,7 +799,7 @@ char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inb stringsize = inbytesleft; string = (char *)SDL_malloc(stringsize + sizeof(Uint32)); - if (string == NULL) { + if (!string) { SDL_iconv_close(cd); return NULL; } @@ -816,7 +816,7 @@ char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inb char *oldstring = string; stringsize *= 2; string = (char *)SDL_realloc(string, stringsize + sizeof(Uint32)); - if (string == NULL) { + if (!string) { SDL_free(oldstring); SDL_iconv_close(cd); return NULL; diff --git a/src/stdlib/SDL_string.c b/src/stdlib/SDL_string.c index 9f434a46c..cdc51ef8d 100644 --- a/src/stdlib/SDL_string.c +++ b/src/stdlib/SDL_string.c @@ -1237,7 +1237,7 @@ int SDL_vsscanf(const char *text, const char *fmt, va_list ap) { int retval = 0; - if (text == NULL || !*text) { + if (!text || !*text) { return -1; } @@ -1641,7 +1641,7 @@ static size_t SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, c size_t length = 0; size_t slen, sz; - if (string == NULL) { + if (!string) { string = "(null)"; } @@ -1701,7 +1701,7 @@ static void SDL_IntPrecisionAdjust(char *num, size_t maxlen, SDL_FormatInfo *inf { /* left-pad num with zeroes. */ size_t sz, pad, have_sign; - if (info == NULL) { + if (!info) { return; } @@ -2189,7 +2189,7 @@ int SDL_vasprintf(char **strp, const char *fmt, va_list ap) *strp = NULL; p = (char *)SDL_malloc(size); - if (p == NULL) { + if (!p) { return -1; } @@ -2215,7 +2215,7 @@ int SDL_vasprintf(char **strp, const char *fmt, va_list ap) size = retval + 1; /* Precisely what is needed */ np = (char *)SDL_realloc(p, size); - if (np == NULL) { + if (!np) { SDL_free(p); return -1; } else { diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c index 25cf72c23..6c98b9db2 100644 --- a/src/test/SDL_test_common.c +++ b/src/test/SDL_test_common.c @@ -102,7 +102,7 @@ SDLTest_CommonState *SDLTest_CommonCreateState(char **argv, Uint32 flags) } state = (SDLTest_CommonState *)SDL_calloc(1, sizeof(*state)); - if (state == NULL) { + if (!state) { SDL_OutOfMemory(); return NULL; } @@ -1090,7 +1090,7 @@ static SDL_Surface *SDLTest_LoadIcon(const char *file) /* Load the icon surface */ icon = SDL_LoadBMP(file); - if (icon == NULL) { + if (!icon) { SDL_Log("Couldn't load %s: %s\n", file, SDL_GetError()); return NULL; } @@ -1919,7 +1919,7 @@ static void SDLTest_CopyScreenShot(SDL_Renderer *renderer) }; SDLTest_ClipboardData *clipboard_data; - if (renderer == NULL) { + if (!renderer) { return; } @@ -1927,7 +1927,7 @@ static void SDLTest_CopyScreenShot(SDL_Renderer *renderer) surface = SDL_CreateSurface(viewport.w, viewport.h, SDL_PIXELFORMAT_BGR24); - if (surface == NULL) { + if (!surface) { SDL_Log("Couldn't create surface: %s\n", SDL_GetError()); return; } diff --git a/src/test/SDL_test_compare.c b/src/test/SDL_test_compare.c index 1bb5c8b50..f0244d57f 100644 --- a/src/test/SDL_test_compare.c +++ b/src/test/SDL_test_compare.c @@ -66,12 +66,12 @@ int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, char referenceFilename[FILENAME_SIZE]; /* Validate input surfaces */ - if (surface == NULL) { + if (!surface) { SDLTest_LogError("Cannot compare NULL surface"); return -1; } - if (referenceSurface == NULL) { + if (!referenceSurface) { SDLTest_LogError("Cannot compare NULL reference surface"); return -1; } diff --git a/src/test/SDL_test_crc32.c b/src/test/SDL_test_crc32.c index ef4000345..57ebef373 100644 --- a/src/test/SDL_test_crc32.c +++ b/src/test/SDL_test_crc32.c @@ -33,7 +33,7 @@ int SDLTest_Crc32Init(SDLTest_Crc32Context *crcContext) CrcUint32 c; /* Sanity check context pointer */ - if (crcContext == NULL) { + if (!crcContext) { return -1; } @@ -87,7 +87,7 @@ int SDLTest_Crc32Calc(SDLTest_Crc32Context *crcContext, CrcUint8 *inBuf, CrcUint int SDLTest_Crc32CalcStart(SDLTest_Crc32Context *crcContext, CrcUint32 *crc32) { /* Sanity check pointers */ - if (crcContext == NULL) { + if (!crcContext) { *crc32 = 0; return -1; } @@ -105,7 +105,7 @@ int SDLTest_Crc32CalcStart(SDLTest_Crc32Context *crcContext, CrcUint32 *crc32) int SDLTest_Crc32CalcEnd(SDLTest_Crc32Context *crcContext, CrcUint32 *crc32) { /* Sanity check pointers */ - if (crcContext == NULL) { + if (!crcContext) { *crc32 = 0; return -1; } @@ -125,12 +125,12 @@ int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context *crcContext, CrcUint8 *inBuf, C CrcUint8 *p; register CrcUint32 crc; - if (crcContext == NULL) { + if (!crcContext) { *crc32 = 0; return -1; } - if (inBuf == NULL) { + if (!inBuf) { return -1; } @@ -152,7 +152,7 @@ int SDLTest_Crc32CalcBuffer(SDLTest_Crc32Context *crcContext, CrcUint8 *inBuf, C int SDLTest_Crc32Done(SDLTest_Crc32Context *crcContext) { - if (crcContext == NULL) { + if (!crcContext) { return -1; } diff --git a/src/test/SDL_test_font.c b/src/test/SDL_test_font.c index 41c6adcd8..7f3391898 100644 --- a/src/test/SDL_test_font.c +++ b/src/test/SDL_test_font.c @@ -3165,14 +3165,14 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, float x, float y, Uint32 c) ci = c; /* Search for this renderer's cache */ - for (cache = SDLTest_CharTextureCacheList; cache != NULL; cache = cache->next) { + for (cache = SDLTest_CharTextureCacheList; cache; cache = cache->next) { if (cache->renderer == renderer) { break; } } /* Allocate a new cache for this renderer if needed */ - if (cache == NULL) { + if (!cache) { cache = (struct SDLTest_CharTextureCache *)SDL_calloc(1, sizeof(struct SDLTest_CharTextureCache)); cache->renderer = renderer; cache->next = SDLTest_CharTextureCacheList; @@ -3187,7 +3187,7 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, float x, float y, Uint32 c) * Redraw character into surface */ character = SDL_CreateSurface(charWidth, charHeight, SDL_PIXELFORMAT_RGBA8888); - if (character == NULL) { + if (!character) { return -1; } @@ -3357,7 +3357,7 @@ SDLTest_TextWindow *SDLTest_TextWindowCreate(float x, float y, float w, float h) { SDLTest_TextWindow *textwin = (SDLTest_TextWindow *)SDL_malloc(sizeof(*textwin)); - if (textwin == NULL) { + if (!textwin) { return NULL; } diff --git a/src/test/SDL_test_fuzzer.c b/src/test/SDL_test_fuzzer.c index 0941c5f33..37fe9a591 100644 --- a/src/test/SDL_test_fuzzer.c +++ b/src/test/SDL_test_fuzzer.c @@ -472,7 +472,7 @@ char *SDLTest_RandomAsciiStringOfSize(int size) } string = (char *)SDL_malloc((size + 1) * sizeof(char)); - if (string == NULL) { + if (!string) { return NULL; } diff --git a/src/test/SDL_test_harness.c b/src/test/SDL_test_harness.c index 7414fe8eb..e17bb1215 100644 --- a/src/test/SDL_test_harness.c +++ b/src/test/SDL_test_harness.c @@ -74,7 +74,7 @@ char *SDLTest_GenerateRunSeed(const int length) /* Allocate output buffer */ seed = (char *)SDL_malloc((length + 1) * sizeof(char)); - if (seed == NULL) { + if (!seed) { SDLTest_LogError("SDL_malloc for run seed output buffer failed."); SDL_Error(SDL_ENOMEM); return NULL; @@ -118,17 +118,17 @@ static Uint64 SDLTest_GenerateExecKey(const char *runSeed, const char *suiteName size_t entireStringLength; char *buffer; - if (runSeed == NULL || runSeed[0] == '\0') { + if (!runSeed || runSeed[0] == '\0') { SDLTest_LogError("Invalid runSeed string."); return -1; } - if (suiteName == NULL || suiteName[0] == '\0') { + if (!suiteName || suiteName[0] == '\0') { SDLTest_LogError("Invalid suiteName string."); return -1; } - if (testName == NULL || testName[0] == '\0') { + if (!testName || testName[0] == '\0') { SDLTest_LogError("Invalid testName string."); return -1; } @@ -149,7 +149,7 @@ static Uint64 SDLTest_GenerateExecKey(const char *runSeed, const char *suiteName iterationStringLength = SDL_strlen(iterationString); entireStringLength = runSeedLength + suiteNameLength + testNameLength + iterationStringLength + 1; buffer = (char *)SDL_malloc(entireStringLength); - if (buffer == NULL) { + if (!buffer) { SDLTest_LogError("Failed to allocate buffer for execKey generation."); SDL_Error(SDL_ENOMEM); return 0; @@ -181,7 +181,7 @@ static SDL_TimerID SDLTest_SetTestTimeout(int timeout, void(SDLCALL *callback)(v Uint32 timeoutInMilliseconds; SDL_TimerID timerID; - if (callback == NULL) { + if (!callback) { SDLTest_LogError("Timeout callback can't be NULL"); return -1; } @@ -239,7 +239,7 @@ static int SDLTest_RunTest(SDLTest_TestSuiteReference *testSuite, const SDLTest_ int testResult = 0; int fuzzerCount; - if (testSuite == NULL || testCase == NULL || testSuite->name == NULL || testCase->name == NULL) { + if (!testSuite || !testCase || !testSuite->name || !testCase->name) { SDLTest_LogError("Setup failure: testSuite or testCase references NULL"); return TEST_RESULT_SETUP_FAILURE; } @@ -412,9 +412,9 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user } /* Generate run see if we don't have one already */ - if (userRunSeed == NULL || userRunSeed[0] == '\0') { + if (!userRunSeed || userRunSeed[0] == '\0') { char *tmp = SDLTest_GenerateRunSeed(16); - if (tmp == NULL) { + if (!tmp) { SDLTest_LogError("Generating a random seed failed"); return 2; } @@ -455,20 +455,20 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user /* Pre-allocate an array for tracking failed tests (potentially all test cases) */ failedTests = (const SDLTest_TestCaseReference **)SDL_malloc(totalNumberOfTests * sizeof(SDLTest_TestCaseReference *)); - if (failedTests == NULL) { + if (!failedTests) { SDLTest_LogError("Unable to allocate cache for failed tests"); SDL_Error(SDL_ENOMEM); return -1; } /* Initialize filtering */ - if (filter != NULL && filter[0] != '\0') { + if (filter && filter[0] != '\0') { /* Loop over all suites to check if we have a filter match */ suiteCounter = 0; while (testSuites[suiteCounter] && suiteFilter == 0) { testSuite = testSuites[suiteCounter]; suiteCounter++; - if (testSuite->name != NULL && SDL_strcasecmp(filter, testSuite->name) == 0) { + if (testSuite->name && SDL_strcasecmp(filter, testSuite->name) == 0) { /* Matched a suite name */ suiteFilter = 1; suiteFilterName = testSuite->name; @@ -481,7 +481,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user while (testSuite->testCases[testCounter] && testFilter == 0) { testCase = testSuite->testCases[testCounter]; testCounter++; - if (testCase->name != NULL && SDL_strcasecmp(filter, testCase->name) == 0) { + if (testCase->name && SDL_strcasecmp(filter, testCase->name) == 0) { /* Matched a test name */ suiteFilter = 1; suiteFilterName = testSuite->name; @@ -497,7 +497,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user SDLTest_LogError("Filter '%s' did not match any test suite/case.", filter); for (suiteCounter = 0; testSuites[suiteCounter]; ++suiteCounter) { testSuite = testSuites[suiteCounter]; - if (testSuite->name != NULL) { + if (testSuite->name) { SDLTest_Log("Test suite: %s", testSuite->name); } @@ -521,7 +521,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user suiteCounter++; /* Filter suite if flag set and we have a name */ - if (suiteFilter == 1 && suiteFilterName != NULL && testSuite->name != NULL && + if (suiteFilter == 1 && suiteFilterName && testSuite->name && SDL_strcasecmp(suiteFilterName, testSuite->name) != 0) { /* Skip suite */ SDLTest_Log("===== Test Suite %i: '%s' " COLOR_BLUE "skipped" COLOR_END "\n", @@ -550,7 +550,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user testCounter++; /* Filter tests if flag set and we have a name */ - if (testFilter == 1 && testFilterName != NULL && testCase->name != NULL && + if (testFilter == 1 && testFilterName && testCase->name && SDL_strcasecmp(testFilterName, testCase->name) != 0) { /* Skip test */ SDLTest_Log("===== Test Case %i.%i: '%s' " COLOR_BLUE "skipped" COLOR_END "\n", @@ -572,7 +572,7 @@ int SDLTest_RunSuites(SDLTest_TestSuiteReference *testSuites[], const char *user suiteCounter, testCounter, currentTestName); - if (testCase->description != NULL && testCase->description[0] != '\0') { + if (testCase->description && testCase->description[0] != '\0') { SDLTest_Log("Test Description: '%s'", (testCase->description) ? testCase->description : SDLTEST_INVALID_NAME_FORMAT); } diff --git a/src/test/SDL_test_md5.c b/src/test/SDL_test_md5.c index 9f7448e44..ce89e4dda 100644 --- a/src/test/SDL_test_md5.c +++ b/src/test/SDL_test_md5.c @@ -110,7 +110,7 @@ static unsigned char MD5PADDING[64] = { void SDLTest_Md5Init(SDLTest_Md5Context *mdContext) { - if (mdContext == NULL) { + if (!mdContext) { return; } @@ -138,10 +138,10 @@ void SDLTest_Md5Update(SDLTest_Md5Context *mdContext, unsigned char *inBuf, int mdi; unsigned int i, ii; - if (mdContext == NULL) { + if (!mdContext) { return; } - if (inBuf == NULL || inLen < 1) { + if (!inBuf || inLen < 1) { return; } @@ -190,7 +190,7 @@ void SDLTest_Md5Final(SDLTest_Md5Context *mdContext) unsigned int i, ii; unsigned int padLen; - if (mdContext == NULL) { + if (!mdContext) { return; } diff --git a/src/test/SDL_test_memory.c b/src/test/SDL_test_memory.c index 2ca790fb3..5ec92cfc5 100644 --- a/src/test/SDL_test_memory.c +++ b/src/test/SDL_test_memory.c @@ -118,7 +118,7 @@ static void SDL_TrackAllocation(void *mem, size_t size) return; } entry = (SDL_tracked_allocation *)SDL_malloc_orig(sizeof(*entry)); - if (entry == NULL) { + if (!entry) { return; } entry->mem = mem; @@ -272,7 +272,7 @@ static void *SDLCALL SDLTest_TrackedRealloc(void *ptr, size_t size) static void SDLCALL SDLTest_TrackedFree(void *ptr) { - if (ptr == NULL) { + if (!ptr) { return; } diff --git a/src/test/SDL_test_random.c b/src/test/SDL_test_random.c index c5633cec6..f004ac7a7 100644 --- a/src/test/SDL_test_random.c +++ b/src/test/SDL_test_random.c @@ -36,7 +36,7 @@ void SDLTest_RandomInit(SDLTest_RandomContext *rndContext, unsigned int xi, unsigned int ci) { - if (rndContext == NULL) { + if (!rndContext) { return; } @@ -64,7 +64,7 @@ void SDLTest_RandomInitTime(SDLTest_RandomContext *rndContext) { int a, b; - if (rndContext == NULL) { + if (!rndContext) { return; } @@ -81,7 +81,7 @@ unsigned int SDLTest_Random(SDLTest_RandomContext *rndContext) { unsigned int xh, xl; - if (rndContext == NULL) { + if (!rndContext) { return -1; } diff --git a/src/thread/SDL_thread.c b/src/thread/SDL_thread.c index 7328316e6..c03fc4130 100644 --- a/src/thread/SDL_thread.c +++ b/src/thread/SDL_thread.c @@ -37,7 +37,7 @@ void *SDL_GetTLS(SDL_TLSID id) SDL_TLSData *storage; storage = SDL_SYS_GetTLSData(); - if (storage == NULL || id == 0 || id > storage->limit) { + if (!storage || id == 0 || id > storage->limit) { return NULL; } return storage->array[id - 1].data; @@ -52,13 +52,13 @@ int SDL_SetTLS(SDL_TLSID id, const void *value, void(SDLCALL *destructor)(void * } storage = SDL_SYS_GetTLSData(); - if (storage == NULL || (id > storage->limit)) { + if (!storage || (id > storage->limit)) { unsigned int i, oldlimit, newlimit; oldlimit = storage ? storage->limit : 0; newlimit = (id + TLS_ALLOC_CHUNKSIZE); storage = (SDL_TLSData *)SDL_realloc(storage, sizeof(*storage) + (newlimit - 1) * sizeof(storage->array[0])); - if (storage == NULL) { + if (!storage) { return SDL_OutOfMemory(); } storage->limit = newlimit; @@ -118,14 +118,14 @@ SDL_TLSData *SDL_Generic_GetTLSData(void) SDL_TLSData *storage = NULL; #ifndef SDL_THREADS_DISABLED - if (SDL_generic_TLS_mutex == NULL) { + if (!SDL_generic_TLS_mutex) { static SDL_SpinLock tls_lock; SDL_AtomicLock(&tls_lock); - if (SDL_generic_TLS_mutex == NULL) { + if (!SDL_generic_TLS_mutex) { SDL_Mutex *mutex = SDL_CreateMutex(); SDL_MemoryBarrierRelease(); SDL_generic_TLS_mutex = mutex; - if (SDL_generic_TLS_mutex == NULL) { + if (!SDL_generic_TLS_mutex) { SDL_AtomicUnlock(&tls_lock); return NULL; } @@ -159,10 +159,10 @@ int SDL_Generic_SetTLSData(SDL_TLSData *data) prev = NULL; for (entry = SDL_generic_TLS; entry; entry = entry->next) { if (entry->thread == thread) { - if (data != NULL) { + if (data) { entry->storage = data; } else { - if (prev != NULL) { + if (prev) { prev->next = entry->next; } else { SDL_generic_TLS = entry->next; @@ -173,7 +173,7 @@ int SDL_Generic_SetTLSData(SDL_TLSData *data) } prev = entry; } - if (entry == NULL) { + if (!entry) { entry = (SDL_TLSEntry *)SDL_malloc(sizeof(*entry)); if (entry) { entry->thread = thread; @@ -184,7 +184,7 @@ int SDL_Generic_SetTLSData(SDL_TLSData *data) } SDL_UnlockMutex(SDL_generic_TLS_mutex); - if (entry == NULL) { + if (!entry) { return SDL_OutOfMemory(); } return 0; @@ -249,7 +249,7 @@ SDL_error *SDL_GetErrBuf(void) if (errbuf == ALLOCATION_IN_PROGRESS) { return SDL_GetStaticErrBuf(); } - if (errbuf == NULL) { + if (!errbuf) { /* Get the original memory functions for this allocation because the lifetime * of the error buffer may span calls to SDL_SetMemoryFunctions() by the app */ @@ -260,7 +260,7 @@ SDL_error *SDL_GetErrBuf(void) /* Mark that we're in the middle of allocating our buffer */ SDL_SetTLS(tls_errbuf, ALLOCATION_IN_PROGRESS, NULL); errbuf = (SDL_error *)realloc_func(NULL, sizeof(*errbuf)); - if (errbuf == NULL) { + if (!errbuf) { SDL_SetTLS(tls_errbuf, NULL, NULL); return SDL_GetStaticErrBuf(); } @@ -328,7 +328,7 @@ SDL_Thread *SDL_CreateThreadWithStackSize(int(SDLCALL *fn)(void *), /* Allocate memory for the thread info structure */ thread = (SDL_Thread *)SDL_calloc(1, sizeof(*thread)); - if (thread == NULL) { + if (!thread) { SDL_OutOfMemory(); return NULL; } @@ -336,9 +336,9 @@ SDL_Thread *SDL_CreateThreadWithStackSize(int(SDLCALL *fn)(void *), SDL_AtomicSet(&thread->state, SDL_THREAD_STATE_ALIVE); /* Set up the arguments for the thread */ - if (name != NULL) { + if (name) { thread->name = SDL_strdup(name); - if (thread->name == NULL) { + if (!thread->name) { SDL_OutOfMemory(); SDL_free(thread); return NULL; @@ -381,7 +381,7 @@ DECLSPEC SDL_Thread *SDLCALL SDL_CreateThread(int(SDLCALL *fn)(void *), size_t stacksize = 0; /* If the SDL_HINT_THREAD_STACK_SIZE exists, use it */ - if (stackhint != NULL) { + if (stackhint) { char *endp = NULL; const Sint64 hintval = SDL_strtoll(stackhint, &endp, 10); if ((*stackhint != '\0') && (*endp == '\0')) { /* a valid number? */ @@ -450,7 +450,7 @@ void SDL_WaitThread(SDL_Thread *thread, int *status) void SDL_DetachThread(SDL_Thread *thread) { - if (thread == NULL) { + if (!thread) { return; } diff --git a/src/thread/generic/SDL_syscond.c b/src/thread/generic/SDL_syscond.c index 6535008a7..e6b1a5d6b 100644 --- a/src/thread/generic/SDL_syscond.c +++ b/src/thread/generic/SDL_syscond.c @@ -92,7 +92,7 @@ void SDL_DestroyCondition_generic(SDL_Condition *_cond) int SDL_SignalCondition_generic(SDL_Condition *_cond) { SDL_cond_generic *cond = (SDL_cond_generic *)_cond; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -116,7 +116,7 @@ int SDL_SignalCondition_generic(SDL_Condition *_cond) int SDL_BroadcastCondition_generic(SDL_Condition *_cond) { SDL_cond_generic *cond = (SDL_cond_generic *)_cond; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -172,7 +172,7 @@ int SDL_WaitConditionTimeoutNS_generic(SDL_Condition *_cond, SDL_Mutex *mutex, S SDL_cond_generic *cond = (SDL_cond_generic *)_cond; int retval; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } diff --git a/src/thread/generic/SDL_sysmutex.c b/src/thread/generic/SDL_sysmutex.c index 579d028ee..95f4cecd1 100644 --- a/src/thread/generic/SDL_sysmutex.c +++ b/src/thread/generic/SDL_sysmutex.c @@ -87,7 +87,7 @@ int SDL_TryLockMutex(SDL_Mutex *mutex) { int retval = 0; #ifndef SDL_THREADS_DISABLED - if (mutex != NULL) { + if (mutex) { SDL_threadID this_thread = SDL_ThreadID(); if (mutex->owner == this_thread) { ++mutex->recursive; diff --git a/src/thread/generic/SDL_syssem.c b/src/thread/generic/SDL_syssem.c index 3dae50be4..bf945695f 100644 --- a/src/thread/generic/SDL_syssem.c +++ b/src/thread/generic/SDL_syssem.c @@ -66,7 +66,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) SDL_Semaphore *sem; sem = (SDL_Semaphore *)SDL_malloc(sizeof(*sem)); - if (sem == NULL) { + if (!sem) { SDL_OutOfMemory(); return NULL; } @@ -108,7 +108,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS) { int retval; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -156,7 +156,7 @@ Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem) int SDL_PostSemaphore(SDL_Semaphore *sem) { - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } diff --git a/src/thread/n3ds/SDL_syscond.c b/src/thread/n3ds/SDL_syscond.c index e170ab55e..5595010fb 100644 --- a/src/thread/n3ds/SDL_syscond.c +++ b/src/thread/n3ds/SDL_syscond.c @@ -54,7 +54,7 @@ void SDL_DestroyCondition(SDL_Condition *cond) /* Restart one of the threads that are waiting on the condition variable */ int SDL_SignalCondition(SDL_Condition *cond) { - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -65,7 +65,7 @@ int SDL_SignalCondition(SDL_Condition *cond) /* Restart all threads that are waiting on the condition variable */ int SDL_BroadcastCondition(SDL_Condition *cond) { - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -98,10 +98,10 @@ int SDL_WaitConditionTimeoutNS(SDL_Condition *cond, SDL_Mutex *mutex, Sint64 tim { Result res; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } - if (mutex == NULL) { + if (!mutex) { return SDL_InvalidParamError("mutex"); } diff --git a/src/thread/n3ds/SDL_sysmutex.c b/src/thread/n3ds/SDL_sysmutex.c index 47e848582..57d189db5 100644 --- a/src/thread/n3ds/SDL_sysmutex.c +++ b/src/thread/n3ds/SDL_sysmutex.c @@ -53,7 +53,7 @@ void SDL_LockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS // clang doe int SDL_TryLockMutex(SDL_Mutex *mutex) { - return (mutex == NULL) ? 0 : RecursiveLock_TryLock(&mutex->lock); + return (!mutex) ? 0 : RecursiveLock_TryLock(&mutex->lock); } void SDL_UnlockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS // clang doesn't know about NULL mutexes diff --git a/src/thread/n3ds/SDL_syssem.c b/src/thread/n3ds/SDL_syssem.c index 261609b27..f41d69c34 100644 --- a/src/thread/n3ds/SDL_syssem.c +++ b/src/thread/n3ds/SDL_syssem.c @@ -43,7 +43,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) } sem = (SDL_Semaphore *)SDL_malloc(sizeof(*sem)); - if (sem == NULL) { + if (!sem) { SDL_OutOfMemory(); return NULL; } @@ -63,7 +63,7 @@ void SDL_DestroySemaphore(SDL_Semaphore *sem) int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS) { - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -99,7 +99,7 @@ int WaitOnSemaphoreFor(SDL_Semaphore *sem, Sint64 timeout) Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem) { - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -108,7 +108,7 @@ Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem) int SDL_PostSemaphore(SDL_Semaphore *sem) { - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } LightSemaphore_Release(&sem->semaphore, 1); diff --git a/src/thread/n3ds/SDL_systhread.c b/src/thread/n3ds/SDL_systhread.c index 348c03723..17a50bb24 100644 --- a/src/thread/n3ds/SDL_systhread.c +++ b/src/thread/n3ds/SDL_systhread.c @@ -66,7 +66,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread) cpu, false); - if (thread->handle == NULL) { + if (!thread->handle) { return SDL_SetError("Couldn't create thread"); } diff --git a/src/thread/ngage/SDL_syssem.cpp b/src/thread/ngage/SDL_syssem.cpp index e7306e8a1..8c458e947 100644 --- a/src/thread/ngage/SDL_syssem.cpp +++ b/src/thread/ngage/SDL_syssem.cpp @@ -90,7 +90,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) void SDL_DestroySemaphore(SDL_Semaphore *sem) { - if (sem != NULL) { + if (sem) { RSemaphore sema; sema.SetHandle(sem->handle); sema.Signal(sema.Count()); @@ -102,7 +102,7 @@ void SDL_DestroySemaphore(SDL_Semaphore *sem) int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS) { - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -140,7 +140,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS) Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem) { - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -149,7 +149,7 @@ Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem) int SDL_PostSemaphore(SDL_Semaphore *sem) { - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } sem->count++; diff --git a/src/thread/ps2/SDL_syssem.c b/src/thread/ps2/SDL_syssem.c index 587bf4941..04e0b2d83 100644 --- a/src/thread/ps2/SDL_syssem.c +++ b/src/thread/ps2/SDL_syssem.c @@ -47,7 +47,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) ee_sema_t sema; sem = (SDL_Semaphore *)SDL_malloc(sizeof(*sem)); - if (sem != NULL) { + if (sem) { /* TODO: Figure out the limit on the maximum value. */ sema.init_count = initial_value; sema.max_count = 255; @@ -69,7 +69,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) /* Free the semaphore */ void SDL_DestroySemaphore(SDL_Semaphore *sem) { - if (sem != NULL) { + if (sem) { if (sem->semid > 0) { DeleteSema(sem->semid); sem->semid = 0; @@ -85,7 +85,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS) struct timer_alarm_t alarm; InitializeTimerAlarm(&alarm); - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -114,7 +114,7 @@ Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem) { ee_sema_t info; - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -130,7 +130,7 @@ int SDL_PostSemaphore(SDL_Semaphore *sem) { int res; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } diff --git a/src/thread/psp/SDL_syscond.c b/src/thread/psp/SDL_syscond.c index a5389444c..0dc6f177d 100644 --- a/src/thread/psp/SDL_syscond.c +++ b/src/thread/psp/SDL_syscond.c @@ -78,7 +78,7 @@ void SDL_DestroyCondition(SDL_Condition *cond) /* Restart one of the threads that are waiting on the condition variable */ int SDL_SignalCondition(SDL_Condition *cond) { - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -101,7 +101,7 @@ int SDL_SignalCondition(SDL_Condition *cond) /* Restart all threads that are waiting on the condition variable */ int SDL_BroadcastCondition(SDL_Condition *cond) { - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -156,7 +156,7 @@ int SDL_WaitConditionTimeoutNS(SDL_Condition *cond, SDL_Mutex *mutex, Sint64 tim { int retval; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } diff --git a/src/thread/psp/SDL_sysmutex.c b/src/thread/psp/SDL_sysmutex.c index f6701bb12..82e63e6fe 100644 --- a/src/thread/psp/SDL_sysmutex.c +++ b/src/thread/psp/SDL_sysmutex.c @@ -80,7 +80,7 @@ int SDL_TryLockMutex(SDL_Mutex *mutex) { int retval = 0; #ifndef SDL_THREADS_DISABLED - if (mutex != NULL) { + if (mutex) { const SceInt32 res = sceKernelTryLockLwMutex(&mutex->lock, 1); if (res == SCE_KERNEL_ERROR_OK) { retval = 0; diff --git a/src/thread/psp/SDL_syssem.c b/src/thread/psp/SDL_syssem.c index f54e53ccf..c6b1a3c57 100644 --- a/src/thread/psp/SDL_syssem.c +++ b/src/thread/psp/SDL_syssem.c @@ -41,7 +41,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) SDL_Semaphore *sem; sem = (SDL_Semaphore *)SDL_malloc(sizeof(*sem)); - if (sem != NULL) { + if (sem) { /* TODO: Figure out the limit on the maximum value. */ sem->semid = sceKernelCreateSema("SDL sema", 0, initial_value, 255, NULL); if (sem->semid < 0) { @@ -59,7 +59,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) /* Free the semaphore */ void SDL_DestroySemaphore(SDL_Semaphore *sem) { - if (sem != NULL) { + if (sem) { if (sem->semid > 0) { sceKernelDeleteSema(sem->semid); sem->semid = 0; @@ -79,7 +79,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS) SceUInt *pTimeout; int res; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -114,7 +114,7 @@ Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem) { SceKernelSemaInfo info; - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -130,7 +130,7 @@ int SDL_PostSemaphore(SDL_Semaphore *sem) { int res; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } diff --git a/src/thread/pthread/SDL_syscond.c b/src/thread/pthread/SDL_syscond.c index f41602494..026f0a1a1 100644 --- a/src/thread/pthread/SDL_syscond.c +++ b/src/thread/pthread/SDL_syscond.c @@ -63,7 +63,7 @@ int SDL_SignalCondition(SDL_Condition *cond) { int retval; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -79,7 +79,7 @@ int SDL_BroadcastCondition(SDL_Condition *cond) { int retval; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -98,7 +98,7 @@ int SDL_WaitConditionTimeoutNS(SDL_Condition *cond, SDL_Mutex *mutex, Sint64 tim #endif struct timespec abstime; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } diff --git a/src/thread/pthread/SDL_sysmutex.c b/src/thread/pthread/SDL_sysmutex.c index 4b921e1a4..30f796cd7 100644 --- a/src/thread/pthread/SDL_sysmutex.c +++ b/src/thread/pthread/SDL_sysmutex.c @@ -88,7 +88,7 @@ int SDL_TryLockMutex(SDL_Mutex *mutex) { int retval = 0; - if (mutex != NULL) { + if (mutex) { #ifdef FAKE_RECURSIVE_MUTEX pthread_t this_thread = pthread_self(); if (mutex->owner == this_thread) { diff --git a/src/thread/pthread/SDL_syssem.c b/src/thread/pthread/SDL_syssem.c index b1b38fa53..d2ecb57d9 100644 --- a/src/thread/pthread/SDL_syssem.c +++ b/src/thread/pthread/SDL_syssem.c @@ -42,7 +42,7 @@ struct SDL_Semaphore SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) { SDL_Semaphore *sem = (SDL_Semaphore *)SDL_malloc(sizeof(SDL_Semaphore)); - if (sem != NULL) { + if (sem) { if (sem_init(&sem->sem, 0, initial_value) < 0) { SDL_SetError("sem_init() failed"); SDL_free(sem); @@ -56,7 +56,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) void SDL_DestroySemaphore(SDL_Semaphore *sem) { - if (sem != NULL) { + if (sem) { sem_destroy(&sem->sem); SDL_free(sem); } @@ -74,7 +74,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS) Uint64 end; #endif - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -152,7 +152,7 @@ Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem) { int ret = 0; - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -168,7 +168,7 @@ int SDL_PostSemaphore(SDL_Semaphore *sem) { int retval; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } diff --git a/src/thread/pthread/SDL_systhread.c b/src/thread/pthread/SDL_systhread.c index b4b6193a5..c1e7d0624 100644 --- a/src/thread/pthread/SDL_systhread.c +++ b/src/thread/pthread/SDL_systhread.c @@ -118,10 +118,10 @@ void SDL_SYS_SetupThread(const char *name) int i; sigset_t mask; - if (name != NULL) { + if (name) { #if (defined(__MACOS__) || defined(__IOS__) || defined(__LINUX__)) && defined(HAVE_DLOPEN) SDL_assert(checked_setname); - if (ppthread_setname_np != NULL) { + if (ppthread_setname_np) { #if defined(__MACOS__) || defined(__IOS__) ppthread_setname_np(name); #elif defined(__LINUX__) diff --git a/src/thread/stdcpp/SDL_syscond.cpp b/src/thread/stdcpp/SDL_syscond.cpp index 90c8a88a4..72536d601 100644 --- a/src/thread/stdcpp/SDL_syscond.cpp +++ b/src/thread/stdcpp/SDL_syscond.cpp @@ -56,7 +56,7 @@ SDL_CreateCondition(void) extern "C" void SDL_DestroyCondition(SDL_Condition *cond) { - if (cond != NULL) { + if (cond) { delete cond; } } @@ -65,7 +65,7 @@ SDL_DestroyCondition(SDL_Condition *cond) extern "C" int SDL_SignalCondition(SDL_Condition *cond) { - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -77,7 +77,7 @@ SDL_SignalCondition(SDL_Condition *cond) extern "C" int SDL_BroadcastCondition(SDL_Condition *cond) { - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } diff --git a/src/thread/stdcpp/SDL_sysmutex.cpp b/src/thread/stdcpp/SDL_sysmutex.cpp index 3619c4139..1d33701b2 100644 --- a/src/thread/stdcpp/SDL_sysmutex.cpp +++ b/src/thread/stdcpp/SDL_sysmutex.cpp @@ -45,7 +45,7 @@ extern "C" SDL_Mutex * SDL_CreateMutex(void) extern "C" void SDL_DestroyMutex(SDL_Mutex *mutex) { - if (mutex != NULL) { + if (mutex) { delete mutex; } } @@ -64,7 +64,7 @@ extern "C" void SDL_LockMutex(SDL_Mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS / extern "C" int SDL_TryLockMutex(SDL_Mutex *mutex) { - return ((mutex == NULL) || mutex->cpp_mutex.try_lock()) ? 0 : SDL_MUTEX_TIMEDOUT; + return ((!mutex) || mutex->cpp_mutex.try_lock()) ? 0 : SDL_MUTEX_TIMEDOUT; } /* Unlock the mutex */ diff --git a/src/thread/stdcpp/SDL_sysrwlock.cpp b/src/thread/stdcpp/SDL_sysrwlock.cpp index e85f879a9..7e6742c4e 100644 --- a/src/thread/stdcpp/SDL_sysrwlock.cpp +++ b/src/thread/stdcpp/SDL_sysrwlock.cpp @@ -46,7 +46,7 @@ extern "C" SDL_RWLock *SDL_CreateRWLock(void) extern "C" void SDL_DestroyRWLock(SDL_RWLock *rwlock) { - if (rwlock != NULL) { + if (rwlock) { delete rwlock; } } diff --git a/src/thread/vita/SDL_syscond.c b/src/thread/vita/SDL_syscond.c index dd32da5d0..2218f755e 100644 --- a/src/thread/vita/SDL_syscond.c +++ b/src/thread/vita/SDL_syscond.c @@ -43,7 +43,7 @@ SDL_Condition *SDL_CreateCondition(void) SDL_Condition *cond; cond = (SDL_Condition *)SDL_malloc(sizeof(SDL_Condition)); - if (cond != NULL) { + if (cond) { cond->lock = SDL_CreateMutex(); cond->wait_sem = SDL_CreateSemaphore(0); cond->wait_done = SDL_CreateSemaphore(0); @@ -61,7 +61,7 @@ SDL_Condition *SDL_CreateCondition(void) /* Destroy a condition variable */ void SDL_DestroyCondition(SDL_Condition *cond) { - if (cond != NULL) { + if (cond) { if (cond->wait_sem) { SDL_DestroySemaphore(cond->wait_sem); } @@ -78,7 +78,7 @@ void SDL_DestroyCondition(SDL_Condition *cond) /* Restart one of the threads that are waiting on the condition variable */ int SDL_SignalCondition(SDL_Condition *cond) { - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -101,7 +101,7 @@ int SDL_SignalCondition(SDL_Condition *cond) /* Restart all threads that are waiting on the condition variable */ int SDL_BroadcastCondition(SDL_Condition *cond) { - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -156,7 +156,7 @@ int SDL_WaitConditionTimeoutNS(SDL_Condition *cond, SDL_Mutex *mutex, Sint64 tim { int retval; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } diff --git a/src/thread/vita/SDL_sysmutex.c b/src/thread/vita/SDL_sysmutex.c index 1bc27780e..e63e77fa5 100644 --- a/src/thread/vita/SDL_sysmutex.c +++ b/src/thread/vita/SDL_sysmutex.c @@ -35,7 +35,7 @@ struct SDL_Mutex SDL_Mutex *SDL_CreateMutex(void) { SDL_Mutex *mutex = (SDL_Mutex *)SDL_malloc(sizeof(*mutex)); - if (mutex != NULL) { + if (mutex) { const SceInt32 res = sceKernelCreateLwMutex( &mutex->lock, "SDL mutex", @@ -56,7 +56,7 @@ SDL_Mutex *SDL_CreateMutex(void) void SDL_DestroyMutex(SDL_Mutex *mutex) { - if (mutex != NULL) { + if (mutex) { sceKernelDeleteLwMutex(&mutex->lock); SDL_free(mutex); } @@ -79,7 +79,7 @@ int SDL_TryLockMutex(SDL_Mutex *mutex) #else SceInt32 res = 0; - if (mutex == NULL) { + if (!mutex) { return 0; } diff --git a/src/thread/vita/SDL_syssem.c b/src/thread/vita/SDL_syssem.c index 105b18d24..f43cbaba5 100644 --- a/src/thread/vita/SDL_syssem.c +++ b/src/thread/vita/SDL_syssem.c @@ -42,7 +42,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) SDL_Semaphore *sem; sem = (SDL_Semaphore *)SDL_malloc(sizeof(*sem)); - if (sem != NULL) { + if (sem) { /* TODO: Figure out the limit on the maximum value. */ sem->semid = sceKernelCreateSema("SDL sema", 0, initial_value, 255, NULL); if (sem->semid < 0) { @@ -60,7 +60,7 @@ SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) /* Free the semaphore */ void SDL_DestroySemaphore(SDL_Semaphore *sem) { - if (sem != NULL) { + if (sem) { if (sem->semid > 0) { sceKernelDeleteSema(sem->semid); sem->semid = 0; @@ -80,7 +80,7 @@ int SDL_WaitSemaphoreTimeoutNS(SDL_Semaphore *sem, Sint64 timeoutNS) SceUInt *pTimeout; int res; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -116,7 +116,7 @@ Uint32 SDL_GetSemaphoreValue(SDL_Semaphore *sem) SceKernelSemaInfo info; info.size = sizeof(info); - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -132,7 +132,7 @@ int SDL_PostSemaphore(SDL_Semaphore *sem) { int res; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } diff --git a/src/thread/windows/SDL_syscond_cv.c b/src/thread/windows/SDL_syscond_cv.c index b0142d8b9..91a5e23bd 100644 --- a/src/thread/windows/SDL_syscond_cv.c +++ b/src/thread/windows/SDL_syscond_cv.c @@ -84,7 +84,7 @@ static SDL_Condition *SDL_CreateCondition_cv(void) /* Relies on CONDITION_VARIABLE_INIT == 0. */ cond = (SDL_cond_cv *)SDL_calloc(1, sizeof(*cond)); - if (cond == NULL) { + if (!cond) { SDL_OutOfMemory(); } @@ -93,7 +93,7 @@ static SDL_Condition *SDL_CreateCondition_cv(void) static void SDL_DestroyCondition_cv(SDL_Condition *cond) { - if (cond != NULL) { + if (cond) { /* There are no kernel allocated resources */ SDL_free(cond); } @@ -102,7 +102,7 @@ static void SDL_DestroyCondition_cv(SDL_Condition *cond) static int SDL_SignalCondition_cv(SDL_Condition *_cond) { SDL_cond_cv *cond = (SDL_cond_cv *)_cond; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -114,7 +114,7 @@ static int SDL_SignalCondition_cv(SDL_Condition *_cond) static int SDL_BroadcastCondition_cv(SDL_Condition *_cond) { SDL_cond_cv *cond = (SDL_cond_cv *)_cond; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } @@ -129,10 +129,10 @@ static int SDL_WaitConditionTimeoutNS_cv(SDL_Condition *_cond, SDL_Mutex *_mutex DWORD timeout; int ret; - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } - if (_mutex == NULL) { + if (!_mutex) { return SDL_InvalidParamError("mutex"); } @@ -208,13 +208,13 @@ static const SDL_cond_impl_t SDL_cond_impl_generic = { SDL_Condition *SDL_CreateCondition(void) { - if (SDL_cond_impl_active.Create == NULL) { + if (!SDL_cond_impl_active.Create) { const SDL_cond_impl_t *impl = NULL; if (SDL_mutex_impl_active.Type == SDL_MUTEX_INVALID) { /* The mutex implementation isn't decided yet, trigger it */ SDL_Mutex *mutex = SDL_CreateMutex(); - if (mutex == NULL) { + if (!mutex) { return NULL; } SDL_DestroyMutex(mutex); diff --git a/src/thread/windows/SDL_sysmutex.c b/src/thread/windows/SDL_sysmutex.c index d70aa1be1..1d62e7e8d 100644 --- a/src/thread/windows/SDL_sysmutex.c +++ b/src/thread/windows/SDL_sysmutex.c @@ -61,7 +61,7 @@ static SDL_Mutex *SDL_CreateMutex_srw(void) SDL_mutex_srw *mutex; mutex = (SDL_mutex_srw *)SDL_calloc(1, sizeof(*mutex)); - if (mutex == NULL) { + if (!mutex) { SDL_OutOfMemory(); } @@ -145,7 +145,7 @@ static const SDL_mutex_impl_t SDL_mutex_impl_srw = { static SDL_Mutex *SDL_CreateMutex_cs(void) { SDL_mutex_cs *mutex = (SDL_mutex_cs *)SDL_malloc(sizeof(*mutex)); - if (mutex != NULL) { + if (mutex) { // Initialize // On SMP systems, a non-zero spin count generally helps performance #ifdef __WINRT__ @@ -199,7 +199,7 @@ static const SDL_mutex_impl_t SDL_mutex_impl_cs = { SDL_Mutex *SDL_CreateMutex(void) { - if (SDL_mutex_impl_active.Create == NULL) { + if (!SDL_mutex_impl_active.Create) { // Default to fallback implementation const SDL_mutex_impl_t *impl = &SDL_mutex_impl_cs; @@ -239,7 +239,7 @@ void SDL_DestroyMutex(SDL_Mutex *mutex) void SDL_LockMutex(SDL_Mutex *mutex) { - if (mutex != NULL) { + if (mutex) { SDL_mutex_impl_active.Lock(mutex); } } @@ -251,7 +251,7 @@ int SDL_TryLockMutex(SDL_Mutex *mutex) void SDL_UnlockMutex(SDL_Mutex *mutex) { - if (mutex != NULL) { + if (mutex) { SDL_mutex_impl_active.Unlock(mutex); } } diff --git a/src/thread/windows/SDL_sysrwlock_srw.c b/src/thread/windows/SDL_sysrwlock_srw.c index c22eecae8..5b5953a38 100644 --- a/src/thread/windows/SDL_sysrwlock_srw.c +++ b/src/thread/windows/SDL_sysrwlock_srw.c @@ -88,7 +88,7 @@ typedef struct SDL_rwlock_srw static SDL_RWLock *SDL_CreateRWLock_srw(void) { SDL_rwlock_srw *rwlock = (SDL_rwlock_srw *)SDL_calloc(1, sizeof(*rwlock)); - if (rwlock == NULL) { + if (!rwlock) { SDL_OutOfMemory(); } pInitializeSRWLock(&rwlock->srw); @@ -125,7 +125,7 @@ static int SDL_TryLockRWLockForReading_srw(SDL_RWLock *_rwlock) { SDL_rwlock_srw *rwlock = (SDL_rwlock_srw *) _rwlock; int retval = 0; - if (rwlock != NULL) { + if (rwlock) { retval = pTryAcquireSRWLockShared(&rwlock->srw) ? 0 : SDL_RWLOCK_TIMEDOUT; } return retval; @@ -135,7 +135,7 @@ static int SDL_TryLockRWLockForWriting_srw(SDL_RWLock *_rwlock) { SDL_rwlock_srw *rwlock = (SDL_rwlock_srw *) _rwlock; int retval = 0; - if (rwlock != NULL) { + if (rwlock) { retval = pTryAcquireSRWLockExclusive(&rwlock->srw) ? 0 : SDL_RWLOCK_TIMEDOUT; } return retval; @@ -182,7 +182,7 @@ static const SDL_rwlock_impl_t SDL_rwlock_impl_generic = { SDL_RWLock *SDL_CreateRWLock(void) { - if (SDL_rwlock_impl_active.Create == NULL) { + if (!SDL_rwlock_impl_active.Create) { const SDL_rwlock_impl_t *impl; #ifdef __WINRT__ diff --git a/src/thread/windows/SDL_syssem.c b/src/thread/windows/SDL_syssem.c index b1097e315..493dd3178 100644 --- a/src/thread/windows/SDL_syssem.c +++ b/src/thread/windows/SDL_syssem.c @@ -83,7 +83,7 @@ static SDL_Semaphore *SDL_CreateSemaphore_atom(Uint32 initial_value) SDL_sem_atom *sem; sem = (SDL_sem_atom *)SDL_malloc(sizeof(*sem)); - if (sem != NULL) { + if (sem) { sem->count = initial_value; } else { SDL_OutOfMemory(); @@ -93,7 +93,7 @@ static SDL_Semaphore *SDL_CreateSemaphore_atom(Uint32 initial_value) static void SDL_DestroySemaphore_atom(SDL_Semaphore *sem) { - if (sem != NULL) { + if (sem) { SDL_free(sem); } } @@ -106,7 +106,7 @@ static int SDL_WaitSemaphoreTimeoutNS_atom(SDL_Semaphore *_sem, Sint64 timeoutNS Uint64 deadline; DWORD timeout_eff; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -176,7 +176,7 @@ static Uint32 SDL_GetSemaphoreValue_atom(SDL_Semaphore *_sem) { SDL_sem_atom *sem = (SDL_sem_atom *)_sem; - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -188,7 +188,7 @@ static int SDL_PostSemaphore_atom(SDL_Semaphore *_sem) { SDL_sem_atom *sem = (SDL_sem_atom *)_sem; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -224,7 +224,7 @@ static SDL_Semaphore *SDL_CreateSemaphore_kern(Uint32 initial_value) /* Allocate sem memory */ sem = (SDL_sem_kern *)SDL_malloc(sizeof(*sem)); - if (sem != NULL) { + if (sem) { /* Create the semaphore, with max value 32K */ #ifdef __WINRT__ sem->id = CreateSemaphoreEx(NULL, initial_value, 32 * 1024, NULL, 0, SEMAPHORE_ALL_ACCESS); @@ -247,7 +247,7 @@ static SDL_Semaphore *SDL_CreateSemaphore_kern(Uint32 initial_value) static void SDL_DestroySemaphore_kern(SDL_Semaphore *_sem) { SDL_sem_kern *sem = (SDL_sem_kern *)_sem; - if (sem != NULL) { + if (sem) { if (sem->id) { CloseHandle(sem->id); sem->id = 0; @@ -262,7 +262,7 @@ static int SDL_WaitSemaphoreTimeoutNS_kern(SDL_Semaphore *_sem, Sint64 timeoutNS int retval; DWORD dwMilliseconds; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -290,7 +290,7 @@ static int SDL_WaitSemaphoreTimeoutNS_kern(SDL_Semaphore *_sem, Sint64 timeoutNS static Uint32 SDL_GetSemaphoreValue_kern(SDL_Semaphore *_sem) { SDL_sem_kern *sem = (SDL_sem_kern *)_sem; - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -300,7 +300,7 @@ static Uint32 SDL_GetSemaphoreValue_kern(SDL_Semaphore *_sem) static int SDL_PostSemaphore_kern(SDL_Semaphore *_sem) { SDL_sem_kern *sem = (SDL_sem_kern *)_sem; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } /* Increase the counter in the first place, because @@ -330,7 +330,7 @@ static const SDL_sem_impl_t SDL_sem_impl_kern = { SDL_Semaphore *SDL_CreateSemaphore(Uint32 initial_value) { - if (SDL_sem_impl_active.Create == NULL) { + if (!SDL_sem_impl_active.Create) { /* Default to fallback implementation */ const SDL_sem_impl_t *impl = &SDL_sem_impl_kern; diff --git a/src/thread/windows/SDL_systhread.c b/src/thread/windows/SDL_systhread.c index 8755f67c3..007665650 100644 --- a/src/thread/windows/SDL_systhread.c +++ b/src/thread/windows/SDL_systhread.c @@ -47,7 +47,7 @@ static DWORD RunThread(void *data) SDL_Thread *thread = (SDL_Thread *)data; pfnSDL_CurrentEndThread pfnEndThread = (pfnSDL_CurrentEndThread)thread->endfunc; SDL_RunThread(thread); - if (pfnEndThread != NULL) { + if (pfnEndThread) { pfnEndThread(0); } return 0; @@ -96,7 +96,7 @@ int SDL_SYS_CreateThread(SDL_Thread *thread) RunThreadViaCreateThread, thread, flags, &threadid); } - if (thread->handle == NULL) { + if (!thread->handle) { return SDL_SetError("Not enough resources to create thread"); } return 0; @@ -116,7 +116,7 @@ typedef HRESULT(WINAPI *pfnSetThreadDescription)(HANDLE, PCWSTR); void SDL_SYS_SetupThread(const char *name) { - if (name != NULL) { + if (name) { #ifndef __WINRT__ /* !!! FIXME: There's no LoadLibrary() in WinRT; don't know if SetThreadDescription is available there at all at the moment. */ static pfnSetThreadDescription pSetThreadDescription = NULL; static HMODULE kernel32 = NULL; @@ -128,7 +128,7 @@ void SDL_SYS_SetupThread(const char *name) } } - if (pSetThreadDescription != NULL) { + if (pSetThreadDescription) { WCHAR *strw = WIN_UTF8ToStringW(name); if (strw) { pSetThreadDescription(GetCurrentThread(), strw); diff --git a/src/timer/SDL_timer.c b/src/timer/SDL_timer.c index 67296bbb8..a5ca67579 100644 --- a/src/timer/SDL_timer.c +++ b/src/timer/SDL_timer.c @@ -171,7 +171,7 @@ static int SDLCALL SDL_TimerThread(void *_data) current->scheduled = tick + interval; SDL_AddTimerInternal(data, current); } else { - if (freelist_head == NULL) { + if (!freelist_head) { freelist_head = current; } if (freelist_tail) { @@ -296,7 +296,7 @@ SDL_TimerID SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *para SDL_RemoveTimer(timer->timerID); } else { timer = (SDL_Timer *)SDL_malloc(sizeof(*timer)); - if (timer == NULL) { + if (!timer) { SDL_OutOfMemory(); return 0; } @@ -309,7 +309,7 @@ SDL_TimerID SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *para SDL_AtomicSet(&timer->canceled, 0); entry = (SDL_TimerMap *)SDL_malloc(sizeof(*entry)); - if (entry == NULL) { + if (!entry) { SDL_free(timer); SDL_OutOfMemory(); return 0; @@ -422,7 +422,7 @@ SDL_TimerID SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *para SDL_TimerMap *entry; entry = (SDL_TimerMap *)SDL_malloc(sizeof(*entry)); - if (entry == NULL) { + if (!entry) { SDL_OutOfMemory(); return 0; } diff --git a/src/video/SDL_RLEaccel.c b/src/video/SDL_RLEaccel.c index 5c478a58d..a9e82465c 100644 --- a/src/video/SDL_RLEaccel.c +++ b/src/video/SDL_RLEaccel.c @@ -1023,7 +1023,7 @@ static int RLEAlphaSurface(SDL_Surface *surface) SDL_PixelFormat *, SDL_PixelFormat *); dest = surface->map->dst; - if (dest == NULL) { + if (!dest) { return -1; } df = dest->format; @@ -1080,7 +1080,7 @@ static int RLEAlphaSurface(SDL_Surface *surface) maxsize += sizeof(RLEDestFormat); rlebuf = (Uint8 *)SDL_malloc(maxsize); - if (rlebuf == NULL) { + if (!rlebuf) { return SDL_OutOfMemory(); } { @@ -1226,7 +1226,7 @@ static int RLEAlphaSurface(SDL_Surface *surface) /* reallocate the buffer to release unused memory */ { Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf); - if (p == NULL) { + if (!p) { p = rlebuf; } surface->map->data = p; @@ -1299,7 +1299,7 @@ static int RLEColorkeySurface(SDL_Surface *surface) } rlebuf = (Uint8 *)SDL_malloc(maxsize); - if (rlebuf == NULL) { + if (!rlebuf) { return SDL_OutOfMemory(); } @@ -1394,7 +1394,7 @@ static int RLEColorkeySurface(SDL_Surface *surface) { /* If SDL_realloc returns NULL, the original block is left intact */ Uint8 *p = SDL_realloc(rlebuf, dst - rlebuf); - if (p == NULL) { + if (!p) { p = rlebuf; } surface->map->data = p; @@ -1496,7 +1496,7 @@ static SDL_bool UnRLEAlpha(SDL_Surface *surface) } surface->pixels = SDL_aligned_alloc(SDL_SIMDGetAlignment(), size); - if (surface->pixels == NULL) { + if (!surface->pixels) { return SDL_FALSE; } surface->flags |= SDL_SIMD_ALIGNED; @@ -1568,7 +1568,7 @@ void SDL_UnRLESurface(SDL_Surface *surface, int recode) return; } surface->pixels = SDL_aligned_alloc(SDL_SIMDGetAlignment(), size); - if (surface->pixels == NULL) { + if (!surface->pixels) { /* Oh crap... */ surface->flags |= SDL_RLEACCEL; return; diff --git a/src/video/SDL_blit.c b/src/video/SDL_blit.c index cb3f25a16..44807bcb9 100644 --- a/src/video/SDL_blit.c +++ b/src/video/SDL_blit.c @@ -247,7 +247,7 @@ int SDL_CalculateBlit(SDL_Surface *surface) } #endif #if SDL_HAVE_BLIT_AUTO - if (blit == NULL) { + if (!blit) { Uint32 src_format = surface->format->format; Uint32 dst_format = dst->format->format; @@ -258,7 +258,7 @@ int SDL_CalculateBlit(SDL_Surface *surface) #endif #ifndef TEST_SLOW_BLIT - if (blit == NULL) + if (!blit) #endif { Uint32 src_format = surface->format->format; @@ -274,7 +274,7 @@ int SDL_CalculateBlit(SDL_Surface *surface) map->data = blit; /* Make sure we have a blit function */ - if (blit == NULL) { + if (!blit) { SDL_InvalidateMap(map); return SDL_SetError("Blit combination not supported"); } diff --git a/src/video/SDL_blit_A.c b/src/video/SDL_blit_A.c index ef0b8de4e..0e61c8a35 100644 --- a/src/video/SDL_blit_A.c +++ b/src/video/SDL_blit_A.c @@ -1326,7 +1326,7 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface) /* Per-pixel alpha blits */ switch (df->BytesPerPixel) { case 1: - if (df->palette != NULL) { + if (df->palette) { return BlitNto1PixelAlpha; } else { /* RGB332 has no palette ! */ @@ -1397,7 +1397,7 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface) /* Per-surface alpha blits */ switch (df->BytesPerPixel) { case 1: - if (df->palette != NULL) { + if (df->palette) { return BlitNto1SurfaceAlpha; } else { /* RGB332 has no palette ! */ @@ -1452,7 +1452,7 @@ SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface *surface) if (sf->Amask == 0) { if (df->BytesPerPixel == 1) { - if (df->palette != NULL) { + if (df->palette) { return BlitNto1SurfaceAlphaKey; } else { /* RGB332 has no palette ! */ diff --git a/src/video/SDL_blit_N.c b/src/video/SDL_blit_N.c index 4c1f8c3e3..541e6edb1 100644 --- a/src/video/SDL_blit_N.c +++ b/src/video/SDL_blit_N.c @@ -971,7 +971,7 @@ static void Blit_XRGB8888_index8(SDL_BlitInfo *info) dstskip = info->dst_skip; map = info->table; - if (map == NULL) { + if (!map) { while (height--) { #ifdef USE_DUFFS_LOOP /* *INDENT-OFF* */ /* clang-format off */ @@ -1085,7 +1085,7 @@ static void Blit_RGB101010_index8(SDL_BlitInfo *info) dstskip = info->dst_skip; map = info->table; - if (map == NULL) { + if (!map) { while (height--) { #ifdef USE_DUFFS_LOOP /* *INDENT-OFF* */ /* clang-format off */ @@ -2109,7 +2109,7 @@ static void BlitNto1(SDL_BlitInfo *info) srcfmt = info->src_fmt; srcbpp = srcfmt->BytesPerPixel; - if (map == NULL) { + if (!map) { while (height--) { #ifdef USE_DUFFS_LOOP /* *INDENT-OFF* */ /* clang-format off */ @@ -2505,7 +2505,7 @@ static void BlitNto1Key(SDL_BlitInfo *info) srcbpp = srcfmt->BytesPerPixel; ckey &= rgbmask; - if (palmap == NULL) { + if (!palmap) { while (height--) { /* *INDENT-OFF* */ /* clang-format off */ DUFFS_LOOP( diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c index 998bee1f3..c9fdcdbaf 100644 --- a/src/video/SDL_bmp.c +++ b/src/video/SDL_bmp.c @@ -235,7 +235,7 @@ SDL_Surface *SDL_LoadBMP_RW(SDL_RWops *src, SDL_bool freesrc) /* Make sure we are passed a valid data source */ surface = NULL; - if (src == NULL) { + if (!src) { SDL_InvalidParamError("src"); goto done; } @@ -442,7 +442,7 @@ SDL_Surface *SDL_LoadBMP_RW(SDL_RWops *src, SDL_bool freesrc) format = SDL_GetPixelFormatEnumForMasks(biBitCount, Rmask, Gmask, Bmask, Amask); surface = SDL_CreateSurface(biWidth, biHeight, format); - if (surface == NULL) { + if (!surface) { goto done; } } @@ -695,7 +695,7 @@ int SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, SDL_bool freedst) } #endif /* SAVE_32BIT_BMP */ - if (surface->format->palette != NULL && !save32bit) { + if (surface->format->palette && !save32bit) { if (surface->format->BitsPerPixel == 8) { intermediate_surface = surface; } else { @@ -726,7 +726,7 @@ int SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, SDL_bool freedst) pixel_format = SDL_PIXELFORMAT_BGR24; } intermediate_surface = SDL_ConvertSurfaceFormat(surface, pixel_format); - if (intermediate_surface == NULL) { + if (!intermediate_surface) { SDL_SetError("Couldn't convert image to %d bpp", (int)SDL_BITSPERPIXEL(pixel_format)); goto done; diff --git a/src/video/SDL_clipboard.c b/src/video/SDL_clipboard.c index a2396bd4f..df116314b 100644 --- a/src/video/SDL_clipboard.c +++ b/src/video/SDL_clipboard.c @@ -58,7 +58,7 @@ int SDL_SetClipboardData(SDL_ClipboardDataCallback callback, SDL_ClipboardCleanu SDL_VideoDevice *_this = SDL_GetVideoDevice(); size_t i; - if (_this == NULL) { + if (!_this) { return SDL_SetError("Video subsystem must be initialized to set clipboard text"); } @@ -168,7 +168,7 @@ void *SDL_GetClipboardData(const char *mime_type, size_t *size) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); - if (_this == NULL) { + if (!_this) { SDL_SetError("Video subsystem must be initialized to get clipboard data"); return NULL; } @@ -215,7 +215,7 @@ SDL_bool SDL_HasClipboardData(const char *mime_type) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); - if (_this == NULL) { + if (!_this) { SDL_SetError("Video subsystem must be initialized to check clipboard data"); return SDL_FALSE; } @@ -272,7 +272,7 @@ int SDL_SetClipboardText(const char *text) size_t num_mime_types; const char **text_mime_types; - if (_this == NULL) { + if (!_this) { return SDL_SetError("Video subsystem must be initialized to set clipboard text"); } @@ -293,7 +293,7 @@ char *SDL_GetClipboardText(void) size_t length; char *text = NULL; - if (_this == NULL) { + if (!_this) { SDL_SetError("Video subsystem must be initialized to get clipboard text"); return SDL_strdup(""); } @@ -318,7 +318,7 @@ SDL_bool SDL_HasClipboardText(void) size_t i, num_mime_types; const char **text_mime_types; - if (_this == NULL) { + if (!_this) { SDL_SetError("Video subsystem must be initialized to check clipboard text"); return SDL_FALSE; } @@ -338,11 +338,11 @@ int SDL_SetPrimarySelectionText(const char *text) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); - if (_this == NULL) { + if (!_this) { return SDL_SetError("Video subsystem must be initialized to set primary selection text"); } - if (text == NULL) { + if (!text) { text = ""; } if (_this->SetPrimarySelectionText) { @@ -362,7 +362,7 @@ char *SDL_GetPrimarySelectionText(void) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); - if (_this == NULL) { + if (!_this) { SDL_SetError("Video subsystem must be initialized to get primary selection text"); return SDL_strdup(""); } @@ -371,7 +371,7 @@ char *SDL_GetPrimarySelectionText(void) return _this->GetPrimarySelectionText(_this); } else { const char *text = _this->primary_selection_text; - if (text == NULL) { + if (!text) { text = ""; } return SDL_strdup(text); @@ -382,7 +382,7 @@ SDL_bool SDL_HasPrimarySelectionText(void) { SDL_VideoDevice *_this = SDL_GetVideoDevice(); - if (_this == NULL) { + if (!_this) { SDL_SetError("Video subsystem must be initialized to check primary selection text"); return SDL_FALSE; } diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c index 19b804286..a2d72114b 100644 --- a/src/video/SDL_egl.c +++ b/src/video/SDL_egl.c @@ -184,7 +184,7 @@ SDL_bool SDL_EGL_HasExtension(SDL_VideoDevice *_this, SDL_EGL_ExtensionType type const char *ext_start; /* Invalid extensions can be rejected early */ - if (ext == NULL || *ext == 0 || SDL_strchr(ext, ' ') != NULL) { + if (!ext || *ext == 0 || SDL_strchr(ext, ' ') != NULL) { /* SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "SDL_EGL_HasExtension: Invalid EGL extension"); */ return SDL_FALSE; } @@ -197,7 +197,7 @@ SDL_bool SDL_EGL_HasExtension(SDL_VideoDevice *_this, SDL_EGL_ExtensionType type * 1 If set, the client extension is masked and not present to SDL. */ ext_override = SDL_getenv(ext); - if (ext_override != NULL) { + if (ext_override) { int disable_ext = SDL_atoi(ext_override); if (disable_ext & 0x01 && type == SDL_EGL_DISPLAY_EXTENSION) { return SDL_FALSE; @@ -223,12 +223,12 @@ SDL_bool SDL_EGL_HasExtension(SDL_VideoDevice *_this, SDL_EGL_ExtensionType type return SDL_FALSE; } - if (egl_extstr != NULL) { + if (egl_extstr) { ext_start = egl_extstr; while (*ext_start) { ext_start = SDL_strstr(ext_start, ext); - if (ext_start == NULL) { + if (!ext_start) { return SDL_FALSE; } /* Check if the match is not just a substring of one of the extensions */ @@ -251,24 +251,24 @@ SDL_bool SDL_EGL_HasExtension(SDL_VideoDevice *_this, SDL_EGL_ExtensionType type SDL_FunctionPointer SDL_EGL_GetProcAddressInternal(SDL_VideoDevice *_this, const char *proc) { SDL_FunctionPointer retval = NULL; - if (_this->egl_data != NULL) { + if (_this->egl_data) { const Uint32 eglver = (((Uint32)_this->egl_data->egl_version_major) << 16) | ((Uint32)_this->egl_data->egl_version_minor); const SDL_bool is_egl_15_or_later = eglver >= ((((Uint32)1) << 16) | 5); /* EGL 1.5 can use eglGetProcAddress() for any symbol. 1.4 and earlier can't use it for core entry points. */ - if (retval == NULL && is_egl_15_or_later && _this->egl_data->eglGetProcAddress) { + if (!retval && is_egl_15_or_later && _this->egl_data->eglGetProcAddress) { retval = _this->egl_data->eglGetProcAddress(proc); } #if !defined(__EMSCRIPTEN__) && !defined(SDL_VIDEO_DRIVER_VITA) /* LoadFunction isn't needed on Emscripten and will call dlsym(), causing other problems. */ /* Try SDL_LoadFunction() first for EGL <= 1.4, or as a fallback for >= 1.5. */ - if (retval == NULL) { + if (!retval) { retval = SDL_LoadFunction(_this->egl_data->opengl_dll_handle, proc); } #endif /* Try eglGetProcAddress if we're on <= 1.4 and still searching... */ - if (retval == NULL && !is_egl_15_or_later && _this->egl_data->eglGetProcAddress) { + if (!retval && !is_egl_15_or_later && _this->egl_data->eglGetProcAddress) { retval = _this->egl_data->eglGetProcAddress(proc); } } @@ -342,17 +342,17 @@ static int SDL_EGL_LoadLibraryInternal(SDL_VideoDevice *_this, const char *egl_p #if !defined(SDL_VIDEO_STATIC_ANGLE) && !defined(SDL_VIDEO_DRIVER_VITA) /* A funny thing, loading EGL.so first does not work on the Raspberry, so we load libGL* first */ path = SDL_getenv("SDL_VIDEO_GL_DRIVER"); - if (path != NULL) { + if (path) { opengl_dll_handle = SDL_LoadObject(path); } - if (opengl_dll_handle == NULL) { + if (!opengl_dll_handle) { if (_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) { if (_this->gl_config.major_version > 1) { path = DEFAULT_OGL_ES2; opengl_dll_handle = SDL_LoadObject(path); #ifdef ALT_OGL_ES2 - if (opengl_dll_handle == NULL && !vc4) { + if (!opengl_dll_handle && !vc4) { path = ALT_OGL_ES2; opengl_dll_handle = SDL_LoadObject(path); } @@ -361,12 +361,12 @@ static int SDL_EGL_LoadLibraryInternal(SDL_VideoDevice *_this, const char *egl_p } else { path = DEFAULT_OGL_ES; opengl_dll_handle = SDL_LoadObject(path); - if (opengl_dll_handle == NULL) { + if (!opengl_dll_handle) { path = DEFAULT_OGL_ES_PVR; opengl_dll_handle = SDL_LoadObject(path); } #ifdef ALT_OGL_ES2 - if (opengl_dll_handle == NULL && !vc4) { + if (!opengl_dll_handle && !vc4) { path = ALT_OGL_ES2; opengl_dll_handle = SDL_LoadObject(path); } @@ -378,7 +378,7 @@ static int SDL_EGL_LoadLibraryInternal(SDL_VideoDevice *_this, const char *egl_p path = DEFAULT_OGL; opengl_dll_handle = SDL_LoadObject(path); #ifdef ALT_OGL - if (opengl_dll_handle == NULL) { + if (!opengl_dll_handle) { path = ALT_OGL; opengl_dll_handle = SDL_LoadObject(path); } @@ -388,34 +388,34 @@ static int SDL_EGL_LoadLibraryInternal(SDL_VideoDevice *_this, const char *egl_p } _this->egl_data->opengl_dll_handle = opengl_dll_handle; - if (opengl_dll_handle == NULL) { + if (!opengl_dll_handle) { return SDL_SetError("Could not initialize OpenGL / GLES library"); } /* Loading libGL* in the previous step took care of loading libEGL.so, but we future proof by double checking */ - if (egl_path != NULL) { + if (egl_path) { egl_dll_handle = SDL_LoadObject(egl_path); } /* Try loading a EGL symbol, if it does not work try the default library paths */ - if (egl_dll_handle == NULL || SDL_LoadFunction(egl_dll_handle, "eglChooseConfig") == NULL) { - if (egl_dll_handle != NULL) { + if (!egl_dll_handle || SDL_LoadFunction(egl_dll_handle, "eglChooseConfig") == NULL) { + if (egl_dll_handle) { SDL_UnloadObject(egl_dll_handle); } path = SDL_getenv("SDL_VIDEO_EGL_DRIVER"); - if (path == NULL) { + if (!path) { path = DEFAULT_EGL; } egl_dll_handle = SDL_LoadObject(path); #ifdef ALT_EGL - if (egl_dll_handle == NULL && !vc4) { + if (!egl_dll_handle && !vc4) { path = ALT_EGL; egl_dll_handle = SDL_LoadObject(path); } #endif - if (egl_dll_handle == NULL || SDL_LoadFunction(egl_dll_handle, "eglChooseConfig") == NULL) { - if (egl_dll_handle != NULL) { + if (!egl_dll_handle || SDL_LoadFunction(egl_dll_handle, "eglChooseConfig") == NULL) { + if (egl_dll_handle) { SDL_UnloadObject(egl_dll_handle); } return SDL_SetError("Could not load EGL library"); @@ -550,7 +550,7 @@ int SDL_EGL_LoadLibrary(SDL_VideoDevice *_this, const char *egl_path, NativeDisp #endif /* Try the implementation-specific eglGetDisplay even if eglGetPlatformDisplay fails */ if ((_this->egl_data->egl_display == EGL_NO_DISPLAY) && - (_this->egl_data->eglGetDisplay != NULL) && + (_this->egl_data->eglGetDisplay) && SDL_GetHintBoolean(SDL_HINT_VIDEO_EGL_ALLOW_GETDISPLAY_FALLBACK, SDL_TRUE)) { _this->egl_data->egl_display = _this->egl_data->eglGetDisplay(native_display); } @@ -594,11 +594,11 @@ int SDL_EGL_InitializeOffscreen(SDL_VideoDevice *_this, int device) } /* Check for all extensions that are optional until used and fail if any is missing */ - if (_this->egl_data->eglQueryDevicesEXT == NULL) { + if (!_this->egl_data->eglQueryDevicesEXT) { return SDL_SetError("eglQueryDevicesEXT is missing (EXT_device_enumeration not supported by the drivers?)"); } - if (_this->egl_data->eglGetPlatformDisplayEXT == NULL) { + if (!_this->egl_data->eglGetPlatformDisplayEXT) { return SDL_SetError("eglGetPlatformDisplayEXT is missing (EXT_platform_base not supported by the drivers?)"); } diff --git a/src/video/SDL_fillrect.c b/src/video/SDL_fillrect.c index 1e0eac852..2a4c132be 100644 --- a/src/video/SDL_fillrect.c +++ b/src/video/SDL_fillrect.c @@ -231,12 +231,12 @@ static void SDL_FillSurfaceRect4(Uint8 *pixels, int pitch, Uint32 color, int w, */ int SDL_FillSurfaceRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color) { - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_FillSurfaceRect(): dst"); } /* If 'rect' == NULL, then fill the whole surface */ - if (rect == NULL) { + if (!rect) { rect = &dst->clip_rect; /* Don't attempt to fill if the surface's clip_rect is empty */ if (SDL_RectEmpty(rect)) { @@ -304,7 +304,7 @@ int SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count, void (*fill_function)(Uint8 * pixels, int pitch, Uint32 color, int w, int h) = NULL; int i; - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_FillSurfaceRects(): dst"); } @@ -318,7 +318,7 @@ int SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count, return SDL_SetError("SDL_FillSurfaceRects(): You must lock the surface"); } - if (rects == NULL) { + if (!rects) { return SDL_InvalidParamError("SDL_FillSurfaceRects(): rects"); } @@ -340,7 +340,7 @@ int SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count, } #ifdef SDL_ARM_NEON_BLITTERS - if (SDL_HasNEON() && dst->format->BytesPerPixel != 3 && fill_function == NULL) { + if (SDL_HasNEON() && dst->format->BytesPerPixel != 3 && !fill_function) { switch (dst->format->BytesPerPixel) { case 1: fill_function = fill_8_neon; @@ -355,7 +355,7 @@ int SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count, } #endif #ifdef SDL_ARM_SIMD_BLITTERS - if (SDL_HasARMSIMD() && dst->format->BytesPerPixel != 3 && fill_function == NULL) { + if (SDL_HasARMSIMD() && dst->format->BytesPerPixel != 3 && !fill_function) { switch (dst->format->BytesPerPixel) { case 1: fill_function = fill_8_simd; @@ -370,7 +370,7 @@ int SDL_FillSurfaceRects(SDL_Surface *dst, const SDL_Rect *rects, int count, } #endif - if (fill_function == NULL) { + if (!fill_function) { switch (dst->format->BytesPerPixel) { case 1: { diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c index f9e79bfd4..262880c83 100644 --- a/src/video/SDL_pixels.c +++ b/src/video/SDL_pixels.c @@ -558,7 +558,7 @@ SDL_PixelFormat *SDL_CreatePixelFormat(Uint32 pixel_format) /* Allocate an empty pixel format structure, and initialize it */ format = SDL_malloc(sizeof(*format)); - if (format == NULL) { + if (!format) { SDL_AtomicUnlock(&formats_lock); SDL_OutOfMemory(); return NULL; @@ -656,7 +656,7 @@ void SDL_DestroyPixelFormat(SDL_PixelFormat *format) { SDL_PixelFormat *prev; - if (format == NULL) { + if (!format) { return; } @@ -699,7 +699,7 @@ SDL_Palette *SDL_CreatePalette(int ncolors) } palette = (SDL_Palette *)SDL_malloc(sizeof(*palette)); - if (palette == NULL) { + if (!palette) { SDL_OutOfMemory(); return NULL; } @@ -721,7 +721,7 @@ SDL_Palette *SDL_CreatePalette(int ncolors) int SDL_SetPixelFormatPalette(SDL_PixelFormat *format, SDL_Palette *palette) { - if (format == NULL) { + if (!format) { return SDL_InvalidParamError("SDL_SetPixelFormatPalette(): format"); } @@ -752,7 +752,7 @@ int SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors, int status = 0; /* Verify the parameters */ - if (palette == NULL) { + if (!palette) { return -1; } if (ncolors > (palette->ncolors - firstcolor)) { @@ -774,7 +774,7 @@ int SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors, void SDL_DestroyPalette(SDL_Palette *palette) { - if (palette == NULL) { + if (!palette) { return; } if (--palette->refcount > 0) { @@ -895,7 +895,7 @@ Uint32 SDL_MapRGB(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b) SDL_InvalidParamError("format"); return 0; } - if (format->palette == NULL) { + if (!format->palette) { return (r >> format->Rloss) << format->Rshift | (g >> format->Gloss) << format->Gshift | (b >> format->Bloss) << format->Bshift | format->Amask; } else { return SDL_FindColor(format->palette, r, g, b, SDL_ALPHA_OPAQUE); @@ -910,7 +910,7 @@ Uint32 SDL_MapRGBA(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b, SDL_InvalidParamError("format"); return 0; } - if (format->palette == NULL) { + if (!format->palette) { return (r >> format->Rloss) << format->Rshift | (g >> format->Gloss) << format->Gshift | (b >> format->Bloss) << format->Bshift | ((Uint32)(a >> format->Aloss) << format->Ashift & format->Amask); } else { return SDL_FindColor(format->palette, r, g, b, a); @@ -920,7 +920,7 @@ Uint32 SDL_MapRGBA(const SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b, void SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat *format, Uint8 *r, Uint8 *g, Uint8 *b) { - if (format->palette == NULL) { + if (!format->palette) { unsigned v; v = (pixel & format->Rmask) >> format->Rshift; *r = SDL_expand_byte[format->Rloss][v]; @@ -942,7 +942,7 @@ void SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat *format, Uint8 *r, Uint8 *g, void SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat *format, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a) { - if (format->palette == NULL) { + if (!format->palette) { unsigned v; v = (pixel & format->Rmask) >> format->Rshift; *r = SDL_expand_byte[format->Rloss][v]; @@ -983,7 +983,7 @@ static Uint8 *Map1to1(SDL_Palette *src, SDL_Palette *dst, int *identical) *identical = 0; } map = (Uint8 *)SDL_calloc(256, sizeof(Uint8)); - if (map == NULL) { + if (!map) { SDL_OutOfMemory(); return NULL; } @@ -1006,7 +1006,7 @@ static Uint8 *Map1toN(SDL_PixelFormat *src, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod, bpp = ((dst->BytesPerPixel == 3) ? 4 : dst->BytesPerPixel); map = (Uint8 *)SDL_calloc(256, bpp); - if (map == NULL) { + if (!map) { SDL_OutOfMemory(); return NULL; } @@ -1042,7 +1042,7 @@ SDL_BlitMap *SDL_AllocBlitMap(void) /* Allocate the empty map */ map = (SDL_BlitMap *)SDL_calloc(1, sizeof(*map)); - if (map == NULL) { + if (!map) { SDL_OutOfMemory(); return NULL; } @@ -1071,7 +1071,7 @@ void SDL_InvalidateAllBlitMap(SDL_Surface *surface) void SDL_InvalidateMap(SDL_BlitMap *map) { - if (map == NULL) { + if (!map) { return; } if (map->dst) { @@ -1110,7 +1110,7 @@ int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst) map->info.table = Map1to1(srcfmt->palette, dstfmt->palette, &map->identity); if (!map->identity) { - if (map->info.table == NULL) { + if (!map->info.table) { return -1; } } @@ -1122,7 +1122,7 @@ int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst) map->info.table = Map1toN(srcfmt, src->map->info.r, src->map->info.g, src->map->info.b, src->map->info.a, dstfmt); - if (map->info.table == NULL) { + if (!map->info.table) { return -1; } } @@ -1131,7 +1131,7 @@ int SDL_MapSurface(SDL_Surface *src, SDL_Surface *dst) /* BitField --> Palette */ map->info.table = MapNto1(srcfmt, dstfmt, &map->identity); if (!map->identity) { - if (map->info.table == NULL) { + if (!map->info.table) { return -1; } } diff --git a/src/video/SDL_rect.c b/src/video/SDL_rect.c index af3a809c7..d37361149 100644 --- a/src/video/SDL_rect.c +++ b/src/video/SDL_rect.c @@ -37,10 +37,10 @@ SDL_bool SDL_GetSpanEnclosingRect(int width, int height, } else if (height < 1) { SDL_InvalidParamError("height"); return SDL_FALSE; - } else if (rects == NULL) { + } else if (!rects) { SDL_InvalidParamError("rects"); return SDL_FALSE; - } else if (span == NULL) { + } else if (!span) { SDL_InvalidParamError("span"); return SDL_FALSE; } else if (numrects < 1) { diff --git a/src/video/SDL_rect_impl.h b/src/video/SDL_rect_impl.h index 4b8713c37..15591a5ac 100644 --- a/src/video/SDL_rect_impl.h +++ b/src/video/SDL_rect_impl.h @@ -25,10 +25,10 @@ SDL_bool SDL_HASINTERSECTION(const RECTTYPE *A, const RECTTYPE *B) { SCALARTYPE Amin, Amax, Bmin, Bmax; - if (A == NULL) { + if (!A) { SDL_InvalidParamError("A"); return SDL_FALSE; - } else if (B == NULL) { + } else if (!B) { SDL_InvalidParamError("B"); return SDL_FALSE; } else if (SDL_RECTEMPTY(A) || SDL_RECTEMPTY(B)) { @@ -70,13 +70,13 @@ SDL_bool SDL_INTERSECTRECT(const RECTTYPE *A, const RECTTYPE *B, RECTTYPE *resul { SCALARTYPE Amin, Amax, Bmin, Bmax; - if (A == NULL) { + if (!A) { SDL_InvalidParamError("A"); return SDL_FALSE; - } else if (B == NULL) { + } else if (!B) { SDL_InvalidParamError("B"); return SDL_FALSE; - } else if (result == NULL) { + } else if (!result) { SDL_InvalidParamError("result"); return SDL_FALSE; } else if (SDL_RECTEMPTY(A) || SDL_RECTEMPTY(B)) { /* Special cases for empty rects */ @@ -120,11 +120,11 @@ int SDL_UNIONRECT(const RECTTYPE *A, const RECTTYPE *B, RECTTYPE *result) { SCALARTYPE Amin, Amax, Bmin, Bmax; - if (A == NULL) { + if (!A) { return SDL_InvalidParamError("A"); - } else if (B == NULL) { + } else if (!B) { return SDL_InvalidParamError("B"); - } else if (result == NULL) { + } else if (!result) { return SDL_InvalidParamError("result"); } else if (SDL_RECTEMPTY(A)) { /* Special cases for empty Rects */ if (SDL_RECTEMPTY(B)) { /* A and B empty */ @@ -178,7 +178,7 @@ SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE *points, int count, const RECTTYPE *c SCALARTYPE x, y; int i; - if (points == NULL) { + if (!points) { SDL_InvalidParamError("points"); return SDL_FALSE; } else if (count < 1) { @@ -208,7 +208,7 @@ SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE *points, int count, const RECTTYPE *c } if (!added) { /* Special case: if no result was requested, we are done */ - if (result == NULL) { + if (!result) { return SDL_TRUE; } @@ -234,7 +234,7 @@ SDL_bool SDL_ENCLOSEPOINTS(const POINTTYPE *points, int count, const RECTTYPE *c } } else { /* Special case: if no result was requested, we are done */ - if (result == NULL) { + if (!result) { return SDL_TRUE; } @@ -297,19 +297,19 @@ SDL_bool SDL_INTERSECTRECTANDLINE(const RECTTYPE *rect, SCALARTYPE *X1, SCALARTY SCALARTYPE recty2; int outcode1, outcode2; - if (rect == NULL) { + if (!rect) { SDL_InvalidParamError("rect"); return SDL_FALSE; - } else if (X1 == NULL) { + } else if (!X1) { SDL_InvalidParamError("X1"); return SDL_FALSE; - } else if (Y1 == NULL) { + } else if (!Y1) { SDL_InvalidParamError("Y1"); return SDL_FALSE; - } else if (X2 == NULL) { + } else if (!X2) { SDL_InvalidParamError("X2"); return SDL_FALSE; - } else if (Y2 == NULL) { + } else if (!Y2) { SDL_InvalidParamError("Y2"); return SDL_FALSE; } else if (SDL_RECTEMPTY(rect)) { diff --git a/src/video/SDL_shape.c b/src/video/SDL_shape.c index b5fc437b7..2afcf6319 100644 --- a/src/video/SDL_shape.c +++ b/src/video/SDL_shape.c @@ -28,13 +28,13 @@ SDL_Window *SDL_CreateShapedWindow(const char *title, int w, int h, Uint32 flags { SDL_Window *result = NULL; result = SDL_CreateWindow(title, w, h, (flags | SDL_WINDOW_BORDERLESS | SDL_WINDOW_HIDDEN) & (~SDL_WINDOW_FULLSCREEN) & (~SDL_WINDOW_RESIZABLE)); - if (result != NULL) { + if (result) { if (SDL_GetVideoDevice()->shape_driver.CreateShaper == NULL) { SDL_DestroyWindow(result); return NULL; } result->shaper = SDL_GetVideoDevice()->shape_driver.CreateShaper(result); - if (result->shaper != NULL) { + if (result->shaper) { result->shaper->mode.mode = ShapeModeDefault; result->shaper->mode.parameters.binarizationCutoff = 1; result->shaper->hasshape = SDL_FALSE; @@ -113,7 +113,7 @@ static SDL_ShapeTree *RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode, SD SDL_ShapeTree *result = (SDL_ShapeTree *)SDL_malloc(sizeof(SDL_ShapeTree)); SDL_Rect next = { 0, 0, 0, 0 }; - if (result == NULL) { + if (!result) { SDL_OutOfMemory(); return NULL; } @@ -200,7 +200,7 @@ SDL_ShapeTree *SDL_CalculateShapeTree(SDL_WindowShapeMode mode, SDL_Surface *sha void SDL_TraverseShapeTree(SDL_ShapeTree *tree, SDL_TraversalFunction function, void *closure) { - SDL_assert(tree != NULL); + SDL_assert(tree); if (tree->kind == QuadShape) { SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.upleft, function, closure); SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.upright, function, closure); @@ -228,16 +228,16 @@ int SDL_SetWindowShape(SDL_Window *window, SDL_Surface *shape, SDL_WindowShapeMo SDL_VideoDevice *_this = SDL_GetVideoDevice(); int result; - if (window == NULL || !SDL_IsShapedWindow(window)) { + if (!window || !SDL_IsShapedWindow(window)) { /* The window given was not a shapeable window. */ return SDL_NONSHAPEABLE_WINDOW; } - if (shape == NULL) { + if (!shape) { /* Invalid shape argument. */ return SDL_INVALID_SHAPE_ARGUMENT; } - if (shape_mode != NULL) { + if (shape_mode) { window->shaper->mode = *shape_mode; } result = _this->shape_driver.SetWindowShape(window->shaper, shape, shape_mode); @@ -250,7 +250,7 @@ int SDL_SetWindowShape(SDL_Window *window, SDL_Surface *shape, SDL_WindowShapeMo static SDL_bool SDL_WindowHasAShape(SDL_Window *window) { - if (window == NULL || !SDL_IsShapedWindow(window)) { + if (!window || !SDL_IsShapedWindow(window)) { return SDL_FALSE; } return window->shaper->hasshape; @@ -258,8 +258,8 @@ static SDL_bool SDL_WindowHasAShape(SDL_Window *window) int SDL_GetShapedWindowMode(SDL_Window *window, SDL_WindowShapeMode *shape_mode) { - if (window != NULL && SDL_IsShapedWindow(window)) { - if (shape_mode == NULL) { + if (window && SDL_IsShapedWindow(window)) { + if (!shape_mode) { if (SDL_WindowHasAShape(window)) { return 0; /* The window given has a shape. */ } else { diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index 00e747fcb..bc71c5413 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -142,7 +142,7 @@ SDL_Surface *SDL_CreateSurface(int width, int height, Uint32 format) /* Allocate the surface */ surface = (SDL_Surface *)SDL_calloc(1, sizeof(*surface)); - if (surface == NULL) { + if (!surface) { SDL_OutOfMemory(); return NULL; } @@ -160,7 +160,7 @@ SDL_Surface *SDL_CreateSurface(int width, int height, Uint32 format) if (SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) { SDL_Palette *palette = SDL_CreatePalette((1 << surface->format->BitsPerPixel)); - if (palette == NULL) { + if (!palette) { SDL_DestroySurface(surface); return NULL; } @@ -225,7 +225,7 @@ SDL_Surface *SDL_CreateSurfaceFrom(void *pixels, int width, int height, int pitc return NULL; } - if (pitch == 0 && pixels == NULL) { + if (pitch == 0 && !pixels) { /* The application will fill these in later with valid values */ } else { size_t minimalPitch; @@ -243,7 +243,7 @@ SDL_Surface *SDL_CreateSurfaceFrom(void *pixels, int width, int height, int pitc } surface = SDL_CreateSurface(0, 0, format); - if (surface != NULL) { + if (surface) { surface->flags |= SDL_PREALLOC; surface->pixels = pixels; surface->w = width; @@ -256,7 +256,7 @@ SDL_Surface *SDL_CreateSurfaceFrom(void *pixels, int width, int height, int pitc SDL_PropertiesID SDL_GetSurfaceProperties(SDL_Surface *surface) { - if (surface == NULL) { + if (!surface) { SDL_InvalidParamError("surface"); return 0; } @@ -269,7 +269,7 @@ SDL_PropertiesID SDL_GetSurfaceProperties(SDL_Surface *surface) int SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette) { - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("surface"); } if (SDL_SetPixelFormatPalette(surface->format, palette) < 0) { @@ -284,7 +284,7 @@ int SDL_SetSurfaceRLE(SDL_Surface *surface, int flag) { int flags; - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("surface"); } @@ -302,7 +302,7 @@ int SDL_SetSurfaceRLE(SDL_Surface *surface, int flag) SDL_bool SDL_SurfaceHasRLE(SDL_Surface *surface) { - if (surface == NULL) { + if (!surface) { return SDL_FALSE; } @@ -317,7 +317,7 @@ int SDL_SetSurfaceColorKey(SDL_Surface *surface, int flag, Uint32 key) { int flags; - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("surface"); } @@ -345,7 +345,7 @@ int SDL_SetSurfaceColorKey(SDL_Surface *surface, int flag, Uint32 key) SDL_bool SDL_SurfaceHasColorKey(SDL_Surface *surface) { - if (surface == NULL) { + if (!surface) { return SDL_FALSE; } @@ -358,7 +358,7 @@ SDL_bool SDL_SurfaceHasColorKey(SDL_Surface *surface) int SDL_GetSurfaceColorKey(SDL_Surface *surface, Uint32 *key) { - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("surface"); } @@ -378,7 +378,7 @@ static void SDL_ConvertColorkeyToAlpha(SDL_Surface *surface, SDL_bool ignore_alp { int x, y, bpp; - if (surface == NULL) { + if (!surface) { return; } @@ -467,7 +467,7 @@ int SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b) { int flags; - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("surface"); } @@ -489,7 +489,7 @@ int SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b) int SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b) { - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("surface"); } @@ -509,7 +509,7 @@ int SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha) { int flags; - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("surface"); } @@ -529,7 +529,7 @@ int SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha) int SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 *alpha) { - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("surface"); } @@ -543,7 +543,7 @@ int SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode) { int flags, status; - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("surface"); } @@ -580,11 +580,11 @@ int SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode) int SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode) { - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("surface"); } - if (blendMode == NULL) { + if (!blendMode) { return 0; } @@ -613,7 +613,7 @@ SDL_bool SDL_SetSurfaceClipRect(SDL_Surface *surface, const SDL_Rect *rect) SDL_Rect full_rect; /* Don't do anything if there's no surface to act on */ - if (surface == NULL) { + if (!surface) { return SDL_FALSE; } @@ -624,7 +624,7 @@ SDL_bool SDL_SetSurfaceClipRect(SDL_Surface *surface, const SDL_Rect *rect) full_rect.h = surface->h; /* Set the clipping rectangle */ - if (rect == NULL) { + if (!rect) { surface->clip_rect = full_rect; return SDL_TRUE; } @@ -682,7 +682,7 @@ int SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, int srcx, srcy, w, h; /* Make sure the surfaces aren't locked */ - if (src == NULL || dst == NULL) { + if (!src || !dst) { return SDL_InvalidParamError("SDL_BlitSurface(): src/dst"); } if (src->locked || dst->locked) { @@ -690,7 +690,7 @@ int SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect, } /* If the destination rectangle is NULL, use the entire dest surface */ - if (dstrect == NULL) { + if (!dstrect) { fulldst.x = fulldst.y = 0; fulldst.w = dst->w; fulldst.h = dst->h; @@ -794,14 +794,14 @@ int SDL_PrivateBlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, int dst_w, dst_h; /* Make sure the surfaces aren't locked */ - if (src == NULL || dst == NULL) { + if (!src || !dst) { return SDL_InvalidParamError("SDL_BlitSurfaceScaled(): src/dst"); } if (src->locked || dst->locked) { return SDL_SetError("Surfaces must not be locked during blit"); } - if (srcrect == NULL) { + if (!srcrect) { src_w = src->w; src_h = src->h; } else { @@ -809,7 +809,7 @@ int SDL_PrivateBlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, src_h = srcrect->h; } - if (dstrect == NULL) { + if (!dstrect) { dst_w = dst->w; dst_h = dst->h; } else { @@ -825,7 +825,7 @@ int SDL_PrivateBlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, scaling_w = (double)dst_w / src_w; scaling_h = (double)dst_h / src_h; - if (dstrect == NULL) { + if (!dstrect) { dst_x0 = 0; dst_y0 = 0; dst_x1 = dst_w; @@ -837,7 +837,7 @@ int SDL_PrivateBlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect, dst_y1 = dst_y0 + dst_h; } - if (srcrect == NULL) { + if (!srcrect) { src_x0 = 0; src_y0 = 0; src_x1 = src_w; @@ -1120,17 +1120,17 @@ SDL_Surface *SDL_ConvertSurface(SDL_Surface *surface, const SDL_PixelFormat *for Uint8 *palette_saved_alpha = NULL; int palette_saved_alpha_ncolors = 0; - if (surface == NULL) { + if (!surface) { SDL_InvalidParamError("surface"); return NULL; } - if (format == NULL) { + if (!format) { SDL_InvalidParamError("format"); return NULL; } /* Check for empty destination palette! (results in empty image) */ - if (format->palette != NULL) { + if (format->palette) { int i; for (i = 0; i < format->palette->ncolors; ++i) { if ((format->palette->colors[i].r != 0xFF) || (format->palette->colors[i].g != 0xFF) || (format->palette->colors[i].b != 0xFF)) { @@ -1145,7 +1145,7 @@ SDL_Surface *SDL_ConvertSurface(SDL_Surface *surface, const SDL_PixelFormat *for /* Create a new surface with the desired format */ convert = SDL_CreateSurface(surface->w, surface->h, format->format); - if (convert == NULL) { + if (!convert) { return NULL; } @@ -1303,7 +1303,7 @@ SDL_Surface *SDL_ConvertSurface(SDL_Surface *surface, const SDL_PixelFormat *for /* Create a dummy surface to get the colorkey converted */ tmp = SDL_CreateSurface(1, 1, surface->format->format); - if (tmp == NULL) { + if (!tmp) { SDL_DestroySurface(convert); return NULL; } @@ -1319,7 +1319,7 @@ SDL_Surface *SDL_ConvertSurface(SDL_Surface *surface, const SDL_PixelFormat *for /* Conversion of the colorkey */ tmp2 = SDL_ConvertSurface(tmp, format); - if (tmp2 == NULL) { + if (!tmp2) { SDL_DestroySurface(tmp); SDL_DestroySurface(convert); return NULL; @@ -1425,13 +1425,13 @@ int SDL_ConvertPixels(int width, int height, void *nonconst_src = (void *)src; int ret; - if (src == NULL) { + if (!src) { return SDL_InvalidParamError("src"); } if (!src_pitch) { return SDL_InvalidParamError("src_pitch"); } - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("dst"); } if (!dst_pitch) { @@ -1507,13 +1507,13 @@ int SDL_PremultiplyAlpha(int width, int height, Uint32 dstpixel; Uint32 dstR, dstG, dstB, dstA; - if (src == NULL) { + if (!src) { return SDL_InvalidParamError("src"); } if (!src_pitch) { return SDL_InvalidParamError("src_pitch"); } - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("dst"); } if (!dst_pitch) { @@ -1555,7 +1555,7 @@ int SDL_PremultiplyAlpha(int width, int height, */ void SDL_DestroySurface(SDL_Surface *surface) { - if (surface == NULL) { + if (!surface) { return; } if (surface->flags & SDL_DONTFREE) { diff --git a/src/video/SDL_surface_pixel_impl.h b/src/video/SDL_surface_pixel_impl.h index 43985b78b..94f107361 100644 --- a/src/video/SDL_surface_pixel_impl.h +++ b/src/video/SDL_surface_pixel_impl.h @@ -29,7 +29,7 @@ static int SDL_ReadSurfacePixel_impl(SDL_Surface *surface, int x, int y, Uint8 * size_t bytes_per_pixel; void *p; - if (surface == NULL || surface->format == NULL || surface->pixels == NULL) { + if (!surface || !surface->format || !surface->pixels) { return SDL_InvalidParamError("surface"); } @@ -41,19 +41,19 @@ static int SDL_ReadSurfacePixel_impl(SDL_Surface *surface, int x, int y, Uint8 * return SDL_InvalidParamError("y"); } - if (r == NULL) { + if (!r) { return SDL_InvalidParamError("r"); } - if (g == NULL) { + if (!g) { return SDL_InvalidParamError("g"); } - if (b == NULL) { + if (!b) { return SDL_InvalidParamError("b"); } - if (a == NULL) { + if (!a) { return SDL_InvalidParamError("a"); } diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index d4ab9a475..591e0277c 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -196,12 +196,12 @@ typedef struct static Uint32 SDL_DefaultGraphicsBackends(SDL_VideoDevice *_this) { #if (defined(SDL_VIDEO_OPENGL) && defined(__MACOS__)) || (defined(__IOS__) && !TARGET_OS_MACCATALYST) || defined(__ANDROID__) - if (_this->GL_CreateContext != NULL) { + if (_this->GL_CreateContext) { return SDL_WINDOW_OPENGL; } #endif #if defined(SDL_VIDEO_METAL) && (TARGET_OS_MACCATALYST || defined(__MACOS__) || defined(__IOS__)) - if (_this->Metal_CreateView != NULL) { + if (_this->Metal_CreateView) { return SDL_WINDOW_METAL; } #endif @@ -233,7 +233,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U SDL_GetWindowSizeInPixels(window, &w, &h); - if (data == NULL) { + if (!data) { SDL_Renderer *renderer = NULL; const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION); const SDL_bool specific_accelerated_renderer = (hint && *hint != '0' && *hint != '1' && @@ -244,7 +244,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U /* Check to see if there's a specific driver requested */ if (specific_accelerated_renderer) { renderer = SDL_CreateRenderer(window, hint, 0); - if (renderer == NULL || (SDL_GetRendererInfo(renderer, &info) == -1)) { + if (!renderer || (SDL_GetRendererInfo(renderer, &info) == -1)) { if (renderer) { SDL_DestroyRenderer(renderer); } @@ -266,16 +266,16 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U } } } - if (renderer == NULL) { + if (!renderer) { return SDL_SetError("No hardware accelerated renderers available"); } } - SDL_assert(renderer != NULL); /* should have explicitly checked this above. */ + SDL_assert(renderer); /* should have explicitly checked this above. */ /* Create the data after we successfully create the renderer (bug #1116) */ data = (SDL_WindowTextureData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { SDL_DestroyRenderer(renderer); return SDL_OutOfMemory(); } @@ -350,7 +350,7 @@ static int SDL_UpdateWindowTexture(SDL_VideoDevice *unused, SDL_Window *window, SDL_GetWindowSizeInPixels(window, &w, &h); data = SDL_GetProperty(SDL_GetWindowProperties(window), SDL_WINDOWTEXTUREDATA); - if (data == NULL || !data->texture) { + if (!data || !data->texture) { return SDL_SetError("No window texture data"); } @@ -382,10 +382,10 @@ int SDL_SetWindowTextureVSync(SDL_Window *window, int vsync) SDL_WindowTextureData *data; data = SDL_GetProperty(SDL_GetWindowProperties(window), SDL_WINDOWTEXTUREDATA); - if (data == NULL) { + if (!data) { return -1; } - if (data->renderer == NULL ) { + if (!data->renderer) { return -1; } return SDL_SetRenderVSync(data->renderer, vsync); @@ -448,7 +448,7 @@ int SDL_VideoInit(const char *driver_name) int i = 0; /* Check to make sure we don't overwrite '_this' */ - if (_this != NULL) { + if (_this) { SDL_VideoQuit(); } @@ -480,14 +480,14 @@ int SDL_VideoInit(const char *driver_name) /* Select the proper video driver */ video = NULL; - if (driver_name == NULL) { + if (!driver_name) { driver_name = SDL_GetHint(SDL_HINT_VIDEO_DRIVER); } - if (driver_name != NULL && *driver_name != 0) { + if (driver_name && *driver_name != 0) { const char *driver_attempt = driver_name; - while (driver_attempt != NULL && *driver_attempt != 0 && video == NULL) { + while (driver_attempt && *driver_attempt != 0 && !video) { const char *driver_attempt_end = SDL_strchr(driver_attempt, ','); - size_t driver_attempt_len = (driver_attempt_end != NULL) ? (driver_attempt_end - driver_attempt) + size_t driver_attempt_len = (driver_attempt_end) ? (driver_attempt_end - driver_attempt) : SDL_strlen(driver_attempt); for (i = 0; bootstrap[i]; ++i) { @@ -498,17 +498,17 @@ int SDL_VideoInit(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; bootstrap[i]; ++i) { video = bootstrap[i]->create(); - if (video != NULL) { + if (video) { break; } } } - if (video == NULL) { + if (!video) { if (driver_name) { SDL_SetError("%s not available", driver_name); goto pre_driver_error; @@ -570,7 +570,7 @@ int SDL_VideoInit(const char *driver_name) return 0; pre_driver_error: - SDL_assert(_this == NULL); + SDL_assert(!_this); if (init_video_capture) { SDL_QuitVideoCapture(); } @@ -591,7 +591,7 @@ pre_driver_error: const char *SDL_GetCurrentVideoDriver(void) { - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return NULL; } @@ -855,7 +855,7 @@ int SDL_GetDisplayBounds(SDL_DisplayID displayID, SDL_Rect *rect) CHECK_DISPLAY_MAGIC(display, -1); - if (rect == NULL) { + if (!rect) { return SDL_InvalidParamError("rect"); } @@ -890,7 +890,7 @@ int SDL_GetDisplayUsableBounds(SDL_DisplayID displayID, SDL_Rect *rect) CHECK_DISPLAY_MAGIC(display, -1); - if (rect == NULL) { + if (!rect) { return SDL_InvalidParamError("rect"); } @@ -1032,7 +1032,7 @@ SDL_bool SDL_AddFullscreenDisplayMode(SDL_VideoDisplay *display, const SDL_Displ /* Go ahead and add the new mode */ if (nmodes == display->max_fullscreen_modes) { modes = (SDL_DisplayMode *)SDL_malloc((display->max_fullscreen_modes + 32) * sizeof(*modes)); - if (modes == NULL) { + if (!modes) { return SDL_FALSE; } @@ -1312,7 +1312,7 @@ void SDL_RelativeToGlobalForWindow(SDL_Window *window, int rel_x, int rel_y, int if (SDL_WINDOW_IS_POPUP(window)) { /* Calculate the total offset of the popup from the parents */ - for (w = window->parent; w != NULL; w = w->parent) { + for (w = window->parent; w; w = w->parent) { rel_x += w->x; rel_y += w->y; } @@ -1332,7 +1332,7 @@ void SDL_GlobalToRelativeForWindow(SDL_Window *window, int abs_x, int abs_y, int if (SDL_WINDOW_IS_POPUP(window)) { /* Convert absolute window coordinates to relative for a popup */ - for (w = window->parent; w != NULL; w = w->parent) { + for (w = window->parent; w; w = w->parent) { abs_x -= w->x; abs_y -= w->y; } @@ -1522,7 +1522,7 @@ static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen) if (fullscreen) { mode = (SDL_DisplayMode *)SDL_GetWindowFullscreenMode(window); - if (mode != NULL) { + if (mode) { window->fullscreen_exclusive = SDL_TRUE; } else { /* Make sure the current mode is zeroed for fullscreen desktop. */ @@ -1851,14 +1851,14 @@ static SDL_Window *SDL_CreateWindowInternal(const char *title, int x, int y, int SDL_bool undefined_x = SDL_FALSE; SDL_bool undefined_y = SDL_FALSE; - if (_this == NULL) { + if (!_this) { /* Initialize the video system if needed */ if (SDL_Init(SDL_INIT_VIDEO) < 0) { return NULL; } /* Make clang-tidy happy */ - if (_this == NULL) { + if (!_this) { return NULL; } } @@ -1967,7 +1967,7 @@ static SDL_Window *SDL_CreateWindowInternal(const char *title, int x, int y, int } window = (SDL_Window *)SDL_calloc(1, sizeof(*window)); - if (window == NULL) { + if (!window) { SDL_OutOfMemory(); return NULL; } @@ -2067,7 +2067,7 @@ SDL_Window *SDL_CreateWindowWithPosition(const char *title, int x, int y, int w, SDL_Window *SDL_CreatePopupWindow(SDL_Window *parent, int offset_x, int offset_y, int w, int h, Uint32 flags) { - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return NULL; } @@ -2097,7 +2097,7 @@ SDL_Window *SDL_CreateWindowFrom(const void *data) SDL_Window *window; Uint32 flags = SDL_WINDOW_FOREIGN; - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return NULL; } @@ -2133,7 +2133,7 @@ SDL_Window *SDL_CreateWindowFrom(const void *data) } window = (SDL_Window *)SDL_calloc(1, sizeof(*window)); - if (window == NULL) { + if (!window) { SDL_OutOfMemory(); return NULL; } @@ -2297,7 +2297,7 @@ int SDL_RecreateWindow(SDL_Window *window, Uint32 flags) SDL_bool SDL_HasWindows(void) { - return _this && _this->windows != NULL; + return _this && _this->windows; } SDL_WindowID SDL_GetWindowID(SDL_Window *window) @@ -2311,7 +2311,7 @@ SDL_Window *SDL_GetWindowFromID(SDL_WindowID id) { SDL_Window *window; - if (_this == NULL) { + if (!_this) { return NULL; } for (window = _this->windows; window; window = window->next) { @@ -2375,7 +2375,7 @@ int SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon) { CHECK_WINDOW_MAGIC(window, -1); - if (icon == NULL) { + if (!icon) { return SDL_InvalidParamError("icon"); } @@ -2614,16 +2614,16 @@ int SDL_GetWindowBordersSize(SDL_Window *window, int *top, int *left, int *botto { int dummy = 0; - if (top == NULL) { + if (!top) { top = &dummy; } - if (left == NULL) { + if (!left) { left = &dummy; } - if (right == NULL) { + if (!right) { right = &dummy; } - if (bottom == NULL) { + if (!bottom) { bottom = &dummy; } @@ -2645,11 +2645,11 @@ int SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h) CHECK_WINDOW_MAGIC(window, -1); - if (w == NULL) { + if (!w) { w = &filter; } - if (h == NULL) { + if (!h) { h = &filter; } @@ -2791,7 +2791,7 @@ int SDL_ShowWindow(SDL_Window *window) window->pending_flags = 0; /* Restore child windows */ - for (child = window->first_child; child != NULL; child = child->next_sibling) { + for (child = window->first_child; child; child = child->next_sibling) { if (!child->restore_on_show && (child->flags & SDL_WINDOW_HIDDEN)) { break; } @@ -2812,7 +2812,7 @@ int SDL_HideWindow(SDL_Window *window) } /* Hide all child windows */ - for (child = window->first_child; child != NULL; child = child->next_sibling) { + for (child = window->first_child; child; child = child->next_sibling) { if (child->flags & SDL_WINDOW_HIDDEN) { break; } @@ -2995,7 +2995,7 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window) #ifdef __LINUX__ /* On WSL, direct X11 is faster than using OpenGL for window framebuffers, so try to detect WSL and avoid texture framebuffer. */ - else if ((_this->CreateWindowFramebuffer != NULL) && (SDL_strcmp(_this->name, "x11") == 0)) { + else if ((_this->CreateWindowFramebuffer) && (SDL_strcmp(_this->name, "x11") == 0)) { struct stat sb; if ((stat("/proc/sys/fs/binfmt_misc/WSLInterop", &sb) == 0) || (stat("/run/WSL", &sb) == 0)) { /* if either of these exist, we're on WSL. */ attempt_texture_framebuffer = SDL_FALSE; @@ -3003,7 +3003,7 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window) } #endif #if defined(__WIN32__) || defined(__WINGDK__) /* GDI BitBlt() is way faster than Direct3D dynamic textures right now. (!!! FIXME: is this still true?) */ - else if ((_this->CreateWindowFramebuffer != NULL) && (SDL_strcmp(_this->name, "windows") == 0)) { + else if ((_this->CreateWindowFramebuffer) && (SDL_strcmp(_this->name, "windows") == 0)) { attempt_texture_framebuffer = SDL_FALSE; } #endif @@ -3510,7 +3510,7 @@ static SDL_bool SDL_ShouldMinimizeOnFocusLoss(SDL_Window *window) /* Real fullscreen windows should minimize on focus loss so the desktop video mode is restored */ hint = SDL_GetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS); - if (hint == NULL || !*hint || SDL_strcasecmp(hint, "auto") == 0) { + if (!hint || !*hint || SDL_strcasecmp(hint, "auto") == 0) { if (window->fullscreen_exclusive && !ModeSwitchingEmulated(_this)) { return SDL_TRUE; } else { @@ -3643,7 +3643,7 @@ void SDL_DestroyWindow(SDL_Window *window) SDL_bool SDL_ScreenSaverEnabled(void) { - if (_this == NULL) { + if (!_this) { return SDL_TRUE; } return !_this->suspend_screensaver; @@ -3651,7 +3651,7 @@ SDL_bool SDL_ScreenSaverEnabled(void) int SDL_EnableScreenSaver(void) { - if (_this == NULL) { + if (!_this) { return 0; } if (!_this->suspend_screensaver) { @@ -3667,7 +3667,7 @@ int SDL_EnableScreenSaver(void) int SDL_DisableScreenSaver(void) { - if (_this == NULL) { + if (!_this) { return 0; } if (_this->suspend_screensaver) { @@ -3685,7 +3685,7 @@ void SDL_VideoQuit(void) { int i; - if (_this == NULL) { + if (!_this) { return; } @@ -3728,7 +3728,7 @@ int SDL_GL_LoadLibrary(const char *path) { int retval; - if (_this == NULL) { + if (!_this) { return SDL_UninitializedVideo(); } if (_this->gl_config.driver_loaded) { @@ -3756,7 +3756,7 @@ SDL_FunctionPointer SDL_GL_GetProcAddress(const char *proc) { SDL_FunctionPointer func; - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return NULL; } @@ -3799,7 +3799,7 @@ SDL_FunctionPointer SDL_EGL_GetProcAddress(const char *proc) void SDL_GL_UnloadLibrary(void) { - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return; } @@ -3849,7 +3849,7 @@ SDL_bool SDL_GL_ExtensionSupported(const char *extension) /* Lookup the available extensions */ glGetStringFunc = (PFNGLGETSTRINGPROC)SDL_GL_GetProcAddress("glGetString"); - if (glGetStringFunc == NULL) { + if (!glGetStringFunc) { return SDL_FALSE; } @@ -3861,7 +3861,7 @@ SDL_bool SDL_GL_ExtensionSupported(const char *extension) glGetStringiFunc = (PFNGLGETSTRINGIPROC)SDL_GL_GetProcAddress("glGetStringi"); glGetIntegervFunc = (PFNGLGETINTEGERVPROC)SDL_GL_GetProcAddress("glGetIntegerv"); - if ((glGetStringiFunc == NULL) || (glGetIntegervFunc == NULL)) { + if ((!glGetStringiFunc) || (!glGetIntegervFunc)) { return SDL_FALSE; } @@ -3882,7 +3882,7 @@ SDL_bool SDL_GL_ExtensionSupported(const char *extension) /* Try the old way with glGetString(GL_EXTENSIONS) ... */ extensions = (const char *)glGetStringFunc(GL_EXTENSIONS); - if (extensions == NULL) { + if (!extensions) { return SDL_FALSE; } /* @@ -3894,7 +3894,7 @@ SDL_bool SDL_GL_ExtensionSupported(const char *extension) for (;;) { where = SDL_strstr(start, extension); - if (where == NULL) { + if (!where) { break; } @@ -3957,7 +3957,7 @@ void SDL_EGL_SetEGLAttributeCallbacks(SDL_EGLAttribArrayCallback platformAttribC void SDL_GL_ResetAttributes(void) { - if (_this == NULL) { + if (!_this) { return; } @@ -4020,7 +4020,7 @@ int SDL_GL_SetAttribute(SDL_GLattr attr, int value) #if defined(SDL_VIDEO_OPENGL) || defined(SDL_VIDEO_OPENGL_ES) || defined(SDL_VIDEO_OPENGL_ES2) int retval; - if (_this == NULL) { + if (!_this) { return SDL_UninitializedVideo(); } retval = 0; @@ -4153,14 +4153,14 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) GLenum attachmentattrib = 0; #endif - if (value == NULL) { + if (!value) { return SDL_InvalidParamError("value"); } /* Clear value in any case */ *value = 0; - if (_this == NULL) { + if (!_this) { return SDL_UninitializedVideo(); } @@ -4331,7 +4331,7 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) #ifdef SDL_VIDEO_OPENGL glGetStringFunc = (PFNGLGETSTRINGPROC)SDL_GL_GetProcAddress("glGetString"); - if (glGetStringFunc == NULL) { + if (!glGetStringFunc) { return -1; } @@ -4368,7 +4368,7 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) } glGetErrorFunc = (PFNGLGETERRORPROC)SDL_GL_GetProcAddress("glGetError"); - if (glGetErrorFunc == NULL) { + if (!glGetErrorFunc) { return -1; } @@ -4415,7 +4415,7 @@ int SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext context) { int retval; - if (_this == NULL) { + if (!_this) { return SDL_UninitializedVideo(); } @@ -4449,7 +4449,7 @@ int SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext context) SDL_Window *SDL_GL_GetCurrentWindow(void) { - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return NULL; } @@ -4458,7 +4458,7 @@ SDL_Window *SDL_GL_GetCurrentWindow(void) SDL_GLContext SDL_GL_GetCurrentContext(void) { - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return NULL; } @@ -4524,7 +4524,7 @@ SDL_EGLConfig SDL_EGL_GetWindowEGLSurface(SDL_Window *window) int SDL_GL_SetSwapInterval(int interval) { - if (_this == NULL) { + if (!_this) { return SDL_UninitializedVideo(); } else if (SDL_GL_GetCurrentContext() == NULL) { return SDL_SetError("No OpenGL context has been made current"); @@ -4537,13 +4537,13 @@ int SDL_GL_SetSwapInterval(int interval) int SDL_GL_GetSwapInterval(int *interval) { - if (interval == NULL) { + if (!interval) { return SDL_InvalidParamError("interval"); } *interval = 0; - if (_this == NULL) { + if (!_this) { return SDL_SetError("no video driver");; } else if (SDL_GL_GetCurrentContext() == NULL) { return SDL_SetError("no current context");; @@ -4571,7 +4571,7 @@ int SDL_GL_SwapWindow(SDL_Window *window) int SDL_GL_DeleteContext(SDL_GLContext context) { - if (_this == NULL) { + if (!_this) { return SDL_UninitializedVideo(); \ } if (!context) { @@ -4749,7 +4749,7 @@ void SDL_StopTextInput(void) int SDL_SetTextInputRect(const SDL_Rect *rect) { - if (rect == NULL) { + if (!rect) { return SDL_InvalidParamError("rect"); } @@ -4820,7 +4820,7 @@ int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) SDL_Window *current_window; SDL_MessageBoxData mbdata; - if (messageboxdata == NULL) { + if (!messageboxdata) { return SDL_InvalidParamError("messageboxdata"); } else if (messageboxdata->numbuttons < 0) { return SDL_SetError("Invalid number of buttons"); @@ -4836,7 +4836,7 @@ int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) SDL_ShowCursor(); SDL_ResetKeyboard(); - if (buttonid == NULL) { + if (!buttonid) { buttonid = &dummybutton; } @@ -4948,10 +4948,10 @@ int SDL_ShowSimpleMessageBox(Uint32 flags, const char *title, const char *messag /* Web browsers don't (currently) have an API for a custom message box that can block, but for the most common case (SDL_ShowSimpleMessageBox), we can use the standard Javascript alert() function. */ - if (title == NULL) { + if (!title) { title = ""; } - if (message == NULL) { + if (!message) { message = ""; } EM_ASM({ @@ -5031,7 +5031,7 @@ void SDL_OnApplicationWillResignActive(void) { if (_this) { SDL_Window *window; - for (window = _this->windows; window != NULL; window = window->next) { + for (window = _this->windows; window; window = window->next) { SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_MINIMIZED, 0, 0); } SDL_SetKeyboardFocus(NULL); @@ -5055,7 +5055,7 @@ void SDL_OnApplicationDidBecomeActive(void) if (_this) { SDL_Window *window; - for (window = _this->windows; window != NULL; window = window->next) { + for (window = _this->windows; window; window = window->next) { SDL_SetKeyboardFocus(window); SDL_SendWindowEvent(window, SDL_EVENT_WINDOW_RESTORED, 0, 0); } @@ -5067,7 +5067,7 @@ void SDL_OnApplicationDidBecomeActive(void) int SDL_Vulkan_LoadLibrary(const char *path) { int retval; - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return -1; } @@ -5090,7 +5090,7 @@ int SDL_Vulkan_LoadLibrary(const char *path) SDL_FunctionPointer SDL_Vulkan_GetVkGetInstanceProcAddr(void) { - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return NULL; } @@ -5103,7 +5103,7 @@ SDL_FunctionPointer SDL_Vulkan_GetVkGetInstanceProcAddr(void) void SDL_Vulkan_UnloadLibrary(void) { - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return; } @@ -5139,7 +5139,7 @@ SDL_bool SDL_Vulkan_CreateSurface(SDL_Window *window, return SDL_FALSE; } - if (surface == NULL) { + if (!surface) { SDL_InvalidParamError("surface"); return SDL_FALSE; } diff --git a/src/video/SDL_vulkan_utils.c b/src/video/SDL_vulkan_utils.c index e44275a9c..a16908a9d 100644 --- a/src/video/SDL_vulkan_utils.c +++ b/src/video/SDL_vulkan_utils.c @@ -148,7 +148,7 @@ VkExtensionProperties *SDL_Vulkan_CreateInstanceExtensionsList( retval = SDL_calloc(count, sizeof(VkExtensionProperties)); } - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); return NULL; } @@ -211,7 +211,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, goto error; } chosenDisplayId = SDL_getenv("SDL_VULKAN_DISPLAY"); - if (chosenDisplayId != NULL) { + if (chosenDisplayId) { displayId = SDL_atoi(chosenDisplayId); } @@ -228,7 +228,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, } physicalDevices = SDL_malloc(sizeof(VkPhysicalDevice) * physicalDeviceCount); - if (physicalDevices == NULL) { + if (!physicalDevices) { SDL_OutOfMemory(); goto error; } @@ -271,7 +271,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, } displayProperties = SDL_malloc(sizeof(VkDisplayPropertiesKHR) * displayPropertiesCount); - if (displayProperties == NULL) { + if (!displayProperties) { SDL_OutOfMemory(); goto error; } @@ -300,7 +300,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of display modes: %u", displayModePropertiesCount); displayModeProperties = SDL_malloc(sizeof(VkDisplayModePropertiesKHR) * displayModePropertiesCount); - if (displayModeProperties == NULL) { + if (!displayModeProperties) { SDL_OutOfMemory(); goto error; } @@ -347,7 +347,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of display planes: %u", displayPlanePropertiesCount); displayPlaneProperties = SDL_malloc(sizeof(VkDisplayPlanePropertiesKHR) * displayPlanePropertiesCount); - if (displayPlaneProperties == NULL) { + if (!displayPlaneProperties) { SDL_OutOfMemory(); goto error; } @@ -378,7 +378,7 @@ SDL_bool SDL_Vulkan_Display_CreateSurface(void *vkGetInstanceProcAddr_, SDL_LogDebug(SDL_LOG_CATEGORY_VIDEO, "vulkandisplay: Number of supported displays for plane %u: %u", i, planeSupportedDisplaysCount); planeSupportedDisplays = SDL_malloc(sizeof(VkDisplayKHR) * planeSupportedDisplaysCount); - if (planeSupportedDisplays == NULL) { + if (!planeSupportedDisplays) { SDL_free(displayPlaneProperties); SDL_OutOfMemory(); goto error; diff --git a/src/video/SDL_yuv.c b/src/video/SDL_yuv.c index 151ef95e9..6eb248bb6 100644 --- a/src/video/SDL_yuv.c +++ b/src/video/SDL_yuv.c @@ -615,7 +615,7 @@ int SDL_ConvertPixels_YUV_to_RGB(int width, int height, int tmp_pitch = (width * sizeof(Uint32)); tmp = SDL_malloc((size_t)tmp_pitch * height); - if (tmp == NULL) { + if (!tmp) { return SDL_OutOfMemory(); } @@ -996,7 +996,7 @@ int SDL_ConvertPixels_RGB_to_YUV(int width, int height, int tmp_pitch = (width * sizeof(Uint32)); tmp = SDL_malloc((size_t)tmp_pitch * height); - if (tmp == NULL) { + if (!tmp) { return SDL_OutOfMemory(); } @@ -1085,7 +1085,7 @@ static int SDL_ConvertPixels_SwapUVPlanes(int width, int height, const void *src /* Allocate a temporary row for the swap */ tmp = (Uint8 *)SDL_malloc(UVwidth); - if (tmp == NULL) { + if (!tmp) { return SDL_OutOfMemory(); } for (y = 0; y < UVheight; ++y) { @@ -1321,7 +1321,7 @@ static int SDL_ConvertPixels_PackUVPlanes_to_NV_std(int width, int height, const if (src == dst) { /* Need to make a copy of the buffer so we don't clobber it while converting */ tmp = (Uint8 *)SDL_malloc((size_t)2 * UVheight * srcUVPitch); - if (tmp == NULL) { + if (!tmp) { return SDL_OutOfMemory(); } SDL_memcpy(tmp, src, (size_t)2 * UVheight * srcUVPitch); @@ -1375,7 +1375,7 @@ static int SDL_ConvertPixels_SplitNV_to_UVPlanes_std(int width, int height, cons if (src == dst) { /* Need to make a copy of the buffer so we don't clobber it while converting */ tmp = (Uint8 *)SDL_malloc((size_t)UVheight * srcUVPitch); - if (tmp == NULL) { + if (!tmp) { return SDL_OutOfMemory(); } SDL_memcpy(tmp, src, (size_t)UVheight * srcUVPitch); diff --git a/src/video/android/SDL_androidmouse.c b/src/video/android/SDL_androidmouse.c index 3e38d85b1..bc97260b1 100644 --- a/src/video/android/SDL_androidmouse.c +++ b/src/video/android/SDL_androidmouse.c @@ -88,7 +88,7 @@ static SDL_Cursor *Android_CreateCursor(SDL_Surface *surface, int hot_x, int hot SDL_Surface *converted; converted = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888); - if (converted == NULL) { + if (!converted) { return NULL; } custom_cursor = Android_JNI_CreateCustomCursor(converted, hot_x, hot_y); @@ -117,7 +117,7 @@ static void Android_FreeCursor(SDL_Cursor *cursor) static SDL_Cursor *Android_CreateEmptyCursor() { - if (empty_cursor == NULL) { + if (!empty_cursor) { SDL_Surface *empty_surface = SDL_CreateSurface(1, 1, SDL_PIXELFORMAT_ARGB8888); if (empty_surface) { SDL_memset(empty_surface->pixels, 0, (size_t)empty_surface->h * empty_surface->pitch); @@ -138,7 +138,7 @@ static void Android_DestroyEmptyCursor() static int Android_ShowCursor(SDL_Cursor *cursor) { - if (cursor == NULL) { + if (!cursor) { cursor = Android_CreateEmptyCursor(); } if (cursor) { @@ -215,7 +215,7 @@ void Android_OnMouse(SDL_Window *window, int state, int action, float x, float y int changes; Uint8 button; - if (window == NULL) { + if (!window) { return; } diff --git a/src/video/android/SDL_androidtouch.c b/src/video/android/SDL_androidtouch.c index 18d9cd026..85e7e04ca 100644 --- a/src/video/android/SDL_androidtouch.c +++ b/src/video/android/SDL_androidtouch.c @@ -52,7 +52,7 @@ void Android_OnTouch(SDL_Window *window, int touch_device_id_in, int pointer_fin SDL_TouchID touchDeviceId = 0; SDL_FingerID fingerId = 0; - if (window == NULL) { + if (!window) { return; } diff --git a/src/video/android/SDL_androidvideo.c b/src/video/android/SDL_androidvideo.c index 96cc2d7ed..1d6d0c282 100644 --- a/src/video/android/SDL_androidvideo.c +++ b/src/video/android/SDL_androidvideo.c @@ -86,13 +86,13 @@ static SDL_VideoDevice *Android_CreateDevice(void) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return NULL; } data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (data == NULL) { + if (!data) { SDL_OutOfMemory(); SDL_free(device); return NULL; diff --git a/src/video/android/SDL_androidvulkan.c b/src/video/android/SDL_androidvulkan.c index 1d1577cff..9c18996f8 100644 --- a/src/video/android/SDL_androidvulkan.c +++ b/src/video/android/SDL_androidvulkan.c @@ -48,10 +48,10 @@ int Android_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) } /* Load the Vulkan loader library */ - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_VULKAN_LIBRARY"); } - if (path == NULL) { + if (!path) { path = "libvulkan.so"; } _this->vulkan_config.loader_handle = SDL_LoadObject(path); @@ -76,7 +76,7 @@ int Android_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) (PFN_vkEnumerateInstanceExtensionProperties) _this->vulkan_config.vkEnumerateInstanceExtensionProperties, &extensionCount); - if (extensions == NULL) { + if (!extensions) { goto fail; } for (i = 0; i < extensionCount; i++) { diff --git a/src/video/android/SDL_androidwindow.c b/src/video/android/SDL_androidwindow.c index 1ef9cd518..3f640fdaa 100644 --- a/src/video/android/SDL_androidwindow.c +++ b/src/video/android/SDL_androidwindow.c @@ -61,7 +61,7 @@ int Android_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) SDL_SetKeyboardFocus(window); data = (SDL_WindowData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { retval = SDL_OutOfMemory(); goto endfunction; } @@ -129,7 +129,7 @@ void Android_SetWindowFullscreen(SDL_VideoDevice *_this, SDL_Window *window, SDL } data = window->driverdata; - if (data == NULL || !data->native_window) { + if (!data || !data->native_window) { if (data && !data->native_window) { SDL_SetError("Missing native window"); } diff --git a/src/video/dummy/SDL_nullframebuffer.c b/src/video/dummy/SDL_nullframebuffer.c index 5978d3b0a..d51b3c408 100644 --- a/src/video/dummy/SDL_nullframebuffer.c +++ b/src/video/dummy/SDL_nullframebuffer.c @@ -43,7 +43,7 @@ int SDL_DUMMY_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window /* Create a new framebuffer */ SDL_GetWindowSizeInPixels(window, &w, &h); surface = SDL_CreateSurface(w, h, surface_format); - if (surface == NULL) { + if (!surface) { return -1; } @@ -61,7 +61,7 @@ int SDL_DUMMY_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window SDL_Surface *surface; surface = (SDL_Surface *)SDL_GetProperty(SDL_GetWindowProperties(window), DUMMY_SURFACE); - if (surface == NULL) { + if (!surface) { return SDL_SetError("Couldn't find dummy surface for window"); } diff --git a/src/video/dummy/SDL_nullvideo.c b/src/video/dummy/SDL_nullvideo.c index d2bd677be..6a85ac980 100644 --- a/src/video/dummy/SDL_nullvideo.c +++ b/src/video/dummy/SDL_nullvideo.c @@ -83,7 +83,7 @@ static SDL_VideoDevice *DUMMY_InternalCreateDevice(const char *enable_hint) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return 0; } diff --git a/src/video/emscripten/SDL_emscriptenevents.c b/src/video/emscripten/SDL_emscriptenevents.c index e25dff184..18b36a794 100644 --- a/src/video/emscripten/SDL_emscriptenevents.c +++ b/src/video/emscripten/SDL_emscriptenevents.c @@ -964,7 +964,7 @@ void Emscripten_RegisterEventHandlers(SDL_WindowData *data) /* Keyboard events are awkward */ keyElement = SDL_GetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT); - if (keyElement == NULL) { + if (!keyElement) { keyElement = EMSCRIPTEN_EVENT_TARGET_WINDOW; } @@ -1007,7 +1007,7 @@ void Emscripten_UnregisterEventHandlers(SDL_WindowData *data) emscripten_set_pointerlockchange_callback(EMSCRIPTEN_EVENT_TARGET_DOCUMENT, NULL, 0, NULL); target = SDL_GetHint(SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT); - if (target == NULL) { + if (!target) { target = EMSCRIPTEN_EVENT_TARGET_WINDOW; } diff --git a/src/video/emscripten/SDL_emscriptenframebuffer.c b/src/video/emscripten/SDL_emscriptenframebuffer.c index b620d554e..318a32305 100644 --- a/src/video/emscripten/SDL_emscriptenframebuffer.c +++ b/src/video/emscripten/SDL_emscriptenframebuffer.c @@ -42,7 +42,7 @@ int Emscripten_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *windo SDL_GetWindowSizeInPixels(window, &w, &h); surface = SDL_CreateSurface(w, h, surface_format); - if (surface == NULL) { + if (!surface) { return -1; } @@ -60,7 +60,7 @@ int Emscripten_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *windo SDL_WindowData *data = window->driverdata; surface = data->surface; - if (surface == NULL) { + if (!surface) { return SDL_SetError("Couldn't find framebuffer surface for window"); } diff --git a/src/video/emscripten/SDL_emscriptenmouse.c b/src/video/emscripten/SDL_emscriptenmouse.c index 9aa794674..1913c0686 100644 --- a/src/video/emscripten/SDL_emscriptenmouse.c +++ b/src/video/emscripten/SDL_emscriptenmouse.c @@ -48,7 +48,7 @@ static SDL_Cursor *Emscripten_CreateCursorFromString(const char *cursor_str, SDL cursor = SDL_calloc(1, sizeof(SDL_Cursor)); if (cursor) { curdata = (Emscripten_CursorData *)SDL_calloc(1, sizeof(*curdata)); - if (curdata == NULL) { + if (!curdata) { SDL_OutOfMemory(); SDL_free(cursor); return NULL; @@ -78,7 +78,7 @@ static SDL_Cursor *Emscripten_CreateCursor(SDL_Surface *surface, int hot_x, int conv_surf = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ABGR8888); - if (conv_surf == NULL) { + if (!conv_surf) { return NULL; } @@ -175,7 +175,7 @@ static void Emscripten_FreeCursor(SDL_Cursor *cursor) if (cursor) { curdata = (Emscripten_CursorData *)cursor->driverdata; - if (curdata != NULL) { + if (curdata) { if (curdata->is_custom) { SDL_free((char *)curdata->system_cursor); } @@ -223,7 +223,7 @@ static int Emscripten_SetRelativeMouseMode(SDL_bool enabled) /* TODO: pointer lock isn't actually enabled yet */ if (enabled) { window = SDL_GetMouseFocus(); - if (window == NULL) { + if (!window) { return -1; } diff --git a/src/video/emscripten/SDL_emscriptenopengles.c b/src/video/emscripten/SDL_emscriptenopengles.c index 6a40c24c9..6f0cdd9df 100644 --- a/src/video/emscripten/SDL_emscriptenopengles.c +++ b/src/video/emscripten/SDL_emscriptenopengles.c @@ -117,7 +117,7 @@ int Emscripten_GLES_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context) SDL_Window *window; /* remove the context from its window */ - for (window = _this->windows; window != NULL; window = window->next) { + for (window = _this->windows; window; window = window->next) { SDL_WindowData *window_data = window->driverdata; if (window_data->gl_context == context) { diff --git a/src/video/emscripten/SDL_emscriptenvideo.c b/src/video/emscripten/SDL_emscriptenvideo.c index b9a8c11d9..0c2209dd0 100644 --- a/src/video/emscripten/SDL_emscriptenvideo.c +++ b/src/video/emscripten/SDL_emscriptenvideo.c @@ -61,7 +61,7 @@ static SDL_VideoDevice *Emscripten_CreateDevice(void) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return 0; } @@ -180,7 +180,7 @@ static int Emscripten_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) /* Allocate window internal data */ wdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); - if (wdata == NULL) { + if (!wdata) { return SDL_OutOfMemory(); } diff --git a/src/video/gdk/SDL_gdktextinput.cpp b/src/video/gdk/SDL_gdktextinput.cpp index 92485ecbe..b07319881 100644 --- a/src/video/gdk/SDL_gdktextinput.cpp +++ b/src/video/gdk/SDL_gdktextinput.cpp @@ -63,7 +63,7 @@ static void SDLCALL GDK_InternalHintCallback( const char *oldValue, const char *newValue) { - if (userdata == NULL) { + if (!userdata) { return; } @@ -72,7 +72,7 @@ static void SDLCALL GDK_InternalHintCallback( if (userdata == &g_TextInputScope || userdata == &g_MaxTextLength) { /* int32 hint */ - Sint32 intValue = (newValue == NULL || newValue[0] == '\0') ? 0 : SDL_atoi(newValue); + Sint32 intValue = (!newValue || newValue[0] == '\0') ? 0 : SDL_atoi(newValue); if (userdata == &g_MaxTextLength && intValue <= 0) { intValue = g_DefaultMaxTextLength; } else if (userdata == &g_TextInputScope && intValue < 0) { @@ -82,13 +82,13 @@ static void SDLCALL GDK_InternalHintCallback( *(Sint32 *)userdata = intValue; } else { /* string hint */ - if (newValue == NULL || newValue[0] == '\0') { + if (!newValue || newValue[0] == '\0') { /* treat empty or NULL strings as just NULL for this impl */ SDL_free(*(char **)userdata); *(char **)userdata = NULL; } else { char *newString = SDL_strdup(newValue); - if (newString == NULL) { + if (!newString) { /* couldn't strdup, oh well */ SDL_OutOfMemory(); } else { @@ -102,7 +102,7 @@ static void SDLCALL GDK_InternalHintCallback( static int GDK_InternalEnsureTaskQueue(void) { - if (g_TextTaskQueue == NULL) { + if (!g_TextTaskQueue) { if (SDL_GDKGetTaskQueue(&g_TextTaskQueue) < 0) { /* SetError will be done for us. */ return -1; @@ -128,7 +128,7 @@ static void CALLBACK GDK_InternalTextEntryCallback(XAsyncBlock *asyncBlock) } else if (resultSize > 0) { /* +1 to be super sure that the buffer will be null terminated */ resultBuffer = (char *)SDL_calloc(sizeof(*resultBuffer), 1 + (size_t)resultSize); - if (resultBuffer == NULL) { + if (!resultBuffer) { SDL_OutOfMemory(); } else { /* still pass the original size that we got from ResultSize */ @@ -251,7 +251,7 @@ void GDK_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window) HRESULT hR = S_OK; - if (g_TextBlock != NULL) { + if (g_TextBlock) { /* already showing the keyboard */ return; } @@ -262,7 +262,7 @@ void GDK_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window) } g_TextBlock = (XAsyncBlock *)SDL_calloc(1, sizeof(*g_TextBlock)); - if (g_TextBlock == NULL) { + if (!g_TextBlock) { SDL_OutOfMemory(); return; } @@ -285,7 +285,7 @@ void GDK_ShowScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window) void GDK_HideScreenKeyboard(SDL_VideoDevice *_this, SDL_Window *window) { - if (g_TextBlock != NULL) { + if (g_TextBlock) { XAsyncCancel(g_TextBlock); /* the completion callback will free the block */ } diff --git a/src/video/haiku/SDL_bclipboard.cc b/src/video/haiku/SDL_bclipboard.cc index 8bc155840..575948268 100644 --- a/src/video/haiku/SDL_bclipboard.cc +++ b/src/video/haiku/SDL_bclipboard.cc @@ -64,7 +64,7 @@ char *HAIKU_GetClipboardText(SDL_VideoDevice *_this) { be_clipboard->Unlock(); } - if (text == NULL) { + if (!text) { result = SDL_strdup(""); } else { /* Copy the data and pass on to SDL */ diff --git a/src/video/haiku/SDL_bframebuffer.cc b/src/video/haiku/SDL_bframebuffer.cc index 0151c72c5..f519650b4 100644 --- a/src/video/haiku/SDL_bframebuffer.cc +++ b/src/video/haiku/SDL_bframebuffer.cc @@ -94,7 +94,7 @@ int HAIKU_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window * window, int HAIKU_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window * window, const SDL_Rect * rects, int numrects) { - if (window == NULL) { + if (!window) { return 0; } diff --git a/src/video/haiku/SDL_bmessagebox.cc b/src/video/haiku/SDL_bmessagebox.cc index 3709f2c0a..84d2d5f61 100644 --- a/src/video/haiku/SDL_bmessagebox.cc +++ b/src/video/haiku/SDL_bmessagebox.cc @@ -356,15 +356,15 @@ int HAIKU_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid // "You need a valid BApplication object before interacting with the app_server." // "2 BApplication objects were created. Only one is allowed." std::unique_ptr application; - if (be_app == NULL) { + if (!be_app) { application = std::unique_ptr(new(std::nothrow) BApplication(SDL_signature)); - if (application == NULL) { + if (!application) { return SDL_SetError("Cannot create the BApplication object. Lack of memory?"); } } HAIKU_SDL_MessageBox *SDL_MessageBox = new(std::nothrow) HAIKU_SDL_MessageBox(messageboxdata); - if (SDL_MessageBox == NULL) { + if (!SDL_MessageBox) { return SDL_SetError("Cannot create the HAIKU_SDL_MessageBox (BAlert inheritor) object. Lack of memory?"); } const int closeButton = SDL_MessageBox->GetCloseButtonId(); diff --git a/src/video/haiku/SDL_bopengl.cc b/src/video/haiku/SDL_bopengl.cc index 52f2ed9c4..7a2f7335a 100644 --- a/src/video/haiku/SDL_bopengl.cc +++ b/src/video/haiku/SDL_bopengl.cc @@ -65,7 +65,7 @@ int HAIKU_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path) SDL_FunctionPointer HAIKU_GL_GetProcAddress(SDL_VideoDevice *_this, const char *proc) { - if (_this->gl_config.dll_handle != NULL) { + if (_this->gl_config.dll_handle) { void *location = NULL; status_t err; if ((err = @@ -92,8 +92,8 @@ int HAIKU_GL_SwapWindow(SDL_VideoDevice *_this, SDL_Window * window) { int HAIKU_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window * window, SDL_GLContext context) { BGLView* glView = (BGLView*)context; // printf("HAIKU_GL_MakeCurrent(%llx), win = %llx, thread = %d\n", (uint64)context, (uint64)window, find_thread(NULL)); - if (glView != NULL) { - if ((glView->Window() == NULL) || (window == NULL) || (_ToBeWin(window)->GetGLView() != glView)) { + if (glView) { + if ((glView->Window() == NULL) || (!window) || (_ToBeWin(window)->GetGLView() != glView)) { return SDL_SetError("MakeCurrent failed"); } } @@ -146,7 +146,7 @@ int HAIKU_GL_DeleteContext(SDL_VideoDevice *_this, SDL_GLContext context) { // printf("HAIKU_GL_DeleteContext(%llx), thread = %d\n", (uint64)context, find_thread(NULL)); BGLView* glView = (BGLView*)context; SDL_BWin *bwin = (SDL_BWin*)glView->Window(); - if (bwin == NULL) { + if (!bwin) { delete glView; } else { bwin->RemoveGLView(); diff --git a/src/video/haiku/SDL_bvideo.cc b/src/video/haiku/SDL_bvideo.cc index 86b8037d5..b97ee5a01 100644 --- a/src/video/haiku/SDL_bvideo.cc +++ b/src/video/haiku/SDL_bvideo.cc @@ -184,7 +184,7 @@ static SDL_Cursor * HAIKU_CreateCursor(SDL_Surface * surface, int hot_x, int hot SDL_Surface *converted; converted = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888); - if (converted == NULL) { + if (!converted) { return NULL; } @@ -206,7 +206,7 @@ static int HAIKU_ShowCursor(SDL_Cursor *cursor) { SDL_Mouse *mouse = SDL_GetMouse(); - if (mouse == NULL) { + if (!mouse) { return 0; } @@ -225,7 +225,7 @@ static int HAIKU_ShowCursor(SDL_Cursor *cursor) static int HAIKU_SetRelativeMouseMode(SDL_bool enabled) { SDL_Window *window = SDL_GetMouseFocus(); - if (window == NULL) { + if (!window) { return 0; } @@ -245,7 +245,7 @@ static int HAIKU_SetRelativeMouseMode(SDL_bool enabled) static void HAIKU_MouseInit(SDL_VideoDevice *_this) { SDL_Mouse *mouse = SDL_GetMouse(); - if (mouse == NULL) { + if (!mouse) { return; } mouse->CreateCursor = HAIKU_CreateCursor; diff --git a/src/video/haiku/SDL_bwindow.cc b/src/video/haiku/SDL_bwindow.cc index f69bec1f6..bb99a0fb9 100644 --- a/src/video/haiku/SDL_bwindow.cc +++ b/src/video/haiku/SDL_bwindow.cc @@ -65,7 +65,7 @@ static int _InitWindow(SDL_VideoDevice *_this, SDL_Window *window) { } SDL_BWin *bwin = new(std::nothrow) SDL_BWin(bounds, look, flags); - if (bwin == NULL) { + if (!bwin) { return -1; } diff --git a/src/video/kmsdrm/SDL_kmsdrmdyn.c b/src/video/kmsdrm/SDL_kmsdrmdyn.c index a5416c48b..e37e2c3e9 100644 --- a/src/video/kmsdrm/SDL_kmsdrmdyn.c +++ b/src/video/kmsdrm/SDL_kmsdrmdyn.c @@ -49,22 +49,22 @@ static void *KMSDRM_GetSym(const char *fnname, int *pHasModule) int i; void *fn = NULL; for (i = 0; i < SDL_TABLESIZE(kmsdrmlibs); i++) { - if (kmsdrmlibs[i].lib != NULL) { + if (kmsdrmlibs[i].lib) { fn = SDL_LoadFunction(kmsdrmlibs[i].lib, fnname); - if (fn != NULL) { + if (fn) { break; } } } #if DEBUG_DYNAMIC_KMSDRM - if (fn != NULL) + if (fn) SDL_Log("KMSDRM: Found '%s' in %s (%p)\n", fnname, kmsdrmlibs[i].libname, fn); else SDL_Log("KMSDRM: Symbol '%s' NOT FOUND!\n", fnname); #endif - if (fn == NULL) { + if (!fn) { *pHasModule = 0; /* kill this module. */ } @@ -98,7 +98,7 @@ void SDL_KMSDRM_UnloadSymbols(void) #ifdef SDL_VIDEO_DRIVER_KMSDRM_DYNAMIC for (i = 0; i < SDL_TABLESIZE(kmsdrmlibs); i++) { - if (kmsdrmlibs[i].lib != NULL) { + if (kmsdrmlibs[i].lib) { SDL_UnloadObject(kmsdrmlibs[i].lib); kmsdrmlibs[i].lib = NULL; } @@ -119,7 +119,7 @@ int SDL_KMSDRM_LoadSymbols(void) int i; int *thismod = NULL; for (i = 0; i < SDL_TABLESIZE(kmsdrmlibs); i++) { - if (kmsdrmlibs[i].libname != NULL) { + if (kmsdrmlibs[i].libname) { kmsdrmlibs[i].lib = SDL_LoadObject(kmsdrmlibs[i].libname); } } diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.c b/src/video/kmsdrm/SDL_kmsdrmmouse.c index 962802cef..1e092726a 100644 --- a/src/video/kmsdrm/SDL_kmsdrmmouse.c +++ b/src/video/kmsdrm/SDL_kmsdrmmouse.c @@ -147,7 +147,7 @@ static int KMSDRM_DumpCursorToBO(SDL_VideoDisplay *display, SDL_Cursor *cursor) int i; int ret; - if (curdata == NULL || !dispdata->cursor_bo) { + if (!curdata || !dispdata->cursor_bo) { return SDL_SetError("Cursor or display not initialized properly."); } @@ -158,7 +158,7 @@ static int KMSDRM_DumpCursorToBO(SDL_VideoDisplay *display, SDL_Cursor *cursor) ready_buffer = (uint8_t *)SDL_calloc(1, bufsize); - if (ready_buffer == NULL) { + if (!ready_buffer) { ret = SDL_OutOfMemory(); goto cleanup; } @@ -236,12 +236,12 @@ static SDL_Cursor *KMSDRM_CreateCursor(SDL_Surface *surface, int hot_x, int hot_ ret = NULL; cursor = (SDL_Cursor *)SDL_calloc(1, sizeof(*cursor)); - if (cursor == NULL) { + if (!cursor) { SDL_OutOfMemory(); goto cleanup; } curdata = (KMSDRM_CursorData *)SDL_calloc(1, sizeof(*curdata)); - if (curdata == NULL) { + if (!curdata) { SDL_OutOfMemory(); goto cleanup; } @@ -277,7 +277,7 @@ static SDL_Cursor *KMSDRM_CreateCursor(SDL_Surface *surface, int hot_x, int hot_ ret = cursor; cleanup: - if (ret == NULL) { + if (!ret) { if (curdata) { if (curdata->buffer) { SDL_free(curdata->buffer); @@ -305,13 +305,13 @@ static int KMSDRM_ShowCursor(SDL_Cursor *cursor) /* Get the mouse focused window, if any. */ mouse = SDL_GetMouse(); - if (mouse == NULL) { + if (!mouse) { return SDL_SetError("No mouse."); } window = mouse->focus; - if (window == NULL || cursor == NULL) { + if (!window || !cursor) { /* If no window is focused by mouse or cursor is NULL, since we have no window (no mouse->focus) and hence we have no display, we simply hide mouse on all displays. diff --git a/src/video/kmsdrm/SDL_kmsdrmopengles.c b/src/video/kmsdrm/SDL_kmsdrmopengles.c index 1df556e23..30ad56d16 100644 --- a/src/video/kmsdrm/SDL_kmsdrmopengles.c +++ b/src/video/kmsdrm/SDL_kmsdrmopengles.c @@ -142,7 +142,7 @@ int KMSDRM_GLES_SwapWindow(SDL_VideoDevice *_this, SDL_Window *window) /* Get an actual usable fb for the next front buffer. */ fb_info = KMSDRM_FBFromBO(_this, windata->next_bo); - if (fb_info == NULL) { + if (!fb_info) { SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Could not get a framebuffer"); return 0; } diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c index 643a469d8..9aee16dae 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -86,7 +86,7 @@ static int get_driindex(void) SDL_strlcpy(device, kmsdrm_dri_path, sizeof(device)); folder = opendir(device); - if (folder == NULL) { + if (!folder) { SDL_SetError("Failed to open directory '%s'", device); return -ENOENT; } @@ -124,7 +124,7 @@ static int get_driindex(void) KMSDRM_drmModeGetConnector( drm_fd, resources->connectors[i]); - if (conn == NULL) { + if (!conn) { continue; } @@ -260,13 +260,13 @@ static SDL_VideoDevice *KMSDRM_CreateDevice(void) } device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return NULL; } viddata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (viddata == NULL) { + if (!viddata) { SDL_OutOfMemory(); goto cleanup; } @@ -364,7 +364,7 @@ KMSDRM_FBInfo *KMSDRM_FBFromBO(SDL_VideoDevice *_this, struct gbm_bo *bo) when the backing buffer is destroyed */ fb_info = (KMSDRM_FBInfo *)SDL_calloc(1, sizeof(KMSDRM_FBInfo)); - if (fb_info == NULL) { + if (!fb_info) { SDL_OutOfMemory(); return NULL; } @@ -689,7 +689,7 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto /* Reserve memory for the new display's driverdata. */ dispdata = (SDL_DisplayData *)SDL_calloc(1, sizeof(SDL_DisplayData)); - if (dispdata == NULL) { + if (!dispdata) { ret = SDL_OutOfMemory(); goto cleanup; } @@ -710,7 +710,7 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto for (i = 0; i < resources->count_encoders; i++) { encoder = KMSDRM_drmModeGetEncoder(viddata->drm_fd, resources->encoders[i]); - if (encoder == NULL) { + if (!encoder) { continue; } @@ -722,13 +722,13 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto encoder = NULL; } - if (encoder == NULL) { + if (!encoder) { /* No encoder was connected, find the first supported one */ for (i = 0; i < resources->count_encoders; i++) { encoder = KMSDRM_drmModeGetEncoder(viddata->drm_fd, resources->encoders[i]); - if (encoder == NULL) { + if (!encoder) { continue; } @@ -747,7 +747,7 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto } } - if (encoder == NULL) { + if (!encoder) { ret = SDL_SetError("No connected encoder found for connector."); goto cleanup; } @@ -757,7 +757,7 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto /* If no CRTC was connected to the encoder, find the first CRTC that is supported by the encoder, and use that. */ - if (crtc == NULL) { + if (!crtc) { for (i = 0; i < resources->count_crtcs; i++) { if (encoder->possible_crtcs & (1 << i)) { encoder->crtc_id = resources->crtcs[i]; @@ -767,7 +767,7 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto } } - if (crtc == NULL) { + if (!crtc) { ret = SDL_SetError("No CRTC found for connector."); goto cleanup; } @@ -852,7 +852,7 @@ static void KMSDRM_AddDisplay(SDL_VideoDevice *_this, drmModeConnector *connecto There's no problem with it being still incomplete. */ modedata = SDL_calloc(1, sizeof(SDL_DisplayModeData)); - if (modedata == NULL) { + if (!modedata) { ret = SDL_OutOfMemory(); goto cleanup; } @@ -924,7 +924,7 @@ static int KMSDRM_InitDisplays(SDL_VideoDevice *_this) /* Get all of the available connectors / devices / crtcs */ resources = KMSDRM_drmModeGetResources(viddata->drm_fd); - if (resources == NULL) { + if (!resources) { ret = SDL_SetError("drmModeGetResources(%d) failed", viddata->drm_fd); goto cleanup; } @@ -935,7 +935,7 @@ static int KMSDRM_InitDisplays(SDL_VideoDevice *_this) drmModeConnector *connector = KMSDRM_drmModeGetConnector(viddata->drm_fd, resources->connectors[i]); - if (connector == NULL) { + if (!connector) { continue; } @@ -1351,7 +1351,7 @@ int KMSDRM_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL return 0; } - if (modedata == NULL) { + if (!modedata) { return SDL_SetError("Mode doesn't have an associated index"); } @@ -1374,7 +1374,7 @@ void KMSDRM_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) SDL_bool is_vulkan = window->flags & SDL_WINDOW_VULKAN; /* Is this a VK window? */ unsigned int i, j; - if (windata == NULL) { + if (!windata) { return; } @@ -1458,7 +1458,7 @@ int KMSDRM_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) /* Allocate window internal data */ windata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); - if (windata == NULL) { + if (!windata) { return SDL_OutOfMemory(); } diff --git a/src/video/kmsdrm/SDL_kmsdrmvulkan.c b/src/video/kmsdrm/SDL_kmsdrmvulkan.c index 038bd2db9..c30d9fe98 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvulkan.c +++ b/src/video/kmsdrm/SDL_kmsdrmvulkan.c @@ -55,10 +55,10 @@ int KMSDRM_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) } /* Load the Vulkan library */ - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_VULKAN_LIBRARY"); } - if (path == NULL) { + if (!path) { path = DEFAULT_VULKAN; } @@ -92,7 +92,7 @@ int KMSDRM_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) _this->vulkan_config.vkEnumerateInstanceExtensionProperties, &extensionCount); - if (extensions == NULL) { + if (!extensions) { goto fail; } diff --git a/src/video/n3ds/SDL_n3dsframebuffer.c b/src/video/n3ds/SDL_n3dsframebuffer.c index 46fe98ea0..502594d66 100644 --- a/src/video/n3ds/SDL_n3dsframebuffer.c +++ b/src/video/n3ds/SDL_n3dsframebuffer.c @@ -53,7 +53,7 @@ int SDL_N3DS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL_GetWindowSizeInPixels(window, &w, &h); framebuffer = SDL_CreateSurface(w, h, FRAMEBUFFER_FORMAT); - if (framebuffer == NULL) { + if (!framebuffer) { return SDL_OutOfMemory(); } @@ -73,7 +73,7 @@ int SDL_N3DS_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, u32 bufsize; surface = (SDL_Surface *)SDL_GetProperty(SDL_GetWindowProperties(window), N3DS_SURFACE); - if (surface == NULL) { + if (!surface) { return SDL_SetError("%s: Unable to get the window surface.", __func__); } diff --git a/src/video/n3ds/SDL_n3dsvideo.c b/src/video/n3ds/SDL_n3dsvideo.c index 74b52071a..409713e77 100644 --- a/src/video/n3ds/SDL_n3dsvideo.c +++ b/src/video/n3ds/SDL_n3dsvideo.c @@ -55,7 +55,7 @@ static void N3DS_DeleteDevice(SDL_VideoDevice *device) static SDL_VideoDevice *N3DS_CreateDevice(void) { SDL_VideoDevice *device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return 0; } @@ -104,7 +104,7 @@ static int AddN3DSDisplay(gfxScreen_t screen) SDL_DisplayMode mode; SDL_VideoDisplay display; SDL_DisplayData *display_driver_data = SDL_calloc(1, sizeof(SDL_DisplayData)); - if (display_driver_data == NULL) { + if (!display_driver_data) { return SDL_OutOfMemory(); } @@ -139,7 +139,7 @@ static int N3DS_GetDisplayBounds(SDL_VideoDevice *_this, SDL_VideoDisplay *displ { SDL_DisplayData *driver_data = display->driverdata; - if (driver_data == NULL) { + if (!driver_data) { return -1; } @@ -154,7 +154,7 @@ static int N3DS_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) { SDL_DisplayData *display_data; SDL_WindowData *window_data = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); - if (window_data == NULL) { + if (!window_data) { return SDL_OutOfMemory(); } display_data = SDL_GetDisplayDriverDataForWindow(window); @@ -166,7 +166,7 @@ static int N3DS_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) static void N3DS_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) { - if (window == NULL) { + if (!window) { return; } SDL_free(window->driverdata); diff --git a/src/video/ngage/SDL_ngageframebuffer.cpp b/src/video/ngage/SDL_ngageframebuffer.cpp index a4072f7fc..bc4612a77 100644 --- a/src/video/ngage/SDL_ngageframebuffer.cpp +++ b/src/video/ngage/SDL_ngageframebuffer.cpp @@ -57,7 +57,7 @@ int SDL_NGAGE_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window /* Create a new one */ SDL_GetWindowSizeInPixels(window, &w, &h); surface = SDL_CreateSurface(w, h, surface_format); - if (surface == NULL) { + if (!surface) { return -1; } @@ -149,7 +149,7 @@ int SDL_NGAGE_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window SDL_Surface *surface; surface = (SDL_Surface *)SDL_GetWindowData(window, NGAGE_SURFACE); - if (surface == NULL) { + if (!surface) { return SDL_SetError("Couldn't find ngage surface for window"); } diff --git a/src/video/ngage/SDL_ngagevideo.cpp b/src/video/ngage/SDL_ngagevideo.cpp index 739b20106..d9af15d27 100644 --- a/src/video/ngage/SDL_ngagevideo.cpp +++ b/src/video/ngage/SDL_ngagevideo.cpp @@ -104,14 +104,14 @@ static SDL_VideoDevice *NGAGE_CreateDevice(void) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return 0; } /* Initialize internal N-Gage specific data */ phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (phdata == NULL) { + if (!phdata) { SDL_OutOfMemory(); SDL_free(device); return 0; diff --git a/src/video/ngage/SDL_ngagewindow.cpp b/src/video/ngage/SDL_ngagewindow.cpp index 5772e3e25..d8ee898ae 100644 --- a/src/video/ngage/SDL_ngagewindow.cpp +++ b/src/video/ngage/SDL_ngagewindow.cpp @@ -36,7 +36,7 @@ int NGAGE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) { NGAGE_Window *ngage_window = (NGAGE_Window *)SDL_calloc(1, sizeof(NGAGE_Window)); - if (ngage_window == NULL) { + if (!ngage_window) { return SDL_OutOfMemory(); } diff --git a/src/video/offscreen/SDL_offscreenframebuffer.c b/src/video/offscreen/SDL_offscreenframebuffer.c index 7dea25a90..cd9604f65 100644 --- a/src/video/offscreen/SDL_offscreenframebuffer.c +++ b/src/video/offscreen/SDL_offscreenframebuffer.c @@ -43,7 +43,7 @@ int SDL_OFFSCREEN_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *wi /* Create a new framebuffer */ SDL_GetWindowSizeInPixels(window, &w, &h); surface = SDL_CreateSurface(w, h, surface_format); - if (surface == NULL) { + if (!surface) { return -1; } @@ -62,7 +62,7 @@ int SDL_OFFSCREEN_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *wi SDL_Surface *surface; surface = (SDL_Surface *)SDL_GetProperty(SDL_GetWindowProperties(window), OFFSCREEN_SURFACE); - if (surface == NULL) { + if (!surface) { return SDL_SetError("Couldn't find offscreen surface for window"); } diff --git a/src/video/offscreen/SDL_offscreenvideo.c b/src/video/offscreen/SDL_offscreenvideo.c index 613340843..f4955862a 100644 --- a/src/video/offscreen/SDL_offscreenvideo.c +++ b/src/video/offscreen/SDL_offscreenvideo.c @@ -56,7 +56,7 @@ static SDL_VideoDevice *OFFSCREEN_CreateDevice(void) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return 0; } diff --git a/src/video/offscreen/SDL_offscreenwindow.c b/src/video/offscreen/SDL_offscreenwindow.c index d105e8347..7a8ce759f 100644 --- a/src/video/offscreen/SDL_offscreenwindow.c +++ b/src/video/offscreen/SDL_offscreenwindow.c @@ -31,7 +31,7 @@ int OFFSCREEN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) { SDL_WindowData *offscreen_window = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); - if (offscreen_window == NULL) { + if (!offscreen_window) { return SDL_OutOfMemory(); } diff --git a/src/video/ps2/SDL_ps2video.c b/src/video/ps2/SDL_ps2video.c index caaab5efa..5d003834c 100644 --- a/src/video/ps2/SDL_ps2video.c +++ b/src/video/ps2/SDL_ps2video.c @@ -95,7 +95,7 @@ static SDL_VideoDevice *PS2_CreateDevice(void) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return 0; } diff --git a/src/video/psp/SDL_pspvideo.c b/src/video/psp/SDL_pspvideo.c index 5cf0d7288..637d9c138 100644 --- a/src/video/psp/SDL_pspvideo.c +++ b/src/video/psp/SDL_pspvideo.c @@ -51,21 +51,21 @@ static SDL_VideoDevice *PSP_Create() /* Initialize SDL_VideoDevice structure */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return NULL; } /* Initialize internal PSP specific data */ phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (phdata == NULL) { + if (!phdata) { SDL_OutOfMemory(); SDL_free(device); return NULL; } gldata = (SDL_GLDriverData *)SDL_calloc(1, sizeof(SDL_GLDriverData)); - if (gldata == NULL) { + if (!gldata) { SDL_OutOfMemory(); SDL_free(device); SDL_free(phdata); @@ -192,7 +192,7 @@ int PSP_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) /* Allocate window internal data */ wdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); - if (wdata == NULL) { + if (!wdata) { return SDL_OutOfMemory(); } diff --git a/src/video/qnx/SDL_qnxgl.c b/src/video/qnx/SDL_qnxgl.c index 91df47dfb..35a4d68ea 100644 --- a/src/video/qnx/SDL_qnxgl.c +++ b/src/video/qnx/SDL_qnxgl.c @@ -84,7 +84,7 @@ int glGetConfig(EGLConfig *pconf, int *pformat) // Allocate enough memory for all configurations. egl_configs = SDL_malloc(egl_num_configs * sizeof(*egl_configs)); - if (egl_configs == NULL) { + if (!egl_configs) { return -1; } diff --git a/src/video/qnx/SDL_qnxvideo.c b/src/video/qnx/SDL_qnxvideo.c index 429f053b4..ea32e7d5e 100644 --- a/src/video/qnx/SDL_qnxvideo.c +++ b/src/video/qnx/SDL_qnxvideo.c @@ -74,7 +74,7 @@ static int createWindow(SDL_VideoDevice *_this, SDL_Window *window) int usage; impl = SDL_calloc(1, sizeof(*impl)); - if (impl == NULL) { + if (!impl) { return -1; } @@ -310,7 +310,7 @@ static SDL_VideoDevice *createDevice() SDL_VideoDevice *device; device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { return NULL; } diff --git a/src/video/raspberry/SDL_rpimouse.c b/src/video/raspberry/SDL_rpimouse.c index e188b37c7..1d915270c 100644 --- a/src/video/raspberry/SDL_rpimouse.c +++ b/src/video/raspberry/SDL_rpimouse.c @@ -65,12 +65,12 @@ static SDL_Cursor *RPI_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) SDL_assert(surface->pitch == surface->w * 4); cursor = (SDL_Cursor *)SDL_calloc(1, sizeof(*cursor)); - if (cursor == NULL) { + if (!cursor) { SDL_OutOfMemory(); return NULL; } curdata = (RPI_CursorData *)SDL_calloc(1, sizeof(*curdata)); - if (curdata == NULL) { + if (!curdata) { SDL_OutOfMemory(); SDL_free(cursor); return NULL; @@ -113,12 +113,12 @@ static int RPI_ShowCursor(SDL_Cursor *cursor) const char *env; mouse = SDL_GetMouse(); - if (mouse == NULL) { + if (!mouse) { return -1; } if (cursor != global_cursor) { - if (global_cursor != NULL) { + if (global_cursor) { curdata = (RPI_CursorData *)global_cursor->driverdata; if (curdata && curdata->element > DISPMANX_NO_HANDLE) { update = vc_dispmanx_update_start(0); @@ -133,21 +133,21 @@ static int RPI_ShowCursor(SDL_Cursor *cursor) global_cursor = cursor; } - if (cursor == NULL) { + if (!cursor) { return 0; } curdata = (RPI_CursorData *)cursor->driverdata; - if (curdata == NULL) { + if (!curdata) { return -1; } - if (mouse->focus == NULL) { + if (!mouse->focus) { return -1; } data = SDL_GetDisplayDriverDataForWindow(mouse->focus); - if (data == NULL) { + if (!data) { return -1; } @@ -188,10 +188,10 @@ static void RPI_FreeCursor(SDL_Cursor *cursor) DISPMANX_UPDATE_HANDLE_T update; RPI_CursorData *curdata; - if (cursor != NULL) { + if (cursor) { curdata = (RPI_CursorData *)cursor->driverdata; - if (curdata != NULL) { + if (curdata) { if (curdata->element != DISPMANX_NO_HANDLE) { update = vc_dispmanx_update_start(0); SDL_assert(update); @@ -224,7 +224,7 @@ static int RPI_WarpMouseGlobalGraphically(float x, float y) VC_RECT_T src_rect; SDL_Mouse *mouse = SDL_GetMouse(); - if (mouse == NULL || mouse->cur_cursor == NULL || mouse->cur_cursor->driverdata == NULL) { + if (!mouse || !mouse->cur_cursor || !mouse->cur_cursor->driverdata) { return 0; } @@ -273,7 +273,7 @@ static int RPI_WarpMouseGlobal(float x, float y) { SDL_Mouse *mouse = SDL_GetMouse(); - if (mouse == NULL || mouse->cur_cursor == NULL || mouse->cur_cursor->driverdata == NULL) { + if (!mouse || !mouse->cur_cursor || !mouse->cur_cursor->driverdata) { return 0; } diff --git a/src/video/raspberry/SDL_rpivideo.c b/src/video/raspberry/SDL_rpivideo.c index 3d5d0888b..e48bc1e68 100644 --- a/src/video/raspberry/SDL_rpivideo.c +++ b/src/video/raspberry/SDL_rpivideo.c @@ -76,14 +76,14 @@ static SDL_VideoDevice *RPI_Create() /* Initialize SDL_VideoDevice structure */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return NULL; } /* Initialize internal data */ phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (phdata == NULL) { + if (!phdata) { SDL_OutOfMemory(); SDL_free(device); return NULL; @@ -170,7 +170,7 @@ static void AddDispManXDisplay(const int display_id) /* Allocate display internal data */ data = (SDL_DisplayData *)SDL_calloc(1, sizeof(SDL_DisplayData)); - if (data == NULL) { + if (!data) { vc_dispmanx_display_close(handle); return; /* oh well */ } @@ -236,7 +236,7 @@ int RPI_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) /* Allocate window internal data */ wdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); - if (wdata == NULL) { + if (!wdata) { return SDL_OutOfMemory(); } display = SDL_GetVideoDisplayForWindow(window); diff --git a/src/video/riscos/SDL_riscosframebuffer.c b/src/video/riscos/SDL_riscosframebuffer.c index 6fe8ec1a3..1f53f85af 100644 --- a/src/video/riscos/SDL_riscosframebuffer.c +++ b/src/video/riscos/SDL_riscosframebuffer.c @@ -80,7 +80,7 @@ int RISCOS_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, U regs.r[5] = h; regs.r[6] = sprite_mode; error = _kernel_swi(OS_SpriteOp, ®s, ®s); - if (error != NULL) { + if (error) { SDL_free(driverdata->fb_area); return SDL_SetError("Unable to create sprite: %s (%i)", error->errmess, error->errnum); } @@ -106,7 +106,7 @@ int RISCOS_UpdateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, c regs.r[6] = 0; regs.r[7] = 0; error = _kernel_swi(OS_SpriteOp, ®s, ®s); - if (error != NULL) { + if (error) { return SDL_SetError("OS_SpriteOp 52 failed: %s (%i)", error->errmess, error->errnum); } diff --git a/src/video/riscos/SDL_riscosmodes.c b/src/video/riscos/SDL_riscosmodes.c index f9d906bb9..d5cb44752 100644 --- a/src/video/riscos/SDL_riscosmodes.c +++ b/src/video/riscos/SDL_riscosmodes.c @@ -167,7 +167,7 @@ static void *convert_mode_block(const int *block) } dst = SDL_malloc(40); - if (dst == NULL) { + if (!dst) { return NULL; } @@ -208,7 +208,7 @@ int RISCOS_InitModes(SDL_VideoDevice *_this) regs.r[0] = 1; error = _kernel_swi(OS_ScreenMode, ®s, ®s); - if (error != NULL) { + if (error) { return SDL_SetError("Unable to retrieve the current screen mode: %s (%i)", error->errmess, error->errnum); } @@ -241,19 +241,19 @@ int RISCOS_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *display) regs.r[6] = 0; regs.r[7] = 0; error = _kernel_swi(OS_ScreenMode, ®s, ®s); - if (error != NULL) { + if (error) { return SDL_SetError("Unable to enumerate screen modes: %s (%i)", error->errmess, error->errnum); } block = SDL_malloc(-regs.r[7]); - if (block == NULL) { + if (!block) { return SDL_OutOfMemory(); } regs.r[6] = (int)block; regs.r[7] = -regs.r[7]; error = _kernel_swi(OS_ScreenMode, ®s, ®s); - if (error != NULL) { + if (error) { SDL_free(block); return SDL_SetError("Unable to enumerate screen modes: %s (%i)", error->errmess, error->errnum); } @@ -292,7 +292,7 @@ int RISCOS_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *display, SDL regs.r[0] = 0; regs.r[1] = (int)mode->driverdata; error = _kernel_swi(OS_ScreenMode, ®s, ®s); - if (error != NULL) { + if (error) { return SDL_SetError("Unable to set the current screen mode: %s (%i)", error->errmess, error->errnum); } diff --git a/src/video/riscos/SDL_riscosvideo.c b/src/video/riscos/SDL_riscosvideo.c index a2df367f9..d132abdb8 100644 --- a/src/video/riscos/SDL_riscosvideo.c +++ b/src/video/riscos/SDL_riscosvideo.c @@ -54,14 +54,14 @@ static SDL_VideoDevice *RISCOS_CreateDevice(void) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return 0; } /* Initialize internal data */ phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (phdata == NULL) { + if (!phdata) { SDL_OutOfMemory(); SDL_free(device); return NULL; diff --git a/src/video/riscos/SDL_riscoswindow.c b/src/video/riscos/SDL_riscoswindow.c index b0a3a207a..bd192c3ce 100644 --- a/src/video/riscos/SDL_riscoswindow.c +++ b/src/video/riscos/SDL_riscoswindow.c @@ -33,7 +33,7 @@ int RISCOS_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) SDL_WindowData *driverdata; driverdata = (SDL_WindowData *)SDL_calloc(1, sizeof(*driverdata)); - if (driverdata == NULL) { + if (!driverdata) { return SDL_OutOfMemory(); } driverdata->window = window; @@ -51,7 +51,7 @@ void RISCOS_DestroyWindow(SDL_VideoDevice *_this, SDL_Window *window) { SDL_WindowData *driverdata = window->driverdata; - if (driverdata == NULL) { + if (!driverdata) { return; } diff --git a/src/video/vita/SDL_vitaframebuffer.c b/src/video/vita/SDL_vitaframebuffer.c index ef505d75e..7fb566727 100644 --- a/src/video/vita/SDL_vitaframebuffer.c +++ b/src/video/vita/SDL_vitaframebuffer.c @@ -103,7 +103,7 @@ void VITA_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window) { SDL_WindowData *data = window->driverdata; - if (data == NULL) { + if (!data) { /* The window wasn't fully initialized */ return; } diff --git a/src/video/vita/SDL_vitagl_pvr.c b/src/video/vita/SDL_vitagl_pvr.c index af9897e59..6e34054a9 100644 --- a/src/video/vita/SDL_vitagl_pvr.c +++ b/src/video/vita/SDL_vitagl_pvr.c @@ -51,8 +51,8 @@ int VITA_GL_LoadLibrary(SDL_VideoDevice *_this, const char *path) char *default_path = "app0:module"; char target_path[MAX_PATH]; - if (skip_init == NULL) { // we don't care about actual value - if (override != NULL) { + if (!skip_init) { // we don't care about actual value + if (override) { default_path = override; } diff --git a/src/video/vita/SDL_vitagles_pvr.c b/src/video/vita/SDL_vitagles_pvr.c index c862d6cae..71cd5d92f 100644 --- a/src/video/vita/SDL_vitagles_pvr.c +++ b/src/video/vita/SDL_vitagles_pvr.c @@ -40,9 +40,9 @@ int VITA_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) char *default_path = "app0:module"; char target_path[MAX_PATH]; - if (skip_init == NULL) { // we don't care about actual value + if (!skip_init) { // we don't care about actual value - if (override != NULL) { + if (override) { default_path = override; } diff --git a/src/video/vita/SDL_vitakeyboard.c b/src/video/vita/SDL_vitakeyboard.c index f92762420..106100a80 100644 --- a/src/video/vita/SDL_vitakeyboard.c +++ b/src/video/vita/SDL_vitakeyboard.c @@ -48,7 +48,7 @@ void VITA_InitKeyboard(void) void VITA_PollKeyboard(void) { // We skip polling keyboard if no window is created - if (Vita_Window == NULL) { + if (!Vita_Window) { return; } diff --git a/src/video/vita/SDL_vitamouse.c b/src/video/vita/SDL_vitamouse.c index 88dd01876..1030adaa6 100644 --- a/src/video/vita/SDL_vitamouse.c +++ b/src/video/vita/SDL_vitamouse.c @@ -42,7 +42,7 @@ void VITA_InitMouse(void) void VITA_PollMouse(void) { // We skip polling mouse if no window is created - if (Vita_Window == NULL) { + if (!Vita_Window) { return; } diff --git a/src/video/vita/SDL_vitatouch.c b/src/video/vita/SDL_vitatouch.c index cef1ffc9c..58c2d5f79 100644 --- a/src/video/vita/SDL_vitatouch.c +++ b/src/video/vita/SDL_vitatouch.c @@ -84,7 +84,7 @@ void VITA_PollTouch(void) int port; // We skip polling touch if no window is created - if (Vita_Window == NULL) { + if (!Vita_Window) { return; } diff --git a/src/video/vita/SDL_vitavideo.c b/src/video/vita/SDL_vitavideo.c index 3b59a3662..f3fd1f94b 100644 --- a/src/video/vita/SDL_vitavideo.c +++ b/src/video/vita/SDL_vitavideo.c @@ -67,14 +67,14 @@ static SDL_VideoDevice *VITA_Create() #endif /* Initialize SDL_VideoDevice structure */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return NULL; } /* Initialize internal VITA specific data */ phdata = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (phdata == NULL) { + if (!phdata) { SDL_OutOfMemory(); SDL_free(device); return NULL; @@ -82,7 +82,7 @@ static SDL_VideoDevice *VITA_Create() #ifdef SDL_VIDEO_VITA_PIB gldata = (SDL_GLDriverData *)SDL_calloc(1, sizeof(SDL_GLDriverData)); - if (gldata == NULL) { + if (!gldata) { SDL_OutOfMemory(); SDL_free(device); SDL_free(phdata); @@ -231,7 +231,7 @@ int VITA_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) /* Allocate window internal data */ wdata = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); - if (wdata == NULL) { + if (!wdata) { return SDL_OutOfMemory(); } @@ -239,7 +239,7 @@ int VITA_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) window->driverdata = wdata; // Vita can only have one window - if (Vita_Window != NULL) { + if (Vita_Window) { return SDL_SetError("Only one window supported"); } diff --git a/src/video/vivante/SDL_vivantevideo.c b/src/video/vivante/SDL_vivantevideo.c index 69eef0a34..fa507571c 100644 --- a/src/video/vivante/SDL_vivantevideo.c +++ b/src/video/vivante/SDL_vivantevideo.c @@ -48,14 +48,14 @@ static SDL_VideoDevice *VIVANTE_Create() /* Initialize SDL_VideoDevice structure */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return NULL; } /* Initialize internal data */ data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (data == NULL) { + if (!data) { SDL_OutOfMemory(); SDL_free(device); return NULL; @@ -124,7 +124,7 @@ static int VIVANTE_AddVideoDisplays(SDL_VideoDevice *_this) unsigned long pixels = 0; data = (SDL_DisplayData *)SDL_calloc(1, sizeof(SDL_DisplayData)); - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } @@ -248,7 +248,7 @@ int VIVANTE_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) /* Allocate window internal data */ data = (SDL_WindowData *)SDL_calloc(1, sizeof(SDL_WindowData)); - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } diff --git a/src/video/vivante/SDL_vivantevulkan.c b/src/video/vivante/SDL_vivantevulkan.c index a8fcb0ff6..29416e603 100644 --- a/src/video/vivante/SDL_vivantevulkan.c +++ b/src/video/vivante/SDL_vivantevulkan.c @@ -46,10 +46,10 @@ int VIVANTE_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) } /* Load the Vulkan loader library */ - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_VULKAN_LIBRARY"); } - if (path == NULL) { + if (!path) { /* If no path set, try Vivante fb vulkan driver explicitly */ path = "libvulkan-fb.so"; _this->vulkan_config.loader_handle = SDL_LoadObject(path); @@ -83,7 +83,7 @@ int VIVANTE_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) (PFN_vkEnumerateInstanceExtensionProperties) _this->vulkan_config.vkEnumerateInstanceExtensionProperties, &extensionCount); - if (extensions == NULL) { + if (!extensions) { goto fail; } for (i = 0; i < extensionCount; i++) { diff --git a/src/video/wayland/SDL_waylandclipboard.c b/src/video/wayland/SDL_waylandclipboard.c index 75c358809..097852e8f 100644 --- a/src/video/wayland/SDL_waylandclipboard.c +++ b/src/video/wayland/SDL_waylandclipboard.c @@ -35,7 +35,7 @@ int Wayland_SetClipboardData(SDL_VideoDevice *_this) SDL_WaylandDataDevice *data_device = NULL; int status = 0; - if (video_data->input != NULL && video_data->input->data_device != NULL) { + if (video_data->input && video_data->input->data_device) { data_device = video_data->input->data_device; if (_this->clipboard_callback && _this->clipboard_mime_types) { @@ -60,7 +60,7 @@ void *Wayland_GetClipboardData(SDL_VideoDevice *_this, const char *mime_type, si SDL_WaylandDataDevice *data_device = NULL; void *buffer = NULL; - if (video_data->input != NULL && video_data->input->data_device != NULL) { + if (video_data->input && video_data->input->data_device) { data_device = video_data->input->data_device; if (data_device->selection_source) { buffer = SDL_GetInternalClipboardData(_this, mime_type, length); @@ -78,9 +78,9 @@ SDL_bool Wayland_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type) SDL_WaylandDataDevice *data_device = NULL; SDL_bool result = SDL_FALSE; - if (video_data->input != NULL && video_data->input->data_device != NULL) { + if (video_data->input && video_data->input->data_device) { data_device = video_data->input->data_device; - if (data_device->selection_source != NULL) { + if (data_device->selection_source) { result = SDL_HasInternalClipboardData(_this, mime_type); } else { result = Wayland_data_offer_has_mime(data_device->selection_offer, mime_type); @@ -109,7 +109,7 @@ int Wayland_SetPrimarySelectionText(SDL_VideoDevice *_this, const char *text) SDL_WaylandPrimarySelectionDevice *primary_selection_device = NULL; int status = -1; - if (video_data->input != NULL && video_data->input->primary_selection_device != NULL) { + if (video_data->input && video_data->input->primary_selection_device) { primary_selection_device = video_data->input->primary_selection_device; if (text[0] != '\0') { SDL_WaylandPrimarySelectionSource *source = Wayland_primary_selection_source_create(_this); @@ -137,16 +137,16 @@ char *Wayland_GetPrimarySelectionText(SDL_VideoDevice *_this) char *text = NULL; size_t length = 0; - if (video_data->input != NULL && video_data->input->primary_selection_device != NULL) { + if (video_data->input && video_data->input->primary_selection_device) { primary_selection_device = video_data->input->primary_selection_device; - if (primary_selection_device->selection_source != NULL) { + if (primary_selection_device->selection_source) { text = Wayland_primary_selection_source_get_data(primary_selection_device->selection_source, TEXT_MIME, &length); } else if (Wayland_primary_selection_offer_has_mime(primary_selection_device->selection_offer, TEXT_MIME)) { text = Wayland_primary_selection_offer_receive(primary_selection_device->selection_offer, TEXT_MIME, &length); } } - if (text == NULL) { + if (!text) { text = SDL_strdup(""); } @@ -159,9 +159,9 @@ SDL_bool Wayland_HasPrimarySelectionText(SDL_VideoDevice *_this) SDL_WaylandPrimarySelectionDevice *primary_selection_device = NULL; SDL_bool result = SDL_FALSE; - if (video_data->input != NULL && video_data->input->primary_selection_device != NULL) { + if (video_data->input && video_data->input->primary_selection_device) { primary_selection_device = video_data->input->primary_selection_device; - if (primary_selection_device->selection_source != NULL) { + if (primary_selection_device->selection_source) { result = SDL_TRUE; } else { result = Wayland_primary_selection_offer_has_mime(primary_selection_device->selection_offer, TEXT_MIME); diff --git a/src/video/wayland/SDL_waylanddatamanager.c b/src/video/wayland/SDL_waylanddatamanager.c index ed24ddeab..00da37305 100644 --- a/src/video/wayland/SDL_waylanddatamanager.c +++ b/src/video/wayland/SDL_waylanddatamanager.c @@ -112,13 +112,13 @@ static ssize_t read_pipe(int fd, void **buffer, size_t *total_length) new_buffer_length = *total_length + sizeof(Uint32); - if (*buffer == NULL) { + if (!*buffer) { output_buffer = SDL_malloc(new_buffer_length); } else { output_buffer = SDL_realloc(*buffer, new_buffer_length); } - if (output_buffer == NULL) { + if (!output_buffer) { bytes_read = SDL_OutOfMemory(); } else { SDL_memcpy((Uint8 *)output_buffer + pos, temp, bytes_read); @@ -155,9 +155,9 @@ static int mime_data_list_add(struct wl_list *list, SDL_MimeDataList *mime_data = NULL; void *internal_buffer = NULL; - if (buffer != NULL) { + if (buffer) { internal_buffer = SDL_malloc(length); - if (internal_buffer == NULL) { + if (!internal_buffer) { return SDL_OutOfMemory(); } SDL_memcpy(internal_buffer, buffer, length); @@ -165,16 +165,16 @@ static int mime_data_list_add(struct wl_list *list, mime_data = mime_data_list_find(list, mime_type); - if (mime_data == NULL) { + if (!mime_data) { mime_data = SDL_calloc(1, sizeof(*mime_data)); - if (mime_data == NULL) { + if (!mime_data) { status = SDL_OutOfMemory(); } else { WAYLAND_wl_list_insert(list, &(mime_data->link)); mime_type_length = SDL_strlen(mime_type) + 1; mime_data->mime_type = SDL_malloc(mime_type_length); - if (mime_data->mime_type == NULL) { + if (!mime_data->mime_type) { status = SDL_OutOfMemory(); } else { SDL_memcpy(mime_data->mime_type, mime_type, mime_type_length); @@ -182,8 +182,8 @@ static int mime_data_list_add(struct wl_list *list, } } - if (mime_data != NULL && buffer != NULL && length > 0) { - if (mime_data->data != NULL) { + if (mime_data && buffer && length > 0) { + if (mime_data->data) { SDL_free(mime_data->data); } mime_data->data = internal_buffer; @@ -202,10 +202,10 @@ static void mime_data_list_free(struct wl_list *list) wl_list_for_each_safe(mime_data, next, list, link) { - if (mime_data->data != NULL) { + if (mime_data->data) { SDL_free(mime_data->data); } - if (mime_data->mime_type != NULL) { + if (mime_data->mime_type) { SDL_free(mime_data->mime_type); } SDL_free(mime_data); @@ -216,7 +216,7 @@ static size_t Wayland_send_data(const void *data, size_t length, int fd) { size_t result = 0; - if (length > 0 && data != NULL) { + if (length > 0 && data) { while (write_pipe(fd, data, length, &result) > 0) { /* Just keep spinning */ } @@ -276,9 +276,9 @@ void Wayland_primary_selection_source_set_callback(SDL_WaylandPrimarySelectionSo static void *Wayland_clone_data_buffer(const void *buffer, size_t *len) { void *clone = NULL; - if (*len > 0 && buffer != NULL) { + if (*len > 0 && buffer) { clone = SDL_malloc((*len)+sizeof(Uint32)); - if (clone == NULL) { + if (!clone) { SDL_OutOfMemory(); } else { SDL_memcpy(clone, buffer, *len); @@ -295,9 +295,9 @@ void *Wayland_data_source_get_data(SDL_WaylandDataSource *source, const void *internal_buffer; *length = 0; - if (source == NULL) { + if (!source) { SDL_SetError("Invalid data source"); - } else if (source->callback != NULL) { + } else if (source->callback) { internal_buffer = source->callback(source->userdata.data, mime_type, length); buffer = Wayland_clone_data_buffer(internal_buffer, length); } @@ -312,7 +312,7 @@ void *Wayland_primary_selection_source_get_data(SDL_WaylandPrimarySelectionSourc const void *internal_buffer; *length = 0; - if (source == NULL) { + if (!source) { SDL_SetError("Invalid primary selection source"); } else if (source->callback) { internal_buffer = source->callback(source->userdata.data, mime_type, length); @@ -324,7 +324,7 @@ void *Wayland_primary_selection_source_get_data(SDL_WaylandPrimarySelectionSourc void Wayland_data_source_destroy(SDL_WaylandDataSource *source) { - if (source != NULL) { + if (source) { SDL_WaylandDataDevice *data_device = (SDL_WaylandDataDevice *)source->data_device; if (data_device && (data_device->selection_source == source)) { data_device->selection_source = NULL; @@ -341,7 +341,7 @@ void Wayland_data_source_destroy(SDL_WaylandDataSource *source) void Wayland_primary_selection_source_destroy(SDL_WaylandPrimarySelectionSource *source) { - if (source != NULL) { + if (source) { SDL_WaylandPrimarySelectionDevice *primary_selection_device = (SDL_WaylandPrimarySelectionDevice *)source->primary_selection_device; if (primary_selection_device && (primary_selection_device->selection_source == source)) { primary_selection_device->selection_source = NULL; @@ -363,12 +363,12 @@ void *Wayland_data_offer_receive(SDL_WaylandDataOffer *offer, void *buffer = NULL; *length = 0; - if (offer == NULL) { + if (!offer) { SDL_SetError("Invalid data offer"); return NULL; } data_device = offer->data_device; - if (data_device == NULL) { + if (!data_device) { SDL_SetError("Data device not initialized"); } else if (pipe2(pipefd, O_CLOEXEC | O_NONBLOCK) == -1) { SDL_SetError("Could not read pipe"); @@ -396,12 +396,12 @@ void *Wayland_primary_selection_offer_receive(SDL_WaylandPrimarySelectionOffer * void *buffer = NULL; *length = 0; - if (offer == NULL) { + if (!offer) { SDL_SetError("Invalid data offer"); return NULL; } primary_selection_device = offer->primary_selection_device; - if (primary_selection_device == NULL) { + if (!primary_selection_device) { SDL_SetError("Primary selection device not initialized"); } else if (pipe2(pipefd, O_CLOEXEC | O_NONBLOCK) == -1) { SDL_SetError("Could not read pipe"); @@ -437,7 +437,7 @@ SDL_bool Wayland_data_offer_has_mime(SDL_WaylandDataOffer *offer, { SDL_bool found = SDL_FALSE; - if (offer != NULL) { + if (offer) { found = mime_data_list_find(&offer->mimes, mime_type) != NULL; } return found; @@ -448,7 +448,7 @@ SDL_bool Wayland_primary_selection_offer_has_mime(SDL_WaylandPrimarySelectionOff { SDL_bool found = SDL_FALSE; - if (offer != NULL) { + if (offer) { found = mime_data_list_find(&offer->mimes, mime_type) != NULL; } return found; @@ -456,7 +456,7 @@ SDL_bool Wayland_primary_selection_offer_has_mime(SDL_WaylandPrimarySelectionOff void Wayland_data_offer_destroy(SDL_WaylandDataOffer *offer) { - if (offer != NULL) { + if (offer) { wl_data_offer_destroy(offer->offer); mime_data_list_free(&offer->mimes); SDL_free(offer); @@ -465,7 +465,7 @@ void Wayland_data_offer_destroy(SDL_WaylandDataOffer *offer) void Wayland_primary_selection_offer_destroy(SDL_WaylandPrimarySelectionOffer *offer) { - if (offer != NULL) { + if (offer) { zwp_primary_selection_offer_v1_destroy(offer->offer); mime_data_list_free(&offer->mimes); SDL_free(offer); @@ -476,9 +476,9 @@ int Wayland_data_device_clear_selection(SDL_WaylandDataDevice *data_device) { int status = 0; - if (data_device == NULL || data_device->data_device == NULL) { + if (!data_device || !data_device->data_device) { status = SDL_SetError("Invalid Data Device"); - } else if (data_device->selection_source != NULL) { + } else if (data_device->selection_source) { wl_data_device_set_selection(data_device->data_device, NULL, 0); Wayland_data_source_destroy(data_device->selection_source); data_device->selection_source = NULL; @@ -490,9 +490,9 @@ int Wayland_primary_selection_device_clear_selection(SDL_WaylandPrimarySelection { int status = 0; - if (primary_selection_device == NULL || primary_selection_device->primary_selection_device == NULL) { + if (!primary_selection_device || !primary_selection_device->primary_selection_device) { status = SDL_SetError("Invalid Primary Selection Device"); - } else if (primary_selection_device->selection_source != NULL) { + } else if (primary_selection_device->selection_source) { zwp_primary_selection_device_v1_set_selection(primary_selection_device->primary_selection_device, NULL, 0); Wayland_primary_selection_source_destroy(primary_selection_device->selection_source); @@ -508,9 +508,9 @@ int Wayland_data_device_set_selection(SDL_WaylandDataDevice *data_device, { int status = 0; - if (data_device == NULL) { + if (!data_device) { status = SDL_SetError("Invalid Data Device"); - } else if (source == NULL) { + } else if (!source) { status = SDL_SetError("Invalid source"); } else { size_t index = 0; @@ -532,7 +532,7 @@ int Wayland_data_device_set_selection(SDL_WaylandDataDevice *data_device, source->source, data_device->selection_serial); } - if (data_device->selection_source != NULL) { + if (data_device->selection_source) { Wayland_data_source_destroy(data_device->selection_source); } data_device->selection_source = source; @@ -550,9 +550,9 @@ int Wayland_primary_selection_device_set_selection(SDL_WaylandPrimarySelectionDe { int status = 0; - if (primary_selection_device == NULL) { + if (!primary_selection_device) { status = SDL_SetError("Invalid Primary Selection Device"); - } else if (source == NULL) { + } else if (!source) { status = SDL_SetError("Invalid source"); } else { size_t index = 0; @@ -573,7 +573,7 @@ int Wayland_primary_selection_device_set_selection(SDL_WaylandPrimarySelectionDe source->source, primary_selection_device->selection_serial); } - if (primary_selection_device->selection_source != NULL) { + if (primary_selection_device->selection_source) { Wayland_primary_selection_source_destroy(primary_selection_device->selection_source); } primary_selection_device->selection_source = source; @@ -588,11 +588,11 @@ int Wayland_data_device_set_serial(SDL_WaylandDataDevice *data_device, uint32_t serial) { int status = -1; - if (data_device != NULL) { + if (data_device) { status = 0; /* If there was no serial and there is a pending selection set it now. */ - if (data_device->selection_serial == 0 && data_device->selection_source != NULL) { + if (data_device->selection_serial == 0 && data_device->selection_source) { wl_data_device_set_selection(data_device->data_device, data_device->selection_source->source, data_device->selection_serial); @@ -608,11 +608,11 @@ int Wayland_primary_selection_device_set_serial(SDL_WaylandPrimarySelectionDevic uint32_t serial) { int status = -1; - if (primary_selection_device != NULL) { + if (primary_selection_device) { status = 0; /* If there was no serial and there is a pending selection set it now. */ - if (primary_selection_device->selection_serial == 0 && primary_selection_device->selection_source != NULL) { + if (primary_selection_device->selection_serial == 0 && primary_selection_device->selection_source) { zwp_primary_selection_device_v1_set_selection(primary_selection_device->primary_selection_device, primary_selection_device->selection_source->source, primary_selection_device->selection_serial); diff --git a/src/video/wayland/SDL_waylanddyn.c b/src/video/wayland/SDL_waylanddyn.c index dde99bf4d..7d4dce5c8 100644 --- a/src/video/wayland/SDL_waylanddyn.c +++ b/src/video/wayland/SDL_waylanddyn.c @@ -56,23 +56,23 @@ static void *WAYLAND_GetSym(const char *fnname, int *pHasModule, SDL_bool requir void *fn = NULL; waylanddynlib *dynlib; for (dynlib = waylandlibs; dynlib->libname; dynlib++) { - if (dynlib->lib != NULL) { + if (dynlib->lib) { fn = SDL_LoadFunction(dynlib->lib, fnname); - if (fn != NULL) { + if (fn) { break; } } } #if DEBUG_DYNAMIC_WAYLAND - if (fn != NULL) { + if (fn) { SDL_Log("WAYLAND: Found '%s' in %s (%p)\n", fnname, dynlib->libname, fn); } else { SDL_Log("WAYLAND: Symbol '%s' NOT FOUND!\n", fnname); } #endif - if (fn == NULL && required) { + if (!fn && required) { *pHasModule = 0; /* kill this module. */ } @@ -112,7 +112,7 @@ void SDL_WAYLAND_UnloadSymbols(void) #ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC for (i = 0; i < SDL_TABLESIZE(waylandlibs); i++) { - if (waylandlibs[i].lib != NULL) { + if (waylandlibs[i].lib) { SDL_UnloadObject(waylandlibs[i].lib); waylandlibs[i].lib = NULL; } @@ -133,7 +133,7 @@ int SDL_WAYLAND_LoadSymbols(void) int i; int *thismod = NULL; for (i = 0; i < SDL_TABLESIZE(waylandlibs); i++) { - if (waylandlibs[i].libname != NULL) { + if (waylandlibs[i].libname) { waylandlibs[i].lib = SDL_LoadObject(waylandlibs[i].libname); } } diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c index e5b0e0a83..7d3fab4ef 100644 --- a/src/video/wayland/SDL_waylandevents.c +++ b/src/video/wayland/SDL_waylandevents.c @@ -360,7 +360,7 @@ int Wayland_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS) WAYLAND_wl_display_flush(d->display); #ifdef SDL_USE_IME - if (d->text_input_manager == NULL && SDL_EventEnabled(SDL_EVENT_TEXT_INPUT)) { + if (!d->text_input_manager && SDL_EventEnabled(SDL_EVENT_TEXT_INPUT)) { SDL_IME_PumpEvents(); } #endif @@ -433,7 +433,7 @@ void Wayland_PumpEvents(SDL_VideoDevice *_this) int err; #ifdef SDL_USE_IME - if (d->text_input_manager == NULL && SDL_EventEnabled(SDL_EVENT_TEXT_INPUT)) { + if (!d->text_input_manager && SDL_EventEnabled(SDL_EVENT_TEXT_INPUT)) { SDL_IME_PumpEvents(); } #endif @@ -507,7 +507,7 @@ static void pointer_handle_enter(void *data, struct wl_pointer *pointer, struct SDL_WaylandInput *input = data; SDL_WindowData *window; - if (surface == NULL) { + if (!surface) { /* enter event for a window we've just destroyed */ return; } @@ -549,7 +549,7 @@ static void pointer_handle_leave(void *data, struct wl_pointer *pointer, { struct SDL_WaylandInput *input = data; - if (surface == NULL || !SDL_WAYLAND_own_surface(surface)) { + if (!surface || !SDL_WAYLAND_own_surface(surface)) { return; } @@ -1097,7 +1097,7 @@ static void keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, char *map_str; const char *locale; - if (data == NULL) { + if (!data) { close(fd); return; } @@ -1170,11 +1170,11 @@ static void keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard, /* Look up the preferred locale, falling back to "C" as default */ locale = SDL_getenv("LC_ALL"); - if (locale == NULL) { + if (!locale) { locale = SDL_getenv("LC_CTYPE"); - if (locale == NULL) { + if (!locale) { locale = SDL_getenv("LANG"); - if (locale == NULL) { + if (!locale) { locale = "C"; } } @@ -1378,7 +1378,7 @@ static void keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, SDL_WindowData *window; uint32_t *key; - if (surface == NULL) { + if (!surface) { /* enter event for a window we've just destroyed */ return; } @@ -1431,7 +1431,7 @@ static void keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, struct SDL_WaylandInput *input = data; SDL_WindowData *window; - if (surface == NULL || !SDL_WAYLAND_own_surface(surface)) { + if (!surface || !SDL_WAYLAND_own_surface(surface)) { return; } @@ -1462,7 +1462,7 @@ static SDL_bool keyboard_input_get_text(char text[8], const struct SDL_WaylandIn const xkb_keysym_t *syms; xkb_keysym_t sym; - if (window == NULL || window->keyboard_device != input || !input->xkb.state) { + if (!window || window->keyboard_device != input || !input->xkb.state) { return SDL_FALSE; } @@ -1682,7 +1682,7 @@ static void data_source_handle_send(void *data, struct wl_data_source *wl_data_s static void data_source_handle_cancelled(void *data, struct wl_data_source *wl_data_source) { SDL_WaylandDataSource *source = data; - if (source != NULL) { + if (source) { Wayland_data_source_destroy(source); } } @@ -1732,21 +1732,21 @@ SDL_WaylandDataSource *Wayland_data_source_create(SDL_VideoDevice *_this) SDL_VideoData *driver_data = NULL; struct wl_data_source *id = NULL; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { SDL_SetError("Video driver uninitialized"); } else { driver_data = _this->driverdata; - if (driver_data->data_device_manager != NULL) { + if (driver_data->data_device_manager) { id = wl_data_device_manager_create_data_source( driver_data->data_device_manager); } - if (id == NULL) { + if (!id) { SDL_SetError("Wayland unable to create data source"); } else { data_source = SDL_calloc(1, sizeof(*data_source)); - if (data_source == NULL) { + if (!data_source) { SDL_OutOfMemory(); wl_data_source_destroy(id); } else { @@ -1766,21 +1766,21 @@ SDL_WaylandPrimarySelectionSource *Wayland_primary_selection_source_create(SDL_V SDL_VideoData *driver_data = NULL; struct zwp_primary_selection_source_v1 *id = NULL; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { SDL_SetError("Video driver uninitialized"); } else { driver_data = _this->driverdata; - if (driver_data->primary_selection_device_manager != NULL) { + if (driver_data->primary_selection_device_manager) { id = zwp_primary_selection_device_manager_v1_create_source( driver_data->primary_selection_device_manager); } - if (id == NULL) { + if (!id) { SDL_SetError("Wayland unable to create primary selection source"); } else { primary_selection_source = SDL_calloc(1, sizeof(*primary_selection_source)); - if (primary_selection_source == NULL) { + if (!primary_selection_source) { SDL_OutOfMemory(); zwp_primary_selection_source_v1_destroy(id); } else { @@ -1833,7 +1833,7 @@ static void data_device_handle_data_offer(void *data, struct wl_data_device *wl_ SDL_WaylandDataOffer *data_offer = NULL; data_offer = SDL_calloc(1, sizeof(*data_offer)); - if (data_offer == NULL) { + if (!data_offer) { SDL_OutOfMemory(); } else { data_offer->offer = id; @@ -1854,7 +1854,7 @@ static void data_device_handle_enter(void *data, struct wl_data_device *wl_data_ data_device->drag_serial = serial; - if (id != NULL) { + if (id) { data_device->drag_offer = wl_data_offer_get_user_data(id); /* TODO: SDL Support more mime types */ @@ -1900,7 +1900,7 @@ static void data_device_handle_leave(void *data, struct wl_data_device *wl_data_ { SDL_WaylandDataDevice *data_device = data; - if (data_device->drag_offer != NULL) { + if (data_device->drag_offer) { Wayland_data_offer_destroy(data_device->drag_offer); data_device->drag_offer = NULL; } @@ -1911,7 +1911,7 @@ static void data_device_handle_motion(void *data, struct wl_data_device *wl_data { SDL_WaylandDataDevice *data_device = data; - if (data_device->drag_offer != NULL && data_device->dnd_window) { + if (data_device->drag_offer && data_device->dnd_window) { const float dx = (float)wl_fixed_to_double(x); const float dy = (float)wl_fixed_to_double(y); @@ -1942,7 +1942,7 @@ static int Wayland_URIDecode(char *buf, int len) { int ri, wi, di; char decode = '\0'; - if (buf == NULL || len < 0) { + if (!buf || len < 0) { errno = EINVAL; return -1; } @@ -2020,7 +2020,7 @@ static char *Wayland_URIToLocal(char *uri) /* got a hostname? */ if (!local && uri[0] == '/' && uri[2] != '/') { char *hostname_end = SDL_strchr(uri + 1, '/'); - if (hostname_end != NULL) { + if (hostname_end) { char hostname[257]; if (gethostname(hostname, 255) == 0) { hostname[256] = '\0'; @@ -2048,7 +2048,7 @@ static void data_device_handle_drop(void *data, struct wl_data_device *wl_data_d { SDL_WaylandDataDevice *data_device = data; - if (data_device->drag_offer != NULL && data_device->dnd_window) { + if (data_device->drag_offer && data_device->dnd_window) { /* TODO: SDL Support more mime types */ size_t length; SDL_bool drop_handled = SDL_FALSE; @@ -2081,13 +2081,13 @@ static void data_device_handle_drop(void *data, struct wl_data_device *wl_data_d * non paths that are not visible to the application */ if (!drop_handled && Wayland_data_offer_has_mime( - data_device->drag_offer, FILE_MIME)) { + data_device->drag_offer, FILE_MIME)) { void *buffer = Wayland_data_offer_receive(data_device->drag_offer, FILE_MIME, &length); if (buffer) { char *saveptr = NULL; char *token = SDL_strtok_r((char *)buffer, "\r\n", &saveptr); - while (token != NULL) { + while (token) { char *fn = Wayland_URIToLocal(token); if (fn) { SDL_SendDropFile(data_device->dnd_window, NULL, fn); @@ -2116,7 +2116,7 @@ static void data_device_handle_selection(void *data, struct wl_data_device *wl_d SDL_WaylandDataDevice *data_device = data; SDL_WaylandDataOffer *offer = NULL; - if (id != NULL) { + if (id) { offer = wl_data_offer_get_user_data(id); } @@ -2143,7 +2143,7 @@ static void primary_selection_device_handle_offer(void *data, struct zwp_primary SDL_WaylandPrimarySelectionOffer *primary_selection_offer = NULL; primary_selection_offer = SDL_calloc(1, sizeof(*primary_selection_offer)); - if (primary_selection_offer == NULL) { + if (!primary_selection_offer) { SDL_OutOfMemory(); } else { primary_selection_offer->offer = id; @@ -2160,7 +2160,7 @@ static void primary_selection_device_handle_selection(void *data, struct zwp_pri SDL_WaylandPrimarySelectionDevice *primary_selection_device = data; SDL_WaylandPrimarySelectionOffer *offer = NULL; - if (id != NULL) { + if (id) { offer = zwp_primary_selection_offer_v1_get_user_data(id); } @@ -2270,7 +2270,7 @@ static void Wayland_create_data_device(SDL_VideoData *d) SDL_WaylandDataDevice *data_device = NULL; data_device = SDL_calloc(1, sizeof(*data_device)); - if (data_device == NULL) { + if (!data_device) { return; } @@ -2278,7 +2278,7 @@ static void Wayland_create_data_device(SDL_VideoData *d) d->data_device_manager, d->input->seat); data_device->video_data = d; - if (data_device->data_device == NULL) { + if (!data_device->data_device) { SDL_free(data_device); } else { wl_data_device_set_user_data(data_device->data_device, data_device); @@ -2293,7 +2293,7 @@ static void Wayland_create_primary_selection_device(SDL_VideoData *d) SDL_WaylandPrimarySelectionDevice *primary_selection_device = NULL; primary_selection_device = SDL_calloc(1, sizeof(*primary_selection_device)); - if (primary_selection_device == NULL) { + if (!primary_selection_device) { return; } @@ -2301,7 +2301,7 @@ static void Wayland_create_primary_selection_device(SDL_VideoData *d) d->primary_selection_device_manager, d->input->seat); primary_selection_device->video_data = d; - if (primary_selection_device->primary_selection_device == NULL) { + if (!primary_selection_device->primary_selection_device) { SDL_free(primary_selection_device); } else { zwp_primary_selection_device_v1_set_user_data(primary_selection_device->primary_selection_device, @@ -2317,14 +2317,14 @@ static void Wayland_create_text_input(SDL_VideoData *d) SDL_WaylandTextInput *text_input = NULL; text_input = SDL_calloc(1, sizeof(*text_input)); - if (text_input == NULL) { + if (!text_input) { return; } text_input->text_input = zwp_text_input_manager_v3_get_text_input( d->text_input_manager, d->input->seat); - if (text_input->text_input == NULL) { + if (!text_input->text_input) { SDL_free(text_input); } else { zwp_text_input_v3_set_user_data(text_input->text_input, text_input); @@ -2338,7 +2338,7 @@ void Wayland_add_data_device_manager(SDL_VideoData *d, uint32_t id, uint32_t ver { d->data_device_manager = wl_registry_bind(d->registry, id, &wl_data_device_manager_interface, SDL_min(3, version)); - if (d->input != NULL) { + if (d->input) { Wayland_create_data_device(d); } } @@ -2347,7 +2347,7 @@ void Wayland_add_primary_selection_device_manager(SDL_VideoData *d, uint32_t id, { d->primary_selection_device_manager = wl_registry_bind(d->registry, id, &zwp_primary_selection_device_manager_v1_interface, 1); - if (d->input != NULL) { + if (d->input) { Wayland_create_primary_selection_device(d); } } @@ -2356,7 +2356,7 @@ void Wayland_add_text_input_manager(SDL_VideoData *d, uint32_t id, uint32_t vers { d->text_input_manager = wl_registry_bind(d->registry, id, &zwp_text_input_manager_v3_interface, 1); - if (d->input != NULL) { + if (d->input) { Wayland_create_text_input(d); } } @@ -2396,7 +2396,7 @@ static void tablet_tool_handle_proximity_in(void *data, struct zwp_tablet_tool_v struct SDL_WaylandTabletInput *input = data; SDL_WindowData *window; - if (surface == NULL) { + if (!surface) { return; } @@ -2454,7 +2454,7 @@ static void tablet_tool_handle_down(void *data, struct zwp_tablet_tool_v2 *tool, SDL_WindowData *window = input->tool_focus; input->is_down = SDL_TRUE; Wayland_UpdateImplicitGrabSerial(input->sdlWaylandInput, serial); - if (window == NULL) { + if (!window) { /* tablet_tool_handle_proximity_out gets called when moving over the libdecoration csd. * that sets input->tool_focus (window) to NULL, but handle_{down,up} events are still * received. To prevent SIGSEGV this returns when this is the case. @@ -2472,7 +2472,7 @@ static void tablet_tool_handle_up(void *data, struct zwp_tablet_tool_v2 *tool) input->is_down = SDL_FALSE; - if (window == NULL) { + if (!window) { /* tablet_tool_handle_proximity_out gets called when moving over the libdecoration csd. * that sets input->tool_focus (window) to NULL, but handle_{down,up} events are still * received. To prevent SIGSEGV this returns when this is the case. @@ -2588,7 +2588,7 @@ static struct SDL_WaylandTabletObjectListNode *tablet_object_list_new_node(void struct SDL_WaylandTabletObjectListNode *node; node = SDL_calloc(1, sizeof(*node)); - if (node == NULL) { + if (!node) { return NULL; } @@ -2600,7 +2600,7 @@ static struct SDL_WaylandTabletObjectListNode *tablet_object_list_new_node(void static void tablet_object_list_append(struct SDL_WaylandTabletObjectListNode *head, void *object) { - if (head->object == NULL) { + if (!head->object) { head->object = object; return; } @@ -2658,12 +2658,12 @@ void Wayland_input_add_tablet(struct SDL_WaylandInput *input, struct SDL_Wayland { struct SDL_WaylandTabletInput *tablet_input; - if (tablet_manager == NULL || input == NULL || !input->seat) { + if (!tablet_manager || !input || !input->seat) { return; } tablet_input = SDL_calloc(1, sizeof(*tablet_input)); - if (tablet_input == NULL) { + if (!tablet_input) { return; } @@ -2697,7 +2697,7 @@ void Wayland_display_add_input(SDL_VideoData *d, uint32_t id, uint32_t version) struct SDL_WaylandInput *input; input = SDL_calloc(1, sizeof(*input)); - if (input == NULL) { + if (!input) { return; } @@ -2708,13 +2708,13 @@ void Wayland_display_add_input(SDL_VideoData *d, uint32_t id, uint32_t version) input->xkb.current_group = XKB_GROUP_INVALID; d->input = input; - if (d->data_device_manager != NULL) { + if (d->data_device_manager) { Wayland_create_data_device(d); } - if (d->primary_selection_device_manager != NULL) { + if (d->primary_selection_device_manager) { Wayland_create_primary_selection_device(d); } - if (d->text_input_manager != NULL) { + if (d->text_input_manager) { Wayland_create_text_input(d); } @@ -2732,7 +2732,7 @@ void Wayland_display_destroy_input(SDL_VideoData *d) { struct SDL_WaylandInput *input = d->input; - if (input == NULL) { + if (!input) { return; } @@ -2746,15 +2746,15 @@ void Wayland_display_destroy_input(SDL_VideoData *d) zwp_input_timestamps_v1_destroy(input->touch_timestamps); } - if (input->data_device != NULL) { + if (input->data_device) { Wayland_data_device_clear_selection(input->data_device); - if (input->data_device->selection_offer != NULL) { + if (input->data_device->selection_offer) { Wayland_data_offer_destroy(input->data_device->selection_offer); } - if (input->data_device->drag_offer != NULL) { + if (input->data_device->drag_offer) { Wayland_data_offer_destroy(input->data_device->drag_offer); } - if (input->data_device->data_device != NULL) { + if (input->data_device->data_device) { if (wl_data_device_get_version(input->data_device->data_device) >= WL_DATA_DEVICE_RELEASE_SINCE_VERSION) { wl_data_device_release(input->data_device->data_device); } else { @@ -2764,20 +2764,20 @@ void Wayland_display_destroy_input(SDL_VideoData *d) SDL_free(input->data_device); } - if (input->primary_selection_device != NULL) { - if (input->primary_selection_device->selection_offer != NULL) { + if (input->primary_selection_device) { + if (input->primary_selection_device->selection_offer) { Wayland_primary_selection_offer_destroy(input->primary_selection_device->selection_offer); } - if (input->primary_selection_device->selection_source != NULL) { + if (input->primary_selection_device->selection_source) { Wayland_primary_selection_source_destroy(input->primary_selection_device->selection_source); } - if (input->primary_selection_device->primary_selection_device != NULL) { + if (input->primary_selection_device->primary_selection_device) { zwp_primary_selection_device_v1_destroy(input->primary_selection_device->primary_selection_device); } SDL_free(input->primary_selection_device); } - if (input->text_input != NULL) { + if (input->text_input) { zwp_text_input_v3_destroy(input->text_input->text_input); SDL_free(input->text_input); } @@ -3078,7 +3078,7 @@ int Wayland_input_confine_pointer(struct SDL_WaylandInput *input, SDL_Window *wi &confined_pointer_listener, window); - if (confine_rect != NULL) { + if (confine_rect) { wl_region_destroy(confine_rect); } diff --git a/src/video/wayland/SDL_waylandkeyboard.c b/src/video/wayland/SDL_waylandkeyboard.c index 3aa52f38f..17dc4f867 100644 --- a/src/video/wayland/SDL_waylandkeyboard.c +++ b/src/video/wayland/SDL_waylandkeyboard.c @@ -32,7 +32,7 @@ int Wayland_InitKeyboard(SDL_VideoDevice *_this) { #ifdef SDL_USE_IME SDL_VideoData *driverdata = _this->driverdata; - if (driverdata->text_input_manager == NULL) { + if (!driverdata->text_input_manager) { SDL_IME_Init(); } #endif @@ -45,7 +45,7 @@ void Wayland_QuitKeyboard(SDL_VideoDevice *_this) { #ifdef SDL_USE_IME SDL_VideoData *driverdata = _this->driverdata; - if (driverdata->text_input_manager == NULL) { + if (!driverdata->text_input_manager) { SDL_IME_Quit(); } #endif @@ -57,7 +57,7 @@ void Wayland_StartTextInput(SDL_VideoDevice *_this) if (driverdata->text_input_manager) { struct SDL_WaylandInput *input = driverdata->input; - if (input != NULL && input->text_input) { + if (input && input->text_input) { const SDL_Rect *rect = &input->text_input->cursor_rect; /* Don't re-enable if we're already enabled. */ @@ -98,7 +98,7 @@ void Wayland_StopTextInput(SDL_VideoDevice *_this) if (driverdata->text_input_manager) { struct SDL_WaylandInput *input = driverdata->input; - if (input != NULL && input->text_input) { + if (input && input->text_input) { zwp_text_input_v3_disable(input->text_input->text_input); zwp_text_input_v3_commit(input->text_input->text_input); input->text_input->is_enabled = SDL_FALSE; @@ -117,7 +117,7 @@ int Wayland_SetTextInputRect(SDL_VideoDevice *_this, const SDL_Rect *rect) SDL_VideoData *driverdata = _this->driverdata; if (driverdata->text_input_manager) { struct SDL_WaylandInput *input = driverdata->input; - if (input != NULL && input->text_input) { + if (input && input->text_input) { if (!SDL_RectsEqual(rect, &input->text_input->cursor_rect)) { SDL_copyp(&input->text_input->cursor_rect, rect); zwp_text_input_v3_set_cursor_rectangle(input->text_input->text_input, diff --git a/src/video/wayland/SDL_waylandmessagebox.c b/src/video/wayland/SDL_waylandmessagebox.c index 790be39e8..2fda9eef9 100644 --- a/src/video/wayland/SDL_waylandmessagebox.c +++ b/src/video/wayland/SDL_waylandmessagebox.c @@ -91,7 +91,7 @@ static int get_zenity_version(int *major, int *minor) close(fd_pipe[1]); outputfp = fdopen(fd_pipe[0], "r"); - if (outputfp == NULL) { + if (!outputfp) { close(fd_pipe[0]); return SDL_SetError("failed to open pipe for reading: %s", strerror(errno)); } @@ -99,7 +99,7 @@ static int get_zenity_version(int *major, int *minor) version_ptr = fgets(version_str, ZENITY_VERSION_LEN, outputfp); (void)fclose(outputfp); /* will close underlying fd */ - if (version_ptr == NULL) { + if (!version_ptr) { return SDL_SetError("failed to read zenity version string"); } @@ -213,7 +213,7 @@ int Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *button char *output = NULL; char *tmp = NULL; - if (buttonid == NULL) { + if (!buttonid) { /* if we don't need buttonid, we can return immediately */ close(fd_pipe[0]); return 0; /* success */ @@ -221,14 +221,14 @@ int Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *button *buttonid = -1; output = SDL_malloc(output_len + 1); - if (output == NULL) { + if (!output) { close(fd_pipe[0]); return SDL_OutOfMemory(); } output[0] = '\0'; outputfp = fdopen(fd_pipe[0], "r"); - if (outputfp == NULL) { + if (!outputfp) { SDL_free(output); close(fd_pipe[0]); return SDL_SetError("Couldn't open pipe for reading: %s", strerror(errno)); @@ -236,20 +236,20 @@ int Wayland_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *button tmp = fgets(output, output_len + 1, outputfp); (void)fclose(outputfp); - if ((tmp == NULL) || (*tmp == '\0') || (*tmp == '\n')) { + if ((!tmp) || (*tmp == '\0') || (*tmp == '\n')) { SDL_free(output); return 0; /* User simply closed the dialog */ } /* It likes to add a newline... */ tmp = SDL_strrchr(output, '\n'); - if (tmp != NULL) { + if (tmp) { *tmp = '\0'; } /* Check which button got pressed */ for (i = 0; i < messageboxdata->numbuttons; i += 1) { - if (messageboxdata->buttons[i].text != NULL) { + if (messageboxdata->buttons[i].text) { if (SDL_strcmp(output, messageboxdata->buttons[i].text) == 0) { *buttonid = messageboxdata->buttons[i].buttonid; break; diff --git a/src/video/wayland/SDL_waylandmouse.c b/src/video/wayland/SDL_waylandmouse.c index 815c50438..8895e4cbc 100644 --- a/src/video/wayland/SDL_waylandmouse.c +++ b/src/video/wayland/SDL_waylandmouse.c @@ -215,7 +215,7 @@ static void Wayland_DBusInitCursorProperties(SDL_VideoData *vdata) SDL_DBusContext *dbus = SDL_DBus_GetContext(); SDL_bool add_filter = SDL_FALSE; - if (dbus == NULL) { + if (!dbus) { return; } @@ -279,7 +279,7 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, Wayland_CursorDa } /* First, find the appropriate theme based on the current scale... */ focus = SDL_GetMouse()->focus; - if (focus == NULL) { + if (!focus) { /* Nothing to see here, bail. */ return SDL_FALSE; } @@ -294,12 +294,12 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, Wayland_CursorDa break; } } - if (theme == NULL) { + if (!theme) { const char *xcursor_theme = dbus_cursor_theme; vdata->cursor_themes = SDL_realloc(vdata->cursor_themes, sizeof(SDL_WaylandCursorTheme) * (vdata->num_cursor_themes + 1)); - if (vdata->cursor_themes == NULL) { + if (!vdata->cursor_themes) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -382,7 +382,7 @@ static int wayland_create_tmp_file(off_t size) int fd; xdg_path = SDL_getenv("XDG_RUNTIME_DIR"); - if (xdg_path == NULL) { + if (!xdg_path) { return -1; } @@ -441,7 +441,7 @@ static int create_buffer_from_shm(Wayland_CursorData *d, return SDL_SetError("mmap() failed."); } - SDL_assert(d->shm_data != NULL); + SDL_assert(d->shm_data); shm_pool = wl_shm_create_pool(data->shm, shm_fd, size); d->buffer = wl_shm_pool_create_buffer(shm_pool, @@ -469,7 +469,7 @@ static SDL_Cursor *Wayland_CreateCursor(SDL_Surface *surface, int hot_x, int hot SDL_VideoDevice *vd = SDL_GetVideoDevice(); SDL_VideoData *wd = vd->driverdata; Wayland_CursorData *data = SDL_calloc(1, sizeof(Wayland_CursorData)); - if (data == NULL) { + if (!data) { SDL_OutOfMemory(); SDL_free(cursor); return NULL; @@ -513,7 +513,7 @@ static SDL_Cursor *Wayland_CreateSystemCursor(SDL_SystemCursor id) cursor = SDL_calloc(1, sizeof(*cursor)); if (cursor) { Wayland_CursorData *cdata = SDL_calloc(1, sizeof(Wayland_CursorData)); - if (cdata == NULL) { + if (!cdata) { SDL_OutOfMemory(); SDL_free(cursor); return NULL; @@ -556,7 +556,7 @@ static void Wayland_FreeCursorData(Wayland_CursorData *d) static void Wayland_FreeCursor(SDL_Cursor *cursor) { - if (cursor == NULL) { + if (!cursor) { return; } @@ -580,7 +580,7 @@ static int Wayland_ShowCursor(SDL_Cursor *cursor) struct wl_pointer *pointer = d->pointer; float scale = 1.0f; - if (pointer == NULL) { + if (!pointer) { return -1; } @@ -588,7 +588,7 @@ static int Wayland_ShowCursor(SDL_Cursor *cursor) Wayland_CursorData *data = cursor->driverdata; /* TODO: High-DPI custom cursors? -flibit */ - if (data->shm_data == NULL) { + if (!data->shm_data) { if (!wayland_get_system_cursor(d, data, &scale)) { return -1; } diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c index 96d7f390f..dfcf717c6 100644 --- a/src/video/wayland/SDL_waylandvideo.c +++ b/src/video/wayland/SDL_waylandvideo.c @@ -140,13 +140,13 @@ static SDL_VideoDevice *Wayland_CreateDevice(void) } display = WAYLAND_wl_display_connect(NULL); - if (display == NULL) { + if (!display) { SDL_WAYLAND_UnloadSymbols(); return NULL; } data = SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { WAYLAND_wl_display_disconnect(display); SDL_WAYLAND_UnloadSymbols(); SDL_OutOfMemory(); @@ -159,7 +159,7 @@ static SDL_VideoDevice *Wayland_CreateDevice(void) /* Initialize all variables that we clean on shutdown */ device = SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_free(data); WAYLAND_wl_display_disconnect(display); SDL_WAYLAND_UnloadSymbols(); @@ -414,7 +414,7 @@ static void display_handle_geometry(void *data, driverdata->physical_height = physical_height; /* The model is only used for the output name if wl_output or xdg-output haven't provided a description. */ - if (driverdata->display == 0 && driverdata->placeholder.name == NULL) { + if (driverdata->display == 0 && !driverdata->placeholder.name) { driverdata->placeholder.name = SDL_strdup(model); } @@ -573,7 +573,7 @@ static void display_handle_done(void *data, SDL_SetDesktopDisplayMode(dpy, &desktop_mode); /* Expose the unscaled, native resolution if the scale is 1.0 or viewports are available... */ - if (driverdata->scale_factor == 1.0f || video->viewporter != NULL) { + if (driverdata->scale_factor == 1.0f || video->viewporter) { SDL_AddFullscreenDisplayMode(dpy, &native_mode); } else { /* ...otherwise expose the integer scaled variants of the desktop resolution down to 1. */ @@ -650,7 +650,7 @@ static int Wayland_add_display(SDL_VideoData *d, uint32_t id, uint32_t version) SDL_DisplayData *data; output = wl_registry_bind(d->registry, id, &wl_output_interface, version); - if (output == NULL) { + if (!output) { return SDL_SetError("Failed to retrieve output."); } data = (SDL_DisplayData *)SDL_calloc(1, sizeof(*data)); @@ -858,7 +858,7 @@ int Wayland_VideoInit(SDL_VideoDevice *_this) } data->registry = wl_display_get_registry(data->display); - if (data->registry == NULL) { + if (!data->registry) { return SDL_SetError("Failed to get the Wayland registry"); } diff --git a/src/video/wayland/SDL_waylandvulkan.c b/src/video/wayland/SDL_waylandvulkan.c index 75cef415f..a82a5fd9e 100644 --- a/src/video/wayland/SDL_waylandvulkan.c +++ b/src/video/wayland/SDL_waylandvulkan.c @@ -54,10 +54,10 @@ int Wayland_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) } /* Load the Vulkan loader library */ - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_VULKAN_LIBRARY"); } - if (path == NULL) { + if (!path) { path = DEFAULT_VULKAN; } _this->vulkan_config.loader_handle = SDL_LoadObject(path); @@ -82,7 +82,7 @@ int Wayland_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) (PFN_vkEnumerateInstanceExtensionProperties) _this->vulkan_config.vkEnumerateInstanceExtensionProperties, &extensionCount); - if (extensions == NULL) { + if (!extensions) { goto fail; } for (i = 0; i < extensionCount; i++) { diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c index 7e00c63a3..91a82d761 100644 --- a/src/video/wayland/SDL_waylandwindow.c +++ b/src/video/wayland/SDL_waylandwindow.c @@ -114,7 +114,7 @@ static SDL_bool WindowNeedsViewport(SDL_Window *window) * - The surface scale is fractional. * - An exclusive fullscreen mode is being emulated and the mode does not match the requested output size. */ - if (video->viewporter != NULL) { + if (video->viewporter) { if (SurfaceScaleIsFractional(window)) { return SDL_TRUE; } else if (window->fullscreen_exclusive) { @@ -157,7 +157,7 @@ static void SetDrawSurfaceViewport(SDL_Window *window, int src_width, int src_he SDL_VideoData *video = wind->waylandData; if (video->viewporter) { - if (wind->draw_viewport == NULL) { + if (!wind->draw_viewport) { wind->draw_viewport = wp_viewporter_get_viewport(video->viewporter, wind->surface); } @@ -201,7 +201,7 @@ static void SetMinMaxDimensions(SDL_Window *window) #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (!wind->shell_surface.libdecor.initial_configure_seen || wind->shell_surface.libdecor.frame == NULL) { + if (!wind->shell_surface.libdecor.initial_configure_seen || !wind->shell_surface.libdecor.frame) { return; /* Can't do anything yet, wait for ShowWindow */ } /* No need to change these values if the window is non-resizable, @@ -417,7 +417,7 @@ static void ConfigureWindowGeometry(SDL_Window *window) /* libdecor does this internally on frame commits, so it's only needed for xdg surfaces. */ if (data->shell_surface_type != WAYLAND_SURFACE_LIBDECOR && - viddata->shell.xdg && data->shell_surface.xdg.surface != NULL) { + viddata->shell.xdg && data->shell_surface.xdg.surface) { xdg_surface_set_window_geometry(data->shell_surface.xdg.surface, 0, 0, data->wl_window_width, data->wl_window_height); } @@ -430,7 +430,7 @@ static void ConfigureWindowGeometry(SDL_Window *window) } /* Ensure that child popup windows are still in bounds. */ - for (SDL_Window *child = window->first_child; child != NULL; child = child->next_sibling) { + for (SDL_Window *child = window->first_child; child; child = child->next_sibling) { RepositionPopup(child); } @@ -486,7 +486,7 @@ static void SetFullscreen(SDL_Window *window, struct wl_output *output) #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (wind->shell_surface.libdecor.frame == NULL) { + if (!wind->shell_surface.libdecor.frame) { return; /* Can't do anything yet, wait for ShowWindow */ } if (output) { @@ -570,7 +570,7 @@ static void surface_frame_done(void *data, struct wl_callback *cb, uint32_t time wind->surface_status = WAYLAND_SURFACE_STATUS_SHOWN; /* If any child windows are waiting on this window to be shown, show them now */ - for (SDL_Window *w = wind->sdlwindow->first_child; w != NULL; w = w->next_sibling) { + for (SDL_Window *w = wind->sdlwindow->first_child; w; w = w->next_sibling) { if (w->driverdata->surface_status == WAYLAND_SURFACE_STATUS_SHOW_PENDING) { Wayland_ShowWindow(SDL_GetVideoDevice(), w); } @@ -876,7 +876,7 @@ static const struct zxdg_toplevel_decoration_v1_listener decoration_listener = { static void OverrideLibdecorLimits(SDL_Window *window) { #ifdef SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR - if (libdecor_frame_get_min_content_size == NULL) { + if (!libdecor_frame_get_min_content_size) { libdecor_frame_set_min_content_size(window->driverdata->shell_surface.libdecor.frame, window->min_w, window->min_h); } #elif !defined(SDL_HAVE_LIBDECOR_VER_0_2_0) @@ -1287,7 +1287,7 @@ static void SetKeyboardFocus(SDL_Window *window) SDL_Window *topmost = window; /* Find the topmost parent */ - while (topmost->parent != NULL) { + while (topmost->parent) { topmost = topmost->parent; } @@ -1318,10 +1318,10 @@ int Wayland_SetWindowModalFor(SDL_VideoDevice *_this, SDL_Window *modal_window, #ifdef HAVE_LIBDECOR_H if (viddata->shell.libdecor) { - if (modal_data->shell_surface.libdecor.frame == NULL) { + if (!modal_data->shell_surface.libdecor.frame) { return SDL_SetError("Modal window was hidden"); } - if (parent_data->shell_surface.libdecor.frame == NULL) { + if (!parent_data->shell_surface.libdecor.frame) { return SDL_SetError("Parent window was hidden"); } libdecor_frame_set_parent(modal_data->shell_surface.libdecor.frame, @@ -1392,7 +1392,7 @@ void Wayland_ShowWindow(SDL_VideoDevice *_this, SDL_Window *window) data->surface, &libdecor_frame_interface, data); - if (data->shell_surface.libdecor.frame == NULL) { + if (!data->shell_surface.libdecor.frame) { SDL_LogError(SDL_LOG_CATEGORY_VIDEO, "Failed to create libdecor frame!"); } else { libdecor_frame_set_app_id(data->shell_surface.libdecor.frame, data->app_id); @@ -1572,11 +1572,11 @@ static void Wayland_ReleasePopup(SDL_VideoDevice *_this, SDL_Window *popup) SDL_WindowData *popupdata; /* Basic sanity checks to weed out the weird popup closures */ - if (popup == NULL || popup->magic != &_this->window_magic) { + if (!popup || popup->magic != &_this->window_magic) { return; } popupdata = popup->driverdata; - if (popupdata == NULL) { + if (!popupdata) { return; } @@ -1590,7 +1590,7 @@ static void Wayland_ReleasePopup(SDL_VideoDevice *_this, SDL_Window *popup) SDL_Window *new_focus = popup->parent; /* Find the highest level window that isn't being hidden or destroyed. */ - while (new_focus->parent != NULL && (new_focus->is_hiding || new_focus->is_destroying)) { + while (new_focus->parent && (new_focus->is_hiding || new_focus->is_destroying)) { new_focus = new_focus->parent; } @@ -1705,7 +1705,7 @@ static void Wayland_activate_window(SDL_VideoData *data, SDL_WindowData *target_ struct wl_surface *requesting_surface = focus ? focus->driverdata->surface : NULL; if (data->activation_manager) { - if (target_wind->activation_token != NULL) { + if (target_wind->activation_token) { /* We're about to overwrite this with a new request */ xdg_activation_token_v1_destroy(target_wind->activation_token); } @@ -1722,7 +1722,7 @@ static void Wayland_activate_window(SDL_VideoData *data, SDL_WindowData *target_ * * -flibit */ - if (requesting_surface != NULL) { + if (requesting_surface) { /* This specifies the surface from which the activation request is originating, not the activation target surface. */ xdg_activation_token_v1_set_surface(target_wind->activation_token, requesting_surface); } @@ -1803,7 +1803,7 @@ void Wayland_RestoreWindow(SDL_VideoDevice *_this, SDL_Window *window) #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (wind->shell_surface.libdecor.frame == NULL) { + if (!wind->shell_surface.libdecor.frame) { return; /* Can't do anything yet, wait for ShowWindow */ } libdecor_frame_unset_maximized(wind->shell_surface.libdecor.frame); @@ -1848,7 +1848,7 @@ void Wayland_SetWindowResizable(SDL_VideoDevice *_this, SDL_Window *window, SDL_ const SDL_WindowData *wind = window->driverdata; if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (wind->shell_surface.libdecor.frame == NULL) { + if (!wind->shell_surface.libdecor.frame) { return; /* Can't do anything yet, wait for ShowWindow */ } if (libdecor_frame_has_capability(wind->shell_surface.libdecor.frame, LIBDECOR_ACTION_RESIZE)) { @@ -1883,7 +1883,7 @@ void Wayland_MaximizeWindow(SDL_VideoDevice *_this, SDL_Window *window) #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (wind->shell_surface.libdecor.frame == NULL) { + if (!wind->shell_surface.libdecor.frame) { return; /* Can't do anything yet, wait for ShowWindow */ } libdecor_frame_set_maximized(wind->shell_surface.libdecor.frame); @@ -1914,7 +1914,7 @@ void Wayland_MinimizeWindow(SDL_VideoDevice *_this, SDL_Window *window) #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (wind->shell_surface.libdecor.frame == NULL) { + if (!wind->shell_surface.libdecor.frame) { return; /* Can't do anything yet, wait for ShowWindow */ } libdecor_frame_set_minimized(wind->shell_surface.libdecor.frame); @@ -1981,7 +1981,7 @@ int Wayland_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) SDL_VideoData *c; data = SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } @@ -2182,7 +2182,7 @@ void Wayland_SetWindowTitle(SDL_VideoDevice *_this, SDL_Window *window) #ifdef HAVE_LIBDECOR_H if (wind->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (wind->shell_surface.libdecor.frame == NULL) { + if (!wind->shell_surface.libdecor.frame) { return; /* Can't do anything yet, wait for ShowWindow */ } libdecor_frame_set_title(wind->shell_surface.libdecor.frame, title); diff --git a/src/video/windows/SDL_windowsclipboard.c b/src/video/windows/SDL_windowsclipboard.c index fabb3d6b3..bac510aae 100644 --- a/src/video/windows/SDL_windowsclipboard.c +++ b/src/video/windows/SDL_windowsclipboard.c @@ -288,7 +288,7 @@ void *WIN_GetClipboardData(SDL_VideoDevice *_this, const char *mime_type, size_t WIN_CloseClipboard(); } } - if (text == NULL) { + if (!text) { text = SDL_strdup(""); } data = text; diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c index cc6b1f63b..7a797561a 100644 --- a/src/video/windows/SDL_windowsevents.c +++ b/src/video/windows/SDL_windowsevents.c @@ -721,12 +721,12 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) /* Get the window data for the window */ data = WIN_GetWindowDataFromHWND(hwnd); #if !defined(__XBOXONE__) && !defined(__XBOXSERIES__) - if (data == NULL) { + if (!data) { /* Fallback */ data = (SDL_WindowData *)GetProp(hwnd, TEXT("SDL_WindowData")); } #endif - if (data == NULL) { + if (!data) { return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam); } @@ -1280,7 +1280,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } /* Update the position of any child windows */ - for (win = data->window->first_child; win != NULL; win = win->next_sibling) { + for (win = data->window->first_child; win; win = win->next_sibling) { /* Don't update hidden child windows, their relative position doesn't change */ if (!(win->flags & SDL_WINDOW_HIDDEN)) { WIN_SetWindowPositionInternal(win, SWP_NOCOPYBITS | SWP_NOACTIVATE); @@ -1783,8 +1783,10 @@ static void WIN_UpdateMouseCapture() SDL_MouseID mouseID = SDL_GetMouse()->mouseID; SDL_SendMouseMotion(WIN_GetEventTimestamp(), data->window, mouseID, 0, (float)cursorPos.x, (float)cursorPos.y); - SDL_SendMouseButton(WIN_GetEventTimestamp(), data->window, mouseID, GetAsyncKeyState(VK_LBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, !swapButtons ? SDL_BUTTON_LEFT : SDL_BUTTON_RIGHT); - SDL_SendMouseButton(WIN_GetEventTimestamp(), data->window, mouseID, GetAsyncKeyState(VK_RBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, !swapButtons ? SDL_BUTTON_RIGHT : SDL_BUTTON_LEFT); + SDL_SendMouseButton(WIN_GetEventTimestamp(), data->window, mouseID, GetAsyncKeyState(VK_LBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, + !swapButtons ? SDL_BUTTON_LEFT : SDL_BUTTON_RIGHT); + SDL_SendMouseButton(WIN_GetEventTimestamp(), data->window, mouseID, GetAsyncKeyState(VK_RBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, + !swapButtons ? SDL_BUTTON_RIGHT : SDL_BUTTON_LEFT); SDL_SendMouseButton(WIN_GetEventTimestamp(), data->window, mouseID, GetAsyncKeyState(VK_MBUTTON) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_MIDDLE); SDL_SendMouseButton(WIN_GetEventTimestamp(), data->window, mouseID, GetAsyncKeyState(VK_XBUTTON1) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_X1); SDL_SendMouseButton(WIN_GetEventTimestamp(), data->window, mouseID, GetAsyncKeyState(VK_XBUTTON2) & 0x8000 ? SDL_PRESSED : SDL_RELEASED, SDL_BUTTON_X2); @@ -1820,7 +1822,7 @@ int WIN_WaitEventTimeout(SDL_VideoDevice *_this, Sint64 timeoutNS) message_result = GetMessage(&msg, 0, 0, 0); } if (message_result) { - if (msg.message == WM_TIMER && msg.hwnd == NULL && msg.wParam == timer_id) { + if (msg.message == WM_TIMER && !msg.hwnd && msg.wParam == timer_id) { return 0; } if (g_WindowsMessageHook) { @@ -1919,7 +1921,7 @@ void WIN_PumpEvents(SDL_VideoDevice *_this) not grabbing the keyboard. Note: If we *are* grabbing the keyboard, GetKeyState() will return inaccurate results for VK_LWIN and VK_RWIN but we don't need it anyway. */ focusWindow = SDL_GetKeyboardFocus(); - if (focusWindow == NULL || !(focusWindow->flags & SDL_WINDOW_KEYBOARD_GRABBED)) { + if (!focusWindow || !(focusWindow->flags & SDL_WINDOW_KEYBOARD_GRABBED)) { if ((keystate[SDL_SCANCODE_LGUI] == SDL_PRESSED) && !(GetKeyState(VK_LWIN) & 0x8000)) { SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_LGUI); } @@ -1973,8 +1975,8 @@ int SDL_RegisterApp(const char *name, Uint32 style, void *hInst) ++app_registered; return 0; } - SDL_assert(SDL_Appname == NULL); - if (name == NULL) { + SDL_assert(!SDL_Appname); + if (!name) { name = "SDL_app"; #if defined(CS_BYTEALIGNCLIENT) || defined(CS_OWNDC) style = (CS_BYTEALIGNCLIENT | CS_OWNDC); diff --git a/src/video/windows/SDL_windowsframebuffer.c b/src/video/windows/SDL_windowsframebuffer.c index aab98603a..9be7cc83b 100644 --- a/src/video/windows/SDL_windowsframebuffer.c +++ b/src/video/windows/SDL_windowsframebuffer.c @@ -114,7 +114,7 @@ void WIN_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window) { SDL_WindowData *data = window->driverdata; - if (data == NULL) { + if (!data) { /* The window wasn't fully initialized */ return; } diff --git a/src/video/windows/SDL_windowskeyboard.c b/src/video/windows/SDL_windowskeyboard.c index 3d5589543..7f09c32ec 100644 --- a/src/video/windows/SDL_windowskeyboard.c +++ b/src/video/windows/SDL_windowskeyboard.c @@ -693,7 +693,7 @@ static void IME_SetupAPI(SDL_VideoData *videodata) } hime = SDL_LoadObject(ime_file); - if (hime == NULL) { + if (!hime) { return; } @@ -776,7 +776,7 @@ static void IME_GetCompositionString(SDL_VideoData *videodata, HIMC himc, DWORD length = ImmGetCompositionStringW(himc, string, NULL, 0); if (length > 0 && videodata->ime_composition_length < length) { - if (videodata->ime_composition != NULL) { + if (videodata->ime_composition) { SDL_free(videodata->ime_composition); } @@ -968,11 +968,11 @@ static int IME_ShowCandidateList(SDL_VideoData *videodata) videodata->ime_candcount = 0; candidates = SDL_realloc(videodata->ime_candidates, MAX_CANDSIZE); - if (candidates != NULL) { + if (candidates) { videodata->ime_candidates = (WCHAR *)candidates; } - if (videodata->ime_candidates == NULL) { + if (!videodata->ime_candidates) { return -1; } @@ -1186,7 +1186,7 @@ TSFSink_Release(TSFSink *sink) STDMETHODIMP UIElementSink_QueryInterface(TSFSink *sink, REFIID riid, PVOID *ppv) { - if (ppv == NULL) { + if (!ppv) { return E_INVALIDARG; } @@ -1223,7 +1223,7 @@ STDMETHODIMP UIElementSink_BeginUIElement(TSFSink *sink, DWORD dwUIElementId, BO ITfReadingInformationUIElement *preading = 0; ITfCandidateListUIElement *pcandlist = 0; SDL_VideoData *videodata = (SDL_VideoData *)sink->data; - if (element == NULL) { + if (!element) { return E_INVALIDARG; } @@ -1248,7 +1248,7 @@ STDMETHODIMP UIElementSink_UpdateUIElement(TSFSink *sink, DWORD dwUIElementId) ITfReadingInformationUIElement *preading = 0; ITfCandidateListUIElement *pcandlist = 0; SDL_VideoData *videodata = (SDL_VideoData *)sink->data; - if (element == NULL) { + if (!element) { return E_INVALIDARG; } @@ -1274,7 +1274,7 @@ STDMETHODIMP UIElementSink_EndUIElement(TSFSink *sink, DWORD dwUIElementId) ITfReadingInformationUIElement *preading = 0; ITfCandidateListUIElement *pcandlist = 0; SDL_VideoData *videodata = (SDL_VideoData *)sink->data; - if (element == NULL) { + if (!element) { return E_INVALIDARG; } @@ -1296,7 +1296,7 @@ STDMETHODIMP UIElementSink_EndUIElement(TSFSink *sink, DWORD dwUIElementId) STDMETHODIMP IPPASink_QueryInterface(TSFSink *sink, REFIID riid, PVOID *ppv) { - if (ppv == NULL) { + if (!ppv) { return E_INVALIDARG; } diff --git a/src/video/windows/SDL_windowsmessagebox.c b/src/video/windows/SDL_windowsmessagebox.c index b5459da5e..689121c2a 100644 --- a/src/video/windows/SDL_windowsmessagebox.c +++ b/src/video/windows/SDL_windowsmessagebox.c @@ -265,7 +265,7 @@ static INT_PTR CALLBACK MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wP if (GetButtonIndex(messageboxdata, SDL_MESSAGEBOX_BUTTON_RETURNKEY_DEFAULT, &buttonindex)) { /* Focus on the first default return-key button */ HWND buttonctl = GetDlgItem(hDlg, (int)(IDBUTTONINDEX0 + buttonindex)); - if (buttonctl == NULL) { + if (!buttonctl) { EndDialog(hDlg, IDINVALPTRDLGITEM); } PostMessage(hDlg, WM_NEXTDLGCTL, (WPARAM)buttonctl, TRUE); @@ -276,7 +276,7 @@ static INT_PTR CALLBACK MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wP return FALSE; case WM_SETFOCUS: messageboxdata = (const SDL_MessageBoxData *)GetWindowLongPtr(hDlg, GWLP_USERDATA); - if (messageboxdata == NULL) { + if (!messageboxdata) { EndDialog(hDlg, IDINVALPTRSETFOCUS); return TRUE; } @@ -288,7 +288,7 @@ static INT_PTR CALLBACK MessageBoxDialogProc(HWND hDlg, UINT iMessage, WPARAM wP return TRUE; case WM_COMMAND: messageboxdata = (const SDL_MessageBoxData *)GetWindowLongPtr(hDlg, GWLP_USERDATA); - if (messageboxdata == NULL) { + if (!messageboxdata) { EndDialog(hDlg, IDINVALPTRCOMMAND); return TRUE; } @@ -344,7 +344,7 @@ static SDL_bool ExpandDialogSpace(WIN_DialogData *dialog, size_t space) if (size > dialog->size) { void *data = SDL_realloc(dialog->data, size); - if (data == NULL) { + if (!data) { SDL_OutOfMemory(); return SDL_FALSE; } @@ -387,12 +387,12 @@ static SDL_bool AddDialogString(WIN_DialogData *dialog, const char *string) size_t count; SDL_bool status; - if (string == NULL) { + if (!string) { string = ""; } wstring = WIN_UTF8ToStringW(string); - if (wstring == NULL) { + if (!wstring) { return SDL_FALSE; } @@ -448,7 +448,7 @@ static SDL_bool AddDialogControl(WIN_DialogData *dialog, WORD type, DWORD style, if (!AddDialogData(dialog, &type, sizeof(type))) { return SDL_FALSE; } - if (type == DLGITEMTYPEBUTTON || (type == DLGITEMTYPESTATIC && caption != NULL)) { + if (type == DLGITEMTYPEBUTTON || (type == DLGITEMTYPESTATIC && caption)) { if (!AddDialogString(dialog, caption)) { return SDL_FALSE; } @@ -521,7 +521,7 @@ static WIN_DialogData *CreateDialogData(int w, int h, const char *caption) Vec2ToDLU(&dialogTemplate.cx, &dialogTemplate.cy); dialog = (WIN_DialogData *)SDL_calloc(1, sizeof(*dialog)); - if (dialog == NULL) { + if (!dialog) { return NULL; } @@ -623,7 +623,7 @@ static const char *EscapeAmpersands(char **dst, size_t *dstlen, const char *src) size_t ampcount = 0; size_t srclen = 0; - if (src == NULL) { + if (!src) { return NULL; } @@ -642,7 +642,7 @@ static const char *EscapeAmpersands(char **dst, size_t *dstlen, const char *src) if (SIZE_MAX - srclen < ampcount) { return NULL; } - if (*dst == NULL || *dstlen < srclen + ampcount) { + if (!*dst || *dstlen < srclen + ampcount) { /* Allocating extra space in case the next strings are a bit longer. */ size_t extraspace = SIZE_MAX - (srclen + ampcount); if (extraspace > 512) { @@ -652,7 +652,7 @@ static const char *EscapeAmpersands(char **dst, size_t *dstlen, const char *src) SDL_free(*dst); *dst = NULL; newdst = SDL_malloc(*dstlen); - if (newdst == NULL) { + if (!newdst) { return NULL; } *dst = newdst; @@ -817,7 +817,7 @@ static int WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int * Size.cy += ButtonHeight + TextMargin; dialog = CreateDialogData(Size.cx, Size.cy, messageboxdata->title); - if (dialog == NULL) { + if (!dialog) { return -1; } @@ -858,7 +858,7 @@ static int WIN_ShowOldMessageBox(const SDL_MessageBoxData *messageboxdata, int * buttontext = EscapeAmpersands(&escape, &escapesize, sdlButton->text); /* Make sure to provide the correct ID to keep buttons indexed in the * same order as how they are in messageboxdata. */ - if (buttontext == NULL || !AddDialogButton(dialog, x, y, ButtonWidth, ButtonHeight, buttontext, IDBUTTONINDEX0 + (int)(sdlButton - messageboxdata->buttons), isdefault)) { + if (!buttontext || !AddDialogButton(dialog, x, y, ButtonWidth, ButtonHeight, buttontext, IDBUTTONINDEX0 + (int)(sdlButton - messageboxdata->buttons), isdefault)) { FreeDialogData(dialog); SDL_free(ampescape); return -1; @@ -932,7 +932,7 @@ int WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) /* If we cannot load comctl32.dll use the old messagebox! */ hComctl32 = LoadLibrary(TEXT("comctl32.dll")); - if (hComctl32 == NULL) { + if (!hComctl32) { return WIN_ShowOldMessageBox(messageboxdata, buttonid); } @@ -944,7 +944,7 @@ int WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") */ pfnTaskDialogIndirect = (TASKDIALOGINDIRECTPROC)GetProcAddress(hComctl32, "TaskDialogIndirect"); - if (pfnTaskDialogIndirect == NULL) { + if (!pfnTaskDialogIndirect) { FreeLibrary(hComctl32); return WIN_ShowOldMessageBox(messageboxdata, buttonid); } @@ -992,7 +992,7 @@ int WIN_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) pButton->nButtonID = IDBUTTONINDEX0 + i; } buttontext = EscapeAmpersands(&escape, &escapesize, messageboxdata->buttons[i].text); - if (buttontext == NULL) { + if (!buttontext) { int j; FreeLibrary(hComctl32); SDL_free(ampescape); diff --git a/src/video/windows/SDL_windowsmodes.c b/src/video/windows/SDL_windowsmodes.c index 714c6f638..1845c452b 100644 --- a/src/video/windows/SDL_windowsmodes.c +++ b/src/video/windows/SDL_windowsmodes.c @@ -203,7 +203,7 @@ static SDL_bool WIN_GetDisplayMode(SDL_VideoDevice *_this, HMONITOR hMonitor, LP } data = (SDL_DisplayModeData *)SDL_malloc(sizeof(*data)); - if (data == NULL) { + if (!data) { return SDL_FALSE; } @@ -251,7 +251,7 @@ static char *WIN_GetDisplayNameVista(const WCHAR *deviceName) LONG rc; dll = SDL_LoadObject("USER32.DLL"); - if (dll == NULL) { + if (!dll) { return NULL; } @@ -259,7 +259,7 @@ static char *WIN_GetDisplayNameVista(const WCHAR *deviceName) pQueryDisplayConfig = (SDL_WIN32PROC_QueryDisplayConfig)SDL_LoadFunction(dll, "QueryDisplayConfig"); pDisplayConfigGetDeviceInfo = (SDL_WIN32PROC_DisplayConfigGetDeviceInfo)SDL_LoadFunction(dll, "DisplayConfigGetDeviceInfo"); - if (pGetDisplayConfigBufferSizes == NULL || pQueryDisplayConfig == NULL || pDisplayConfigGetDeviceInfo == NULL) { + if (!pGetDisplayConfigBufferSizes || !pQueryDisplayConfig || !pDisplayConfigGetDeviceInfo) { goto WIN_GetDisplayNameVista_failed; } @@ -274,7 +274,7 @@ static char *WIN_GetDisplayNameVista(const WCHAR *deviceName) paths = (DISPLAYCONFIG_PATH_INFO *)SDL_malloc(sizeof(DISPLAYCONFIG_PATH_INFO) * pathCount); modes = (DISPLAYCONFIG_MODE_INFO *)SDL_malloc(sizeof(DISPLAYCONFIG_MODE_INFO) * modeCount); - if ((paths == NULL) || (modes == NULL)) { + if ((!paths) || (!modes)) { goto WIN_GetDisplayNameVista_failed; } @@ -401,7 +401,7 @@ static void WIN_AddDisplay(SDL_VideoDevice *_this, HMONITOR hMonitor, const MONI } displaydata = (SDL_DisplayData *)SDL_calloc(1, sizeof(*displaydata)); - if (displaydata == NULL) { + if (!displaydata) { return; } SDL_memcpy(displaydata->DeviceName, info->szDevice, sizeof(displaydata->DeviceName)); @@ -410,7 +410,7 @@ static void WIN_AddDisplay(SDL_VideoDevice *_this, HMONITOR hMonitor, const MONI SDL_zero(display); display.name = WIN_GetDisplayNameVista(info->szDevice); - if (display.name == NULL) { + if (!display.name) { DISPLAY_DEVICEW device; SDL_zero(device); device.cb = sizeof(device); diff --git a/src/video/windows/SDL_windowsmouse.c b/src/video/windows/SDL_windowsmouse.c index 46d39136f..44491d37a 100644 --- a/src/video/windows/SDL_windowsmouse.c +++ b/src/video/windows/SDL_windowsmouse.c @@ -114,7 +114,7 @@ static SDL_Cursor *WIN_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) maskbitslen = ((surface->w + (pad - (surface->w % pad))) / 8) * surface->h; maskbits = SDL_small_alloc(Uint8, maskbitslen, &isstack); - if (maskbits == NULL) { + if (!maskbits) { SDL_OutOfMemory(); return NULL; } @@ -249,7 +249,7 @@ static void WIN_FreeCursor(SDL_Cursor *cursor) static int WIN_ShowCursor(SDL_Cursor *cursor) { - if (cursor == NULL) { + if (!cursor) { cursor = SDL_blank_cursor; } if (cursor) { diff --git a/src/video/windows/SDL_windowsopengl.c b/src/video/windows/SDL_windowsopengl.c index 08834bc4a..88e274f8d 100644 --- a/src/video/windows/SDL_windowsopengl.c +++ b/src/video/windows/SDL_windowsopengl.c @@ -218,7 +218,7 @@ SDL_FunctionPointer WIN_GL_GetProcAddress(SDL_VideoDevice *_this, const char *pr /* This is to pick up extensions */ func = _this->gl_data->wglGetProcAddress(proc); - if (func == NULL) { + if (!func) { /* This is probably a normal GL function */ func = GetProcAddress(_this->gl_config.dll_handle, proc); } @@ -380,7 +380,7 @@ static SDL_bool HasExtension(const char *extension, const char *extensions) return SDL_FALSE; } - if (extensions == NULL) { + if (!extensions) { return SDL_FALSE; } @@ -392,7 +392,7 @@ static SDL_bool HasExtension(const char *extension, const char *extensions) for (;;) { where = SDL_strstr(start, extension); - if (where == NULL) { + if (!where) { break; } @@ -689,7 +689,7 @@ int WIN_GL_SetupWindow(SDL_VideoDevice *_this, SDL_Window *window) SDL_bool WIN_GL_UseEGL(SDL_VideoDevice *_this) { - SDL_assert(_this->gl_data != NULL); + SDL_assert(_this->gl_data); SDL_assert(_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES); return SDL_GetHintBoolean(SDL_HINT_OPENGL_ES_DRIVER, SDL_FALSE) || _this->gl_config.major_version == 1 || _this->gl_config.major_version > _this->gl_data->es_profile_max_supported_version.major || (_this->gl_config.major_version == _this->gl_data->es_profile_max_supported_version.major && _this->gl_config.minor_version > _this->gl_data->es_profile_max_supported_version.minor); /* No WGL extension for OpenGL ES 1.x profiles. */ @@ -829,15 +829,15 @@ int WIN_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext } /* sanity check that higher level handled this. */ - SDL_assert(window || (window == NULL && !context)); + SDL_assert(window || (!window && !context)); /* Some Windows drivers freak out if hdc is NULL, even when context is NULL, against spec. Since hdc is _supposed_ to be ignored if context is NULL, we either use the current GL window, or do nothing if we already have no current context. */ - if (window == NULL) { + if (!window) { window = SDL_GL_GetCurrentWindow(); - if (window == NULL) { + if (!window) { SDL_assert(SDL_GL_GetCurrentContext() == NULL); return 0; /* already done. */ } diff --git a/src/video/windows/SDL_windowsopengles.c b/src/video/windows/SDL_windowsopengles.c index d956eaf25..ac5dbc046 100644 --- a/src/video/windows/SDL_windowsopengles.c +++ b/src/video/windows/SDL_windowsopengles.c @@ -53,7 +53,7 @@ int WIN_GLES_LoadLibrary(SDL_VideoDevice *_this, const char *path) #endif } - if (_this->egl_data == NULL) { + if (!_this->egl_data) { return SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, _this->gl_config.egl_platform); } @@ -111,7 +111,7 @@ int WIN_GLES_SetupWindow(SDL_VideoDevice *_this, SDL_Window *window) SDL_Window *current_win = SDL_GL_GetCurrentWindow(); SDL_GLContext current_ctx = SDL_GL_GetCurrentContext(); - if (_this->egl_data == NULL) { + if (!_this->egl_data) { /* !!! FIXME: commenting out this assertion is (I think) incorrect; figure out why driver_loaded is wrong for ANGLE instead. --ryan. */ #if 0 /* When hint SDL_HINT_OPENGL_ES_DRIVER is set to "1" (e.g. for ANGLE support), _this->gl_config.driver_loaded can be 1, while the below lines function. */ SDL_assert(!_this->gl_config.driver_loaded); diff --git a/src/video/windows/SDL_windowsshape.c b/src/video/windows/SDL_windowsshape.c index 25c3f5e0a..74026601f 100644 --- a/src/video/windows/SDL_windowsshape.c +++ b/src/video/windows/SDL_windowsshape.c @@ -28,7 +28,7 @@ SDL_WindowShaper *Win32_CreateShaper(SDL_Window *window) { SDL_WindowShaper *result = (SDL_WindowShaper *)SDL_malloc(sizeof(SDL_WindowShaper)); - if (result == NULL) { + if (!result) { SDL_OutOfMemory(); return NULL; } @@ -67,14 +67,14 @@ int Win32_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_Windo SDL_ShapeData *data; HRGN mask_region = NULL; - if ((shaper == NULL) || - (shape == NULL) || + if ((!shaper) || + (!shape) || ((shape->format->Amask == 0) && (shape_mode->mode != ShapeModeColorKey))) { return SDL_INVALID_SHAPE_ARGUMENT; } data = (SDL_ShapeData *)shaper->driverdata; - if (data->mask_tree != NULL) { + if (data->mask_tree) { SDL_FreeShapeTree(&data->mask_tree); } data->mask_tree = SDL_CalculateShapeTree(*shape_mode, shape); diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c index 0bd8fd5b6..78bf42368 100644 --- a/src/video/windows/SDL_windowsvideo.c +++ b/src/video/windows/SDL_windowsvideo.c @@ -413,7 +413,7 @@ static void WIN_InitDPIAwareness(SDL_VideoDevice *_this) { const char *hint = SDL_GetHint("SDL_WINDOWS_DPI_AWARENESS"); - if (hint == NULL || SDL_strcmp(hint, "permonitorv2") == 0) { + if (!hint || SDL_strcmp(hint, "permonitorv2") == 0) { WIN_DeclareDPIAwarePerMonitorV2(_this); } else if (SDL_strcmp(hint, "permonitor") == 0) { WIN_DeclareDPIAwarePerMonitor(_this); @@ -549,7 +549,7 @@ int SDL_Direct3D9GetAdapterIndex(SDL_DisplayID displayID) SDL_DisplayData *pData = SDL_GetDisplayDriverData(displayID); int adapterIndex = D3DADAPTER_DEFAULT; - if (pData == NULL) { + if (!pData) { SDL_SetError("Invalid display index"); adapterIndex = -1; /* make sure we return something invalid */ } else { @@ -632,12 +632,12 @@ SDL_bool SDL_DXGIGetOutputInfo(SDL_DisplayID displayID, int *adapterIndex, int * IDXGIAdapter *pDXGIAdapter; IDXGIOutput *pDXGIOutput; - if (adapterIndex == NULL) { + if (!adapterIndex) { SDL_InvalidParamError("adapterIndex"); return SDL_FALSE; } - if (outputIndex == NULL) { + if (!outputIndex) { SDL_InvalidParamError("outputIndex"); return SDL_FALSE; } @@ -645,7 +645,7 @@ SDL_bool SDL_DXGIGetOutputInfo(SDL_DisplayID displayID, int *adapterIndex, int * *adapterIndex = -1; *outputIndex = -1; - if (pData == NULL) { + if (!pData) { SDL_SetError("Invalid display index"); return SDL_FALSE; } diff --git a/src/video/windows/SDL_windowsvulkan.c b/src/video/windows/SDL_windowsvulkan.c index f52892d0f..5a632421c 100644 --- a/src/video/windows/SDL_windowsvulkan.c +++ b/src/video/windows/SDL_windowsvulkan.c @@ -48,10 +48,10 @@ int WIN_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) } /* Load the Vulkan loader library */ - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_VULKAN_LIBRARY"); } - if (path == NULL) { + if (!path) { path = "vulkan-1.dll"; } _this->vulkan_config.loader_handle = SDL_LoadObject(path); @@ -76,7 +76,7 @@ int WIN_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) (PFN_vkEnumerateInstanceExtensionProperties) _this->vulkan_config.vkEnumerateInstanceExtensionProperties, &extensionCount); - if (extensions == NULL) { + if (!extensions) { goto fail; } for (i = 0; i < extensionCount; i++) { diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index 95927b74d..ebcabd24e 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -188,7 +188,7 @@ static int WIN_AdjustWindowRectWithStyle(SDL_Window *window, DWORD style, BOOL m if (WIN_IsPerMonitorV2DPIAware(SDL_GetVideoDevice())) { /* With per-monitor v2, the window border/titlebar size depend on the DPI, so we need to call AdjustWindowRectExForDpi instead of AdjustWindowRectEx. */ - if (videodata != NULL) { + if (videodata) { SDL_WindowData *data = window->driverdata; frame_dpi = (data && videodata->GetDpiForWindow) ? videodata->GetDpiForWindow(data->hwnd) : 96; if (videodata->AdjustWindowRectExForDpi(&rect, style, menu, 0, frame_dpi) == 0) { @@ -262,7 +262,7 @@ int WIN_SetWindowPositionInternal(SDL_Window *window, UINT flags) data->expected_resize = SDL_FALSE; /* Update any child windows */ - for (child_window = window->first_child; child_window != NULL; child_window = child_window->next_sibling) { + for (child_window = window->first_child; child_window; child_window = child_window->next_sibling) { if (WIN_SetWindowPositionInternal(child_window, flags) < 0) { result = -1; } @@ -283,7 +283,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, HWND hwnd /* Allocate the window data */ data = (SDL_WindowData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } data->window = window; @@ -471,7 +471,7 @@ static void CleanupWindowData(SDL_VideoDevice *_this, SDL_Window *window) } } else { /* Restore any original event handler... */ - if (data->wndproc != NULL) { + if (data->wndproc) { #ifdef GWLP_WNDPROC SetWindowLongPtr(data->hwnd, GWLP_WNDPROC, (LONG_PTR)data->wndproc); @@ -498,7 +498,7 @@ static void WIN_ConstrainPopup(SDL_Window *window) int offset_x = 0, offset_y = 0; /* Calculate the total offset from the parents */ - for (w = window->parent; w->parent != NULL; w = w->parent) { + for (w = window->parent; w->parent; w = w->parent) { offset_x += w->x; offset_y += w->y; } @@ -530,7 +530,7 @@ static void WIN_SetKeyboardFocus(SDL_Window *window) SDL_Window *topmost = window; /* Find the topmost parent */ - while (topmost->parent != NULL) { + while (topmost->parent) { topmost = topmost->parent; } @@ -684,7 +684,7 @@ int WIN_CreateWindowFrom(SDL_VideoDevice *_this, SDL_Window *window, const void (void)SDL_sscanf(hint, "%p", (void **)&otherWindow); /* Do some error checking on the pointer */ - if (otherWindow != NULL && otherWindow->magic == &_this->window_magic) { + if (otherWindow && otherWindow->magic == &_this->window_magic) { /* If the otherWindow has SDL_WINDOW_OPENGL set, set it for the new window as well */ if (otherWindow->flags & SDL_WINDOW_OPENGL) { window->flags |= SDL_WINDOW_OPENGL; @@ -763,7 +763,7 @@ int WIN_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *i SDL_small_free(icon_bmp, isstack); - if (hicon == NULL) { + if (!hicon) { retval = SDL_SetError("SetWindowIcon() failed, error %08X", (unsigned int)GetLastError()); } @@ -916,7 +916,7 @@ void WIN_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) SDL_Window *new_focus = window->parent; /* Find the highest level window that isn't being hidden or destroyed. */ - while (new_focus->parent != NULL && (new_focus->is_hiding || new_focus->is_destroying)) { + while (new_focus->parent && (new_focus->is_hiding || new_focus->is_destroying)) { new_focus = new_focus->parent; } @@ -1162,7 +1162,7 @@ void *WIN_GetWindowICCProfile(SDL_VideoDevice *_this, SDL_Window *window, size_t filename_utf8 = WIN_StringToUTF8(data->ICMFileName); if (filename_utf8) { iccProfileData = SDL_LoadFile(filename_utf8, size); - if (iccProfileData == NULL) { + if (!iccProfileData) { SDL_SetError("Could not open ICC profile"); } SDL_free(filename_utf8); @@ -1285,7 +1285,7 @@ int SDL_HelperWindowCreate(void) CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, HWND_MESSAGE, NULL, hInstance, NULL); - if (SDL_HelperWindow == NULL) { + if (!SDL_HelperWindow) { UnregisterClass(SDL_HelperWindowClassName, hInstance); return WIN_SetError("Unable to create Helper Window"); } @@ -1324,7 +1324,7 @@ void WIN_OnWindowEnter(SDL_VideoDevice *_this, SDL_Window *window) { SDL_WindowData *data = window->driverdata; - if (data == NULL || !data->hwnd) { + if (!data || !data->hwnd) { /* The window wasn't fully initialized */ return; } diff --git a/src/video/winrt/SDL_winrtgamebar.cpp b/src/video/winrt/SDL_winrtgamebar.cpp index f9ffa2c5f..00f777a5c 100644 --- a/src/video/winrt/SDL_winrtgamebar.cpp +++ b/src/video/winrt/SDL_winrtgamebar.cpp @@ -115,7 +115,7 @@ static void WINRT_HandleGameBarIsInputRedirected_MainThread() return; } gameBar = WINRT_GetGameBar(); - if (gameBar == NULL) { + if (!gameBar) { /* Shouldn't happen, but just in case... */ return; } @@ -166,11 +166,11 @@ void WINRT_QuitGameBar(SDL_VideoDevice *_this) { SDL_VideoData *driverdata; IGameBarStatics_ *gameBar; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { return; } gameBar = WINRT_GetGameBar(); - if (gameBar == NULL) { + if (!gameBar) { return; } driverdata = _this->driverdata; diff --git a/src/video/winrt/SDL_winrtvideo.cpp b/src/video/winrt/SDL_winrtvideo.cpp index 51e10ab31..f9877a9ce 100644 --- a/src/video/winrt/SDL_winrtvideo.cpp +++ b/src/video/winrt/SDL_winrtvideo.cpp @@ -108,13 +108,13 @@ static SDL_VideoDevice *WINRT_CreateDevice(void) /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return 0; } data = (SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (data == NULL) { + if (!data) { SDL_OutOfMemory(); SDL_free(device); return 0; @@ -173,7 +173,7 @@ static void SDLCALL WINRT_SetDisplayOrientationsPreference(void *userdata, const * * TODO, WinRT: consider reading in an app's .appxmanifest file, and apply its orientation when 'newValue == NULL'. */ - if ((oldValue == NULL) && (newValue == NULL)) { + if ((!oldValue) && (!newValue)) { return; } @@ -320,7 +320,7 @@ static int WINRT_AddDisplaysForOutput(SDL_VideoDevice *_this, IDXGIAdapter1 *dxg } dxgiModes = (DXGI_MODE_DESC *)SDL_calloc(numModes, sizeof(DXGI_MODE_DESC)); - if (dxgiModes == NULL) { + if (!dxgiModes) { SDL_OutOfMemory(); goto done; } diff --git a/src/video/x11/SDL_x11clipboard.c b/src/video/x11/SDL_x11clipboard.c index 3bec67098..4bb7d395b 100644 --- a/src/video/x11/SDL_x11clipboard.c +++ b/src/video/x11/SDL_x11clipboard.c @@ -99,9 +99,9 @@ static int SetSelectionData(SDL_VideoDevice *_this, Atom selection, SDL_Clipboar static void *CloneDataBuffer(const void *buffer, size_t *len) { void *clone = NULL; - if (*len > 0 && buffer != NULL) { + if (*len > 0 && buffer) { clone = SDL_malloc((*len)+sizeof(Uint32)); - if (clone == NULL) { + if (!clone) { SDL_OutOfMemory(); } else { SDL_memcpy(clone, buffer, *len); @@ -228,7 +228,7 @@ SDL_bool X11_HasClipboardData(SDL_VideoDevice *_this, const char *mime_type) size_t length; void *data; data = X11_GetClipboardData(_this, mime_type, &length); - if (data != NULL) { + if (data) { SDL_free(data); } return length > 0; diff --git a/src/video/x11/SDL_x11dyn.c b/src/video/x11/SDL_x11dyn.c index 18174d129..5b8a226b9 100644 --- a/src/video/x11/SDL_x11dyn.c +++ b/src/video/x11/SDL_x11dyn.c @@ -72,22 +72,22 @@ static void *X11_GetSym(const char *fnname, int *pHasModule) int i; void *fn = NULL; for (i = 0; i < SDL_TABLESIZE(x11libs); i++) { - if (x11libs[i].lib != NULL) { + if (x11libs[i].lib) { fn = SDL_LoadFunction(x11libs[i].lib, fnname); - if (fn != NULL) { + if (fn) { break; } } } #if DEBUG_DYNAMIC_X11 - if (fn != NULL) + if (fn) printf("X11: Found '%s' in %s (%p)\n", fnname, x11libs[i].libname, fn); else printf("X11: Symbol '%s' NOT FOUND!\n", fnname); #endif - if (fn == NULL) { + if (!fn) { *pHasModule = 0; /* kill this module. */ } @@ -133,7 +133,7 @@ void SDL_X11_UnloadSymbols(void) #ifdef SDL_VIDEO_DRIVER_X11_DYNAMIC for (i = 0; i < SDL_TABLESIZE(x11libs); i++) { - if (x11libs[i].lib != NULL) { + if (x11libs[i].lib) { SDL_UnloadObject(x11libs[i].lib); x11libs[i].lib = NULL; } @@ -154,7 +154,7 @@ int SDL_X11_LoadSymbols(void) int i; int *thismod = NULL; for (i = 0; i < SDL_TABLESIZE(x11libs); i++) { - if (x11libs[i].libname != NULL) { + if (x11libs[i].libname) { x11libs[i].lib = SDL_LoadObject(x11libs[i].libname); } } diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 1731dc747..59a0b969d 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -100,7 +100,7 @@ static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop) int bytes_fetch = 0; do { - if (ret != NULL) { + if (ret) { X11_XFree(ret); } X11_XGetWindowProperty(disp, w, prop, 0, bytes_fetch, False, AnyPropertyType, &type, &fmt, &count, &bytes_left, &ret); @@ -222,7 +222,7 @@ static int X11_URIDecode(char *buf, int len) { int ri, wi, di; char decode = '\0'; - if (buf == NULL || len < 0) { + if (!buf || len < 0) { errno = EINVAL; return -1; } @@ -298,7 +298,7 @@ static char *X11_URIToLocal(char *uri) /* got a hostname? */ if (!local && uri[0] == '/' && uri[2] != '/') { char *hostname_end = SDL_strchr(uri + 1, '/'); - if (hostname_end != NULL) { + if (hostname_end) { char hostname[257]; if (gethostname(hostname, 255) == 0) { hostname[256] = '\0'; @@ -685,7 +685,7 @@ static void X11_HandleClipboardEvent(SDL_VideoDevice *_this, const XEvent *xeven /* FIXME: We don't support the X11 INCR protocol for large clipboards. Do we want that? - Yes, yes we do. */ /* This is a safe cast, XChangeProperty() doesn't take a const value, but it doesn't modify the data */ seln_data = (unsigned char *)clipboard->callback(clipboard->userdata, mime_type, &seln_length); - if (seln_data != NULL) { + if (seln_data) { X11_XChangeProperty(display, req->requestor, req->property, req->target, 8, PropModeReplace, seln_data, seln_length); @@ -821,7 +821,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) XClientMessageEvent m; int i; - SDL_assert(videodata != NULL); + SDL_assert(videodata); display = videodata->display; /* Save the original keycode for dead keys, which are filtered out by @@ -921,7 +921,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) } } } - if (data == NULL) { + if (!data) { /* The window for KeymapNotify, etc events is 0 */ if (xevent->type == KeymapNotify) { #ifdef DEBUG_XEVENTS @@ -1257,7 +1257,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) SDL_IME_UpdateTextRect(NULL); } #endif - for (w = data->window->first_child; w != NULL; w = w->next_sibling) { + for (w = data->window->first_child; w; w = w->next_sibling) { /* Don't update hidden child windows, their relative position doesn't change */ if (!(w->flags & SDL_WINDOW_HIDDEN)) { X11_UpdateWindowPosition(w); @@ -1616,7 +1616,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) char *name = X11_XGetAtomName(display, target); if (name) { char *token = SDL_strtok_r((char *)p.data, "\r\n", &saveptr); - while (token != NULL) { + while (token) { if (SDL_strcmp("text/plain", name) == 0) { SDL_SendDropText(data->window, token); } else if (SDL_strcmp("text/uri-list", name) == 0) { diff --git a/src/video/x11/SDL_x11framebuffer.c b/src/video/x11/SDL_x11framebuffer.c index 9e8da1dd1..b4a0ae12a 100644 --- a/src/video/x11/SDL_x11framebuffer.c +++ b/src/video/x11/SDL_x11framebuffer.c @@ -127,7 +127,7 @@ int X11_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, Uint #endif /* not NO_SHARED_MEMORY */ *pixels = SDL_malloc((size_t)h * (*pitch)); - if (*pixels == NULL) { + if (!*pixels) { return SDL_OutOfMemory(); } @@ -226,7 +226,7 @@ void X11_DestroyWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window) SDL_WindowData *data = window->driverdata; Display *display; - if (data == NULL) { + if (!data) { /* The window wasn't fully initialized */ return; } diff --git a/src/video/x11/SDL_x11messagebox.c b/src/video/x11/SDL_x11messagebox.c index cc197227e..7eae41deb 100644 --- a/src/video/x11/SDL_x11messagebox.c +++ b/src/video/x11/SDL_x11messagebox.c @@ -190,15 +190,15 @@ static int X11_MessageBoxInit(SDL_MessageBoxDataX11 *data, const SDL_MessageBoxD int num_missing = 0; data->font_set = X11_XCreateFontSet(data->display, g_MessageBoxFont, &missing, &num_missing, NULL); - if (missing != NULL) { + if (missing) { X11_XFreeStringList(missing); } - if (data->font_set == NULL) { + if (!data->font_set) { return SDL_SetError("Couldn't load font %s", g_MessageBoxFont); } } else { data->font_struct = X11_XLoadQueryFont(data->display, g_MessageBoxFontLatin1); - if (data->font_struct == NULL) { + if (!data->font_struct) { return SDL_SetError("Couldn't load font %s", g_MessageBoxFontLatin1); } } @@ -239,12 +239,12 @@ static int X11_MessageBoxInitPositions(SDL_MessageBoxDataX11 *data) const SDL_MessageBoxData *messageboxdata = data->messageboxdata; /* Go over text and break linefeeds into separate lines. */ - if (messageboxdata != NULL && messageboxdata->message[0]) { + if (messageboxdata && messageboxdata->message[0]) { const char *text = messageboxdata->message; const int linecount = CountLinesOfText(text); TextLineData *plinedata = (TextLineData *)SDL_malloc(sizeof(TextLineData) * linecount); - if (plinedata == NULL) { + if (!plinedata) { return SDL_OutOfMemory(); } @@ -272,7 +272,7 @@ static int X11_MessageBoxInitPositions(SDL_MessageBoxDataX11 *data) text += length + 1; /* Break if there are no more linefeeds. */ - if (lf == NULL) { + if (!lf) { break; } } @@ -361,12 +361,12 @@ static int X11_MessageBoxInitPositions(SDL_MessageBoxDataX11 *data) /* Free SDL_MessageBoxData data. */ static void X11_MessageBoxShutdown(SDL_MessageBoxDataX11 *data) { - if (data->font_set != NULL) { + if (data->font_set) { X11_XFreeFontSet(data->display, data->font_set); data->font_set = NULL; } - if (data->font_struct != NULL) { + if (data->font_struct) { X11_XFreeFont(data->display, data->font_struct); data->font_struct = NULL; } @@ -760,9 +760,9 @@ static int X11_ShowMessageBoxImpl(const SDL_MessageBoxData *messageboxdata, int #if SDL_SET_LOCALE origlocale = setlocale(LC_ALL, NULL); - if (origlocale != NULL) { + if (origlocale) { origlocale = SDL_strdup(origlocale); - if (origlocale == NULL) { + if (!origlocale) { return SDL_OutOfMemory(); } (void)setlocale(LC_ALL, ""); diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c index e8c0ad331..16255c98e 100644 --- a/src/video/x11/SDL_x11modes.c +++ b/src/video/x11/SDL_x11modes.c @@ -536,7 +536,7 @@ static int X11_AddXRandRDisplay(SDL_VideoDevice *_this, Display *dpy, int screen } output_info = X11_XRRGetOutputInfo(dpy, res, outputid); - if (output_info == NULL || !output_info->crtc || output_info->connection == RR_Disconnected) { + if (!output_info || !output_info->crtc || output_info->connection == RR_Disconnected) { X11_XRRFreeOutputInfo(output_info); return 0; /* ignore this one. */ } @@ -548,7 +548,7 @@ static int X11_AddXRandRDisplay(SDL_VideoDevice *_this, Display *dpy, int screen X11_XRRFreeOutputInfo(output_info); crtc = X11_XRRGetCrtcInfo(dpy, res, output_crtc); - if (crtc == NULL) { + if (!crtc) { return 0; /* oh well, ignore it. */ } @@ -564,12 +564,12 @@ static int X11_AddXRandRDisplay(SDL_VideoDevice *_this, Display *dpy, int screen X11_XRRFreeCrtcInfo(crtc); displaydata = (SDL_DisplayData *)SDL_calloc(1, sizeof(*displaydata)); - if (displaydata == NULL) { + if (!displaydata) { return SDL_OutOfMemory(); } modedata = (SDL_DisplayModeData *)SDL_calloc(1, sizeof(SDL_DisplayModeData)); - if (modedata == NULL) { + if (!modedata) { SDL_free(displaydata); return SDL_OutOfMemory(); } @@ -626,11 +626,11 @@ static void X11_HandleXRandROutputChange(SDL_VideoDevice *_this, const XRROutput } if (ev->connection == RR_Disconnected) { /* output is going away */ - if (display != NULL) { + if (display) { SDL_DelVideoDisplay(display->id, SDL_TRUE); } } else if (ev->connection == RR_Connected) { /* output is coming online */ - if (display != NULL) { + if (display) { /* !!! FIXME: update rotation or current mode of existing display? */ } else { Display *dpy = ev->display; @@ -638,7 +638,7 @@ static void X11_HandleXRandROutputChange(SDL_VideoDevice *_this, const XRROutput XVisualInfo vinfo; if (get_visualinfo(dpy, screen, &vinfo) == 0) { XRRScreenResources *res = X11_XRRGetScreenResourcesCurrent(dpy, RootWindow(dpy, screen)); - if (res == NULL || res->noutput == 0) { + if (!res || res->noutput == 0) { if (res) { X11_XRRFreeScreenResources(res); } @@ -694,13 +694,13 @@ static int X11_InitModes_XRandR(SDL_VideoDevice *_this) } res = X11_XRRGetScreenResourcesCurrent(dpy, RootWindow(dpy, screen)); - if (res == NULL || res->noutput == 0) { + if (!res || res->noutput == 0) { if (res) { X11_XRRFreeScreenResources(res); } res = X11_XRRGetScreenResources(dpy, RootWindow(dpy, screen)); - if (res == NULL) { + if (!res) { continue; } } @@ -767,12 +767,12 @@ static int X11_InitModes_StdXlib(SDL_VideoDevice *_this) mode.format = pixelformat; displaydata = (SDL_DisplayData *)SDL_calloc(1, sizeof(*displaydata)); - if (displaydata == NULL) { + if (!displaydata) { return SDL_OutOfMemory(); } modedata = (SDL_DisplayModeData *)SDL_calloc(1, sizeof(SDL_DisplayModeData)); - if (modedata == NULL) { + if (!modedata) { SDL_free(displaydata); return SDL_OutOfMemory(); } @@ -861,7 +861,7 @@ int X11_GetDisplayModes(SDL_VideoDevice *_this, SDL_VideoDisplay *sdl_display) if (output_info && output_info->connection != RR_Disconnected) { for (i = 0; i < output_info->nmode; ++i) { modedata = (SDL_DisplayModeData *)SDL_calloc(1, sizeof(SDL_DisplayModeData)); - if (modedata == NULL) { + if (!modedata) { continue; } mode.driverdata = modedata; @@ -914,18 +914,18 @@ int X11_SetDisplayMode(SDL_VideoDevice *_this, SDL_VideoDisplay *sdl_display, SD Status status; res = X11_XRRGetScreenResources(display, RootWindow(display, data->screen)); - if (res == NULL) { + if (!res) { return SDL_SetError("Couldn't get XRandR screen resources"); } output_info = X11_XRRGetOutputInfo(display, res, data->xrandr_output); - if (output_info == NULL || output_info->connection == RR_Disconnected) { + if (!output_info || output_info->connection == RR_Disconnected) { X11_XRRFreeScreenResources(res); return SDL_SetError("Couldn't get XRandR output info"); } crtc = X11_XRRGetCrtcInfo(display, res, output_info->crtc); - if (crtc == NULL) { + if (!crtc) { X11_XRRFreeOutputInfo(output_info); X11_XRRFreeScreenResources(res); return SDL_SetError("Couldn't get XRandR crtc info"); diff --git a/src/video/x11/SDL_x11mouse.c b/src/video/x11/SDL_x11mouse.c index 7edef6a84..3f2d3d3dd 100644 --- a/src/video/x11/SDL_x11mouse.c +++ b/src/video/x11/SDL_x11mouse.c @@ -88,7 +88,7 @@ static Cursor X11_CreateXCursorCursor(SDL_Surface *surface, int hot_x, int hot_y XcursorImage *image; image = X11_XcursorImageCreate(surface->w, surface->h); - if (image == NULL) { + if (!image) { SDL_OutOfMemory(); return None; } @@ -121,13 +121,13 @@ static Cursor X11_CreatePixmapCursor(SDL_Surface *surface, int hot_x, int hot_y) size_t width_bytes = ((surface->w + 7) & ~((size_t)7)) / 8; data_bits = SDL_calloc(1, surface->h * width_bytes); - if (data_bits == NULL) { + if (!data_bits) { SDL_OutOfMemory(); return None; } mask_bits = SDL_calloc(1, surface->h * width_bytes); - if (mask_bits == NULL) { + if (!mask_bits) { SDL_free(data_bits); SDL_OutOfMemory(); return None; @@ -422,7 +422,7 @@ static Uint32 X11_GetGlobalMouseState(float *x, float *y) if (displays) { for (i = 0; displays[i]; ++i) { SDL_DisplayData *data = SDL_GetDisplayDriverData(displays[i]); - if (data != NULL) { + if (data) { Window root, child; int rootx, rooty, winx, winy; unsigned int mask; @@ -481,7 +481,7 @@ void X11_QuitMouse(SDL_VideoDevice *_this) SDL_XInput2DeviceInfo *i; SDL_XInput2DeviceInfo *next; - for (i = data->mouse_device_info; i != NULL; i = next) { + for (i = data->mouse_device_info; i; i = next) { next = i->next; SDL_free(i); } diff --git a/src/video/x11/SDL_x11shape.c b/src/video/x11/SDL_x11shape.c index 1acd33ce0..373d6eba1 100644 --- a/src/video/x11/SDL_x11shape.c +++ b/src/video/x11/SDL_x11shape.c @@ -36,7 +36,7 @@ SDL_WindowShaper *X11_CreateShaper(SDL_Window *window) if (SDL_X11_HAVE_XSHAPE) { /* Make sure X server supports it. */ result = SDL_malloc(sizeof(SDL_WindowShaper)); - if (result == NULL) { + if (!result) { SDL_OutOfMemory(); return NULL; } @@ -44,7 +44,7 @@ SDL_WindowShaper *X11_CreateShaper(SDL_Window *window) result->mode.mode = ShapeModeDefault; result->mode.parameters.binarizationCutoff = 1; data = SDL_malloc(sizeof(SDL_ShapeData)); - if (data == NULL) { + if (!data) { SDL_free(result); SDL_OutOfMemory(); return NULL; @@ -67,7 +67,7 @@ int X11_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_WindowS Pixmap shapemask; #endif - if (shaper == NULL || shape == NULL || shaper->driverdata == NULL) { + if (!shaper || !shape || !shaper->driverdata) { return -1; } diff --git a/src/video/x11/SDL_x11video.c b/src/video/x11/SDL_x11video.c index 1e164e84c..a27e40981 100644 --- a/src/video/x11/SDL_x11video.c +++ b/src/video/x11/SDL_x11video.c @@ -79,7 +79,7 @@ static int X11_SafetyNetErrHandler(Display *d, XErrorEvent *e) if (!safety_net_triggered) { safety_net_triggered = SDL_TRUE; device = SDL_GetVideoDevice(); - if (device != NULL) { + if (device) { int i; for (i = 0; i < device->num_displays; i++) { SDL_VideoDisplay *display = device->displays[i]; @@ -90,7 +90,7 @@ static int X11_SafetyNetErrHandler(Display *d, XErrorEvent *e) } } - if (orig_x11_errhandler != NULL) { + if (orig_x11_errhandler) { return orig_x11_errhandler(d, e); /* probably terminate. */ } @@ -115,19 +115,19 @@ static SDL_VideoDevice *X11_CreateDevice(void) /* Open the display first to be sure that X11 is available */ x11_display = X11_XOpenDisplay(display); - if (x11_display == NULL) { + if (!x11_display) { SDL_X11_UnloadSymbols(); return NULL; } /* Initialize all variables that we clean on shutdown */ device = (SDL_VideoDevice *)SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { + if (!device) { SDL_OutOfMemory(); return NULL; } data = (struct SDL_VideoData *)SDL_calloc(1, sizeof(SDL_VideoData)); - if (data == NULL) { + if (!data) { SDL_free(device); SDL_OutOfMemory(); return NULL; @@ -142,7 +142,7 @@ static SDL_VideoDevice *X11_CreateDevice(void) data->display = x11_display; data->request_display = X11_XOpenDisplay(display); - if (data->request_display == NULL) { + if (!data->request_display) { X11_XCloseDisplay(data->display); SDL_free(device->driverdata); SDL_free(device); diff --git a/src/video/x11/SDL_x11vulkan.c b/src/video/x11/SDL_x11vulkan.c index a5aa38b9a..9b9917bf6 100644 --- a/src/video/x11/SDL_x11vulkan.c +++ b/src/video/x11/SDL_x11vulkan.c @@ -57,10 +57,10 @@ int X11_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) } /* Load the Vulkan loader library */ - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_VULKAN_LIBRARY"); } - if (path == NULL) { + if (!path) { path = DEFAULT_VULKAN; } _this->vulkan_config.loader_handle = SDL_LoadObject(path); @@ -84,7 +84,7 @@ int X11_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) (PFN_vkEnumerateInstanceExtensionProperties) _this->vulkan_config.vkEnumerateInstanceExtensionProperties, &extensionCount); - if (extensions == NULL) { + if (!extensions) { goto fail; } for (i = 0; i < extensionCount; i++) { @@ -108,7 +108,7 @@ int X11_Vulkan_LoadLibrary(SDL_VideoDevice *_this, const char *path) goto fail; } else { const char *libX11XCBLibraryName = SDL_getenv("SDL_X11_XCB_LIBRARY"); - if (libX11XCBLibraryName == NULL) { + if (!libX11XCBLibraryName) { libX11XCBLibraryName = "libX11-xcb.so"; } videoData->vulkan_xlib_xcb_library = SDL_LoadObject(libX11XCBLibraryName); diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 1820b54c2..9c2b53e95 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -169,7 +169,7 @@ static void X11_ConstrainPopup(SDL_Window *window) int offset_x = 0, offset_y = 0; /* Calculate the total offset from the parents */ - for (w = window->parent; w->parent != NULL; w = w->parent) { + for (w = window->parent; w->parent; w = w->parent) { offset_x += w->x; offset_y += w->y; } @@ -201,7 +201,7 @@ static void X11_SetKeyboardFocus(SDL_Window *window) SDL_Window *topmost = window; /* Find the topmost parent */ - while (topmost->parent != NULL) { + while (topmost->parent) { topmost = topmost->parent; } @@ -306,7 +306,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, Window w, /* Allocate the window data */ data = (SDL_WindowData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } data->window = window; @@ -330,7 +330,7 @@ static int SetupWindowData(SDL_VideoDevice *_this, SDL_Window *window, Window w, videodata->numwindows++; } else { windowlist = (SDL_WindowData **)SDL_realloc(windowlist, (numwindows + 1) * sizeof(*windowlist)); - if (windowlist == NULL) { + if (!windowlist) { SDL_free(data); return SDL_OutOfMemory(); } @@ -451,7 +451,7 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) const int transparent = (window->flags & SDL_WINDOW_TRANSPARENT) ? SDL_TRUE : SDL_FALSE; const char *forced_visual_id = SDL_GetHint(SDL_HINT_VIDEO_X11_WINDOW_VISUALID); - if (forced_visual_id != NULL && forced_visual_id[0] != '\0') { + if (forced_visual_id && forced_visual_id[0] != '\0') { XVisualInfo *vi, template; int nvis; @@ -485,7 +485,7 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) #endif } - if (vinfo == NULL) { + if (!vinfo) { return -1; } visual = vinfo->visual; @@ -522,7 +522,7 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) /* OK, we got a colormap, now fill it in as best as we can */ colorcells = SDL_malloc(visual->map_entries * sizeof(XColor)); - if (colorcells == NULL) { + if (!colorcells) { return SDL_OutOfMemory(); } ncolors = visual->map_entries; @@ -669,7 +669,7 @@ int X11_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window) wintype_name = "_NET_WM_WINDOW_TYPE_TOOLTIP"; } else if (window->flags & SDL_WINDOW_POPUP_MENU) { wintype_name = "_NET_WM_WINDOW_TYPE_POPUP_MENU"; - } else if (hint != NULL && *hint) { + } else if (hint && *hint) { wintype_name = hint; } else { wintype_name = "_NET_WM_WINDOW_TYPE_NORMAL"; @@ -984,7 +984,7 @@ int X11_SetWindowIcon(SDL_VideoDevice *_this, SDL_Window *window, SDL_Surface *i X11_XFlush(display); - if (prevHandler != NULL) { + if (prevHandler) { X11_XSetErrorHandler(prevHandler); caught_x11_error = SDL_FALSE; } @@ -1020,7 +1020,7 @@ void X11_UpdateWindowPosition(SDL_Window *window) /* Send MOVED/RESIZED event, if needed. Compare with initial/expected position. Timeout 100 */ X11_WaitAndSendWindowEvents(window, 100, COMPARE_POSITION, orig_x, orig_y, dest_x, dest_y, 0, 0, 0, 0); - for (w = window->first_child; w != NULL; w = w->next_sibling) { + for (w = window->first_child; w; w = w->next_sibling) { X11_UpdateWindowPosition(w); } } @@ -1375,7 +1375,7 @@ void X11_HideWindow(SDL_VideoDevice *_this, SDL_Window *window) SDL_Window *new_focus = window->parent; /* Find the highest level window that isn't being hidden or destroyed. */ - while (new_focus->parent != NULL && (new_focus->is_hiding || new_focus->is_destroying)) { + while (new_focus->parent && (new_focus->is_hiding || new_focus->is_destroying)) { new_focus = new_focus->parent; } @@ -1658,7 +1658,7 @@ static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop) int bytes_fetch = 0; do { - if (ret != NULL) { + if (ret) { X11_XFree(ret); } X11_XGetWindowProperty(disp, w, prop, 0, bytes_fetch, False, AnyPropertyType, &type, &fmt, &count, &bytes_left, &ret); @@ -1708,7 +1708,7 @@ void *X11_GetWindowICCProfile(SDL_VideoDevice *_this, SDL_Window *window, size_t } ret_icc_profile_data = SDL_malloc(real_nitems); - if (ret_icc_profile_data == NULL) { + if (!ret_icc_profile_data) { SDL_OutOfMemory(); return NULL; } @@ -1725,7 +1725,7 @@ void X11_SetWindowMouseGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool SDL_WindowData *data = window->driverdata; Display *display; - if (data == NULL) { + if (!data) { return; } data->mouse_grabbed = SDL_FALSE; @@ -1780,7 +1780,7 @@ void X11_SetWindowKeyboardGrab(SDL_VideoDevice *_this, SDL_Window *window, SDL_b SDL_WindowData *data = window->driverdata; Display *display; - if (data == NULL) { + if (!data) { return; } @@ -1881,7 +1881,7 @@ int X11_FlashWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_FlashOperati XWMHints *wmhints; wmhints = X11_XGetWMHints(display, data->xwindow); - if (wmhints == NULL) { + if (!wmhints) { return SDL_SetError("Couldn't get WM hints"); } @@ -1984,7 +1984,7 @@ int X11_SetWindowFocusable(SDL_VideoDevice *_this, SDL_Window *window, SDL_bool XWMHints *wmhints; wmhints = X11_XGetWMHints(display, data->xwindow); - if (wmhints == NULL) { + if (!wmhints) { return SDL_SetError("Couldn't get WM hints"); } diff --git a/src/video/x11/SDL_x11xfixes.c b/src/video/x11/SDL_x11xfixes.c index 28ea7a6ad..89952a100 100644 --- a/src/video/x11/SDL_x11xfixes.c +++ b/src/video/x11/SDL_x11xfixes.c @@ -120,7 +120,7 @@ int X11_ConfineCursorWithFlags(SDL_VideoDevice *_this, SDL_Window *window, const X11_DestroyPointerBarrier(_this, data->active_cursor_confined_window); } - SDL_assert(window != NULL); + SDL_assert(window); wdata = window->driverdata; /* If user did not specify an area to confine, destroy the barrier that was/is assigned to diff --git a/src/video/x11/SDL_x11xinput2.c b/src/video/x11/SDL_x11xinput2.c index 7705e957f..fa7a651be 100644 --- a/src/video/x11/SDL_x11xinput2.c +++ b/src/video/x11/SDL_x11xinput2.c @@ -188,10 +188,10 @@ static void xinput2_remove_device_info(SDL_VideoData *videodata, const int devic SDL_XInput2DeviceInfo *prev = NULL; SDL_XInput2DeviceInfo *devinfo; - for (devinfo = videodata->mouse_device_info; devinfo != NULL; devinfo = devinfo->next) { + for (devinfo = videodata->mouse_device_info; devinfo; devinfo = devinfo->next) { if (devinfo->device_id == device_id) { - SDL_assert((devinfo == videodata->mouse_device_info) == (prev == NULL)); - if (prev == NULL) { + SDL_assert((devinfo == videodata->mouse_device_info) == (!prev)); + if (!prev) { videodata->mouse_device_info = devinfo->next; } else { prev->next = devinfo->next; @@ -212,10 +212,10 @@ static SDL_XInput2DeviceInfo *xinput2_get_device_info(SDL_VideoData *videodata, int axis = 0; int i; - for (devinfo = videodata->mouse_device_info; devinfo != NULL; devinfo = devinfo->next) { + for (devinfo = videodata->mouse_device_info; devinfo; devinfo = devinfo->next) { if (devinfo->device_id == device_id) { - SDL_assert((devinfo == videodata->mouse_device_info) == (prev == NULL)); - if (prev != NULL) { /* move this to the front of the list, assuming we'll get more from this one. */ + SDL_assert((devinfo == videodata->mouse_device_info) == (!prev)); + if (prev) { /* move this to the front of the list, assuming we'll get more from this one. */ prev->next = devinfo->next; devinfo->next = videodata->mouse_device_info; videodata->mouse_device_info = devinfo; @@ -227,13 +227,13 @@ static SDL_XInput2DeviceInfo *xinput2_get_device_info(SDL_VideoData *videodata, /* don't know about this device yet, query and cache it. */ devinfo = (SDL_XInput2DeviceInfo *)SDL_calloc(1, sizeof(SDL_XInput2DeviceInfo)); - if (devinfo == NULL) { + if (!devinfo) { SDL_OutOfMemory(); return NULL; } xidevinfo = X11_XIQueryDevice(videodata->display, device_id, &i); - if (xidevinfo == NULL) { + if (!xidevinfo) { SDL_free(devinfo); return NULL; } @@ -287,7 +287,7 @@ int X11_HandleXinput2Event(SDL_VideoData *videodata, XGenericEventCookie *cookie } devinfo = xinput2_get_device_info(videodata, rawev->deviceid); - if (devinfo == NULL) { + if (!devinfo) { return 0; /* oh well. */ } diff --git a/test/checkkeys.c b/test/checkkeys.c index cdba94157..5d9ab3e44 100644 --- a/test/checkkeys.c +++ b/test/checkkeys.c @@ -241,7 +241,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } state->window_title = "CheckKeys Test"; diff --git a/test/checkkeysthreads.c b/test/checkkeysthreads.c index cca4740e4..dcb003cc3 100644 --- a/test/checkkeysthreads.c +++ b/test/checkkeysthreads.c @@ -247,7 +247,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -267,7 +267,7 @@ int main(int argc, char *argv[]) /* Set 640x480 video mode */ window = SDL_CreateWindow("CheckKeys Test", 640, 480, 0); - if (window == NULL) { + if (!window) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create 640x480 window: %s\n", SDL_GetError()); quit(2); diff --git a/test/gamepadutils.c b/test/gamepadutils.c index c3570aee4..28d50e877 100644 --- a/test/gamepadutils.c +++ b/test/gamepadutils.c @@ -2658,7 +2658,7 @@ SDL_GamepadType GetMappingType(const char *mapping) char *SetMappingType(char *mapping, SDL_GamepadType type) { const char *type_string = SDL_GetGamepadStringForType(type); - if (type_string == NULL || type == SDL_GAMEPAD_TYPE_UNKNOWN) { + if (!type_string || type == SDL_GAMEPAD_TYPE_UNKNOWN) { return RemoveMappingValue(mapping, "type"); } else { return SetMappingValue(mapping, "type", type_string); diff --git a/test/loopwave.c b/test/loopwave.c index 877fe8f39..071d4cc97 100644 --- a/test/loopwave.c +++ b/test/loopwave.c @@ -52,7 +52,7 @@ int SDL_AppInit(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -87,7 +87,7 @@ int SDL_AppInit(int argc, char *argv[]) filename = GetResourceFilename(filename, "sample.wav"); - if (filename == NULL) { + if (!filename) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError()); return -1; } diff --git a/test/testatomic.c b/test/testatomic.c index dbbc38326..599730c9b 100644 --- a/test/testatomic.c +++ b/test/testatomic.c @@ -701,7 +701,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testaudio.c b/test/testaudio.c index 210b9c29b..924924187 100644 --- a/test/testaudio.c +++ b/test/testaudio.c @@ -146,7 +146,7 @@ static Thing *FindThingAtPoint(const float x, const float y) const SDL_FPoint pt = { x, y }; Thing *retval = NULL; Thing *i; - for (i = things; i != NULL; i = i->next) { + for (i = things; i; i = i->next) { if ((i != dragging_thing) && SDL_PointInRectFloat(&pt, &i->rect)) { retval = i; /* keep going, though, because things drawn on top are later in the list. */ } @@ -188,7 +188,7 @@ static Thing *CreateThing(ThingType what, float x, float y, float z, float w, fl } if ((w < 0) || (h < 0)) { - SDL_assert(texture != NULL); + SDL_assert(texture); if (w < 0) { w = texture->w; } @@ -213,12 +213,12 @@ static Thing *CreateThing(ThingType what, float x, float y, float z, float w, fl thing->titlebar = titlebar ? SDL_strdup(titlebar) : NULL; /* if allocation fails, oh well. */ /* insert in list by Z order (furthest from the "camera" first, so they get drawn over; negative Z is not drawn at all). */ - if (things == NULL) { + if (!things) { things = thing; return thing; } - for (i = things; i != NULL; i = i->next) { + for (i = things; i; i = i->next) { if (z > i->z) { /* insert here. */ thing->next = i; thing->prev = i->prev; @@ -389,7 +389,7 @@ static void RepositionRowOfThings(const ThingType what, const float y) float texh = 0.0f; Thing *i; - for (i = things; i != NULL; i = i->next) { + for (i = things; i; i = i->next) { if (i->what == what) { texw = i->rect.w; texh = i->rect.h; @@ -402,7 +402,7 @@ static void RepositionRowOfThings(const ThingType what, const float y) SDL_GetWindowSize(state->windows[0], &w, &h); const float spacing = w / ((float) total_things); float x = (spacing - texw) / 2.0f; - for (i = things; i != NULL; i = i->next) { + for (i = things; i; i = i->next) { if (i->what == what) { i->rect.x = x; i->rect.y = (y >= 0.0f) ? y : ((h + y) - texh); @@ -494,7 +494,7 @@ static void DestroyThingInPoof(Thing *thing) static void TrashThing(Thing *thing) { Thing *i, *next; - for (i = things; i != NULL; i = next) { + for (i = things; i; i = next) { next = i->next; if (i->line_connected_to == thing) { TrashThing(i); @@ -1009,7 +1009,7 @@ static void TickThings(void) Thing *i; Thing *next; const Uint64 now = SDL_GetTicks(); - for (i = things; i != NULL; i = next) { + for (i = things; i; i = next) { next = i->next; /* in case this deletes itself. */ if (i->ontick) { i->ontick(i, now); @@ -1024,7 +1024,7 @@ static void WindowResized(const int newwinw, const int newwinh) const float newh = (float) newwinh; const float oldw = (float) state->window_w; const float oldh = (float) state->window_h; - for (i = things; i != NULL; i = i->next) { + for (i = things; i; i = i->next) { const float halfw = i->rect.w / 2.0f; const float halfh = i->rect.h / 2.0f; const float x = (i->rect.x + halfw) / oldw; @@ -1041,7 +1041,7 @@ int SDL_AppInit(int argc, char *argv[]) int i; state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO | SDL_INIT_AUDIO); - if (state == NULL) { + if (!state) { return -1; } @@ -1195,7 +1195,7 @@ int SDL_AppEvent(const SDL_Event *event) const SDL_AudioDeviceID which = event->adevice.which; Thing *i, *next; SDL_Log("Removing audio device %u", (unsigned int) which); - for (i = things; i != NULL; i = next) { + for (i = things; i; i = next) { next = i->next; if (((i->what == THING_PHYSDEV) || (i->what == THING_PHYSDEV_CAPTURE)) && (i->data.physdev.devid == which)) { TrashThing(i); @@ -1234,7 +1234,7 @@ int SDL_AppIterate(void) void SDL_AppQuit(void) { - while (things != NULL) { + while (things) { DestroyThing(things); /* make sure all the audio devices are closed, etc. */ } diff --git a/test/testaudiocapture.c b/test/testaudiocapture.c index 9b44b6573..dfa22a73c 100644 --- a/test/testaudiocapture.c +++ b/test/testaudiocapture.c @@ -36,7 +36,7 @@ int SDL_AppInit(int argc, char **argv) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testaudiohotplug.c b/test/testaudiohotplug.c index 6f3198488..72a562cfc 100644 --- a/test/testaudiohotplug.c +++ b/test/testaudiohotplug.c @@ -72,7 +72,7 @@ static void iteration(void) const SDL_AudioDeviceID which = (SDL_AudioDeviceID) e.adevice.which; const SDL_bool iscapture = e.adevice.iscapture ? SDL_TRUE : SDL_FALSE; char *name = SDL_GetAudioDeviceName(which); - if (name != NULL) { + if (name) { SDL_Log("New %s audio device at id %u: %s", devtypestr(iscapture), (unsigned int)which, name); } else { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Got new %s device, id %u, but failed to get the name: %s", @@ -119,7 +119,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -154,7 +154,7 @@ int main(int argc, char *argv[]) /* Some targets (Mac CoreAudio) need an event queue for audio hotplug, so make and immediately hide a window. */ window = SDL_CreateWindow("testaudiohotplug", 640, 480, 0); - if (window == NULL) { + if (!window) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_CreateWindow failed: %s\n", SDL_GetError()); quit(1); } @@ -162,7 +162,7 @@ int main(int argc, char *argv[]) filename = GetResourceFilename(filename, "sample.wav"); - if (filename == NULL) { + if (!filename) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError()); quit(1); } diff --git a/test/testaudioinfo.c b/test/testaudioinfo.c index 8034f5623..cb061db1a 100644 --- a/test/testaudioinfo.c +++ b/test/testaudioinfo.c @@ -22,7 +22,7 @@ print_devices(SDL_bool iscapture) int frames; SDL_AudioDeviceID *devices = iscapture ? SDL_GetAudioCaptureDevices(&n) : SDL_GetAudioOutputDevices(&n); - if (devices == NULL) { + if (!devices) { SDL_Log(" Driver failed to report %s devices: %s\n\n", typestr, SDL_GetError()); } else if (n == 0) { SDL_Log(" No %s devices found.\n\n", typestr); @@ -31,7 +31,7 @@ print_devices(SDL_bool iscapture) SDL_Log("Found %d %s device%s:\n", n, typestr, n != 1 ? "s" : ""); for (i = 0; i < n; i++) { char *name = SDL_GetAudioDeviceName(devices[i]); - if (name != NULL) { + if (name) { SDL_Log(" %d: %s\n", i, name); SDL_free(name); } else { @@ -60,7 +60,7 @@ int main(int argc, char **argv) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testaudiostreamdynamicresample.c b/test/testaudiostreamdynamicresample.c index 0c6c2c197..4e3b8fb0f 100644 --- a/test/testaudiostreamdynamicresample.c +++ b/test/testaudiostreamdynamicresample.c @@ -158,7 +158,7 @@ static void skip_audio(float amount) num_frames = (int)(new_spec.freq * ((speed * amount) / 100.0f)); buf = SDL_malloc(num_frames); - if (buf != NULL) { + if (buf) { retval = SDL_GetAudioStreamData(stream, buf, num_frames); SDL_free(buf); } @@ -374,7 +374,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_AUDIO | SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testautomation.c b/test/testautomation.c index f2bb2e8eb..9a5bf803d 100644 --- a/test/testautomation.c +++ b/test/testautomation.c @@ -72,7 +72,7 @@ int 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; } diff --git a/test/testautomation_mouse.c b/test/testautomation_mouse.c index 2397b992a..af037f02f 100644 --- a/test/testautomation_mouse.c +++ b/test/testautomation_mouse.c @@ -418,7 +418,7 @@ static SDL_Window *createMouseSuiteTestWindow(void) */ static void destroyMouseSuiteTestWindow(SDL_Window *window) { - if (window != NULL) { + if (window) { SDL_DestroyWindow(window); window = NULL; SDLTest_AssertPass("SDL_DestroyWindow()"); @@ -454,7 +454,7 @@ static int mouse_warpMouseInWindow(void *arg) yPositions[5] = (float)h + 1; /* Create test window */ window = createMouseSuiteTestWindow(); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } @@ -507,7 +507,7 @@ static int mouse_getMouseFocus(void *arg) /* Create test window */ window = createMouseSuiteTestWindow(); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } diff --git a/test/testautomation_render.c b/test/testautomation_render.c index 5e7ca3579..9ab7ea460 100644 --- a/test/testautomation_render.c +++ b/test/testautomation_render.c @@ -76,13 +76,13 @@ static void InitCreateRenderer(void *arg) */ static void CleanupDestroyRenderer(void *arg) { - if (renderer != NULL) { + if (renderer) { SDL_DestroyRenderer(renderer); renderer = NULL; SDLTest_AssertPass("SDL_DestroyRenderer()"); } - if (window != NULL) { + if (window) { SDL_DestroyWindow(window); window = NULL; SDLTest_AssertPass("SDL_DestroyWindow"); @@ -1054,12 +1054,12 @@ loadTestFace(void) SDL_Texture *tface; face = SDLTest_ImageFace(); - if (face == NULL) { + if (!face) { return NULL; } tface = SDL_CreateTextureFromSurface(renderer, face); - if (tface == NULL) { + if (!tface) { SDLTest_LogError("SDL_CreateTextureFromSurface() failed with error: %s", SDL_GetError()); } @@ -1085,7 +1085,7 @@ hasTexColor(void) /* Get test face. */ tface = loadTestFace(); - if (tface == NULL) { + if (!tface) { return 0; } @@ -1128,7 +1128,7 @@ hasTexAlpha(void) /* Get test face. */ tface = loadTestFace(); - if (tface == NULL) { + if (!tface) { return 0; } diff --git a/test/testautomation_stdlib.c b/test/testautomation_stdlib.c index e797e4824..eab676d79 100644 --- a/test/testautomation_stdlib.c +++ b/test/testautomation_stdlib.c @@ -453,10 +453,10 @@ static int stdlib_getsetenv(void *arg) text = SDL_getenv(name); SDLTest_AssertPass("Call to SDL_getenv('%s')", name); - if (text != NULL) { + if (text) { SDLTest_Log("Expected: NULL, Got: '%s' (%i)", text, (int)SDL_strlen(text)); } - } while (text != NULL); + } while (text); /* Create random values to set */ value1 = SDLTest_RandomAsciiStringOfSize(10); diff --git a/test/testautomation_surface.c b/test/testautomation_surface.c index 5567ece46..c75c85d93 100644 --- a/test/testautomation_surface.c +++ b/test/testautomation_surface.c @@ -353,21 +353,21 @@ static int surface_testCompleteSurfaceConversion(void *arg) for (i = 0; i < SDL_arraysize(pixel_formats); ++i) { for (j = 0; j < SDL_arraysize(pixel_formats); ++j) { fmt1 = SDL_CreatePixelFormat(pixel_formats[i]); - SDL_assert(fmt1 != NULL); + SDL_assert(fmt1); cvt1 = SDL_ConvertSurface(face, fmt1); - SDL_assert(cvt1 != NULL); + SDL_assert(cvt1); fmt2 = SDL_CreatePixelFormat(pixel_formats[j]); - SDL_assert(fmt1 != NULL); + SDL_assert(fmt1); cvt2 = SDL_ConvertSurface(cvt1, fmt2); - SDL_assert(cvt2 != NULL); + SDL_assert(cvt2); if (fmt1->BytesPerPixel == face->format->BytesPerPixel && fmt2->BytesPerPixel == face->format->BytesPerPixel && (fmt1->Amask != 0) == (face->format->Amask != 0) && (fmt2->Amask != 0) == (face->format->Amask != 0)) { final = SDL_ConvertSurface(cvt2, face->format); - SDL_assert(final != NULL); + SDL_assert(final); /* Compare surface. */ ret = SDLTest_CompareSurfaces(face, final, 0); diff --git a/test/testautomation_video.c b/test/testautomation_video.c index a05d90267..e5fbdee28 100644 --- a/test/testautomation_video.c +++ b/test/testautomation_video.c @@ -542,7 +542,7 @@ static int video_getSetWindowGrab(void *arg) /* Call against new test window */ window = createVideoSuiteTestWindow(title); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } @@ -703,7 +703,7 @@ static int video_getWindowId(void *arg) /* Call against new test window */ window = createVideoSuiteTestWindow(title); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } @@ -758,7 +758,7 @@ static int video_getWindowPixelFormat(void *arg) /* Call against new test window */ window = createVideoSuiteTestWindow(title); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } @@ -828,7 +828,7 @@ static int video_getSetWindowPosition(void *arg) /* Call against new test window */ window = createVideoSuiteTestWindow(title); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } @@ -1000,7 +1000,7 @@ static int video_getSetWindowSize(void *arg) /* Call against new test window */ window = createVideoSuiteTestWindow(title); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } @@ -1183,7 +1183,7 @@ static int video_getSetWindowMinimumSize(void *arg) /* Call against new test window */ window = createVideoSuiteTestWindow(title); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } @@ -1325,7 +1325,7 @@ static int video_getSetWindowMaximumSize(void *arg) /* Call against new test window */ window = createVideoSuiteTestWindow(title); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } @@ -1463,30 +1463,30 @@ static int video_getSetWindowData(void *arg) /* Call against new test window */ window = createVideoSuiteTestWindow(title); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } /* Create testdata */ datasize = SDLTest_RandomIntegerInRange(1, 32); referenceUserdata = SDLTest_RandomAsciiStringOfSize(datasize); - if (referenceUserdata == NULL) { + if (!referenceUserdata) { returnValue = TEST_ABORTED; goto cleanup; } userdata = SDL_strdup(referenceUserdata); - if (userdata == NULL) { + if (!userdata) { returnValue = TEST_ABORTED; goto cleanup; } datasize = SDLTest_RandomIntegerInRange(1, 32); referenceUserdata2 = SDLTest_RandomAsciiStringOfSize(datasize); - if (referenceUserdata2 == NULL) { + if (!referenceUserdata2) { returnValue = TEST_ABORTED; goto cleanup; } userdata2 = SDL_strdup(referenceUserdata2); - if (userdata2 == NULL) { + if (!userdata2) { returnValue = TEST_ABORTED; goto cleanup; } diff --git a/test/testbounds.c b/test/testbounds.c index b16a54f96..cea2b229d 100644 --- a/test/testbounds.c +++ b/test/testbounds.c @@ -22,7 +22,7 @@ int main(int argc, char **argv) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testcontroller.c b/test/testcontroller.c index 4fd5627ab..89b1b4368 100644 --- a/test/testcontroller.c +++ b/test/testcontroller.c @@ -829,7 +829,7 @@ static void AddController(SDL_JoystickID id, SDL_bool verbose) } new_controllers = (Controller *)SDL_realloc(controllers, (num_controllers + 1) * sizeof(*controllers)); - if (new_controllers == NULL) { + if (!new_controllers) { return; } @@ -1092,7 +1092,7 @@ static void OpenVirtualGamepad(void) SDL_Log("Couldn't attach virtual device: %s\n", SDL_GetError()); } else { virtual_joystick = SDL_OpenJoystick(virtual_id); - if (virtual_joystick == NULL) { + if (!virtual_joystick) { SDL_Log("Couldn't open virtual device: %s\n", SDL_GetError()); } } @@ -1818,7 +1818,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -1890,13 +1890,13 @@ int main(int argc, char *argv[]) screen_width = (int)SDL_ceilf(SCREEN_WIDTH * content_scale); screen_height = (int)SDL_ceilf(SCREEN_HEIGHT * content_scale); window = SDL_CreateWindow("SDL Controller Test", screen_width, screen_height, 0); - if (window == NULL) { + if (!window) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError()); return 2; } screen = SDL_CreateRenderer(window, NULL, 0); - if (screen == NULL) { + if (!screen) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); SDL_DestroyWindow(window); return 2; @@ -1923,7 +1923,7 @@ int main(int argc, char *argv[]) type_area.y = (float)TITLE_HEIGHT / 2 - type_area.h / 2; image = CreateGamepadImage(screen); - if (image == NULL) { + if (!image) { SDL_DestroyRenderer(screen); SDL_DestroyWindow(window); return 2; diff --git a/test/testcustomcursor.c b/test/testcustomcursor.c index 12d54208c..ee90c782d 100644 --- a/test/testcustomcursor.c +++ b/test/testcustomcursor.c @@ -248,7 +248,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } for (i = 1; i < argc;) { diff --git a/test/testdisplayinfo.c b/test/testdisplayinfo.c index 009e45c3f..f11764e48 100644 --- a/test/testdisplayinfo.c +++ b/test/testdisplayinfo.c @@ -21,7 +21,7 @@ static void print_mode(const char *prefix, const SDL_DisplayMode *mode) { - if (mode == NULL) { + if (!mode) { return; } @@ -41,7 +41,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testdraw.c b/test/testdraw.c index d0c102c22..eccb8cad4 100644 --- a/test/testdraw.c +++ b/test/testdraw.c @@ -229,7 +229,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } for (i = 1; i < argc;) { diff --git a/test/testdrawchessboard.c b/test/testdrawchessboard.c index 375410590..e4c9a882d 100644 --- a/test/testdrawchessboard.c +++ b/test/testdrawchessboard.c @@ -106,7 +106,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -126,13 +126,13 @@ int main(int argc, char *argv[]) /* Create window and renderer for given surface */ window = SDL_CreateWindow("Chess Board", 640, 480, SDL_WINDOW_RESIZABLE); - if (window == NULL) { + if (!window) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Window creation fail : %s\n", SDL_GetError()); return 1; } surface = SDL_GetWindowSurface(window); renderer = SDL_CreateSoftwareRenderer(surface); - if (renderer == NULL) { + if (!renderer) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Render creation for surface fail : %s\n", SDL_GetError()); return 1; } diff --git a/test/testdropfile.c b/test/testdropfile.c index a24547bb2..9047a4a9d 100644 --- a/test/testdropfile.c +++ b/test/testdropfile.c @@ -26,7 +26,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testerror.c b/test/testerror.c index b52c206c8..1f3830f12 100644 --- a/test/testerror.c +++ b/test/testerror.c @@ -52,7 +52,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -81,7 +81,7 @@ int main(int argc, char *argv[]) alive = 1; thread = SDL_CreateThread(ThreadFunc, NULL, "#1"); - if (thread == NULL) { + if (!thread) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError()); quit(1); } diff --git a/test/testevdev.c b/test/testevdev.c index 9758bbe24..fbc362b21 100644 --- a/test/testevdev.c +++ b/test/testevdev.c @@ -1940,7 +1940,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testffmpeg.c b/test/testffmpeg.c index 519ae466f..aa240f49e 100644 --- a/test/testffmpeg.c +++ b/test/testffmpeg.c @@ -1000,7 +1000,7 @@ int main(int argc, char *argv[]) /* Create the sprite */ sprite = CreateTexture(renderer, icon_bmp, icon_bmp_len, &sprite_w, &sprite_h); - if (sprite == NULL) { + if (!sprite) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture (%s)", SDL_GetError()); return_code = 3; goto quit; @@ -1009,7 +1009,7 @@ int main(int argc, char *argv[]) /* Allocate memory for the sprite info */ positions = (SDL_FRect *)SDL_malloc(num_sprites * sizeof(*positions)); velocities = (SDL_FRect *)SDL_malloc(num_sprites * sizeof(*velocities)); - if (positions == NULL || velocities == NULL) { + if (!positions || !velocities) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); return_code = 3; goto quit; diff --git a/test/testfile.c b/test/testfile.c index 1561f176d..157d6e8be 100644 --- a/test/testfile.c +++ b/test/testfile.c @@ -71,7 +71,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -123,25 +123,25 @@ int main(int argc, char *argv[]) RWOP_ERR_QUIT(rwops); } rwops = SDL_RWFromFile(FBASENAME2, "wb"); - if (rwops == NULL) { + if (!rwops) { RWOP_ERR_QUIT(rwops); } SDL_RWclose(rwops); unlink(FBASENAME2); rwops = SDL_RWFromFile(FBASENAME2, "wb+"); - if (rwops == NULL) { + if (!rwops) { RWOP_ERR_QUIT(rwops); } SDL_RWclose(rwops); unlink(FBASENAME2); rwops = SDL_RWFromFile(FBASENAME2, "ab"); - if (rwops == NULL) { + if (!rwops) { RWOP_ERR_QUIT(rwops); } SDL_RWclose(rwops); unlink(FBASENAME2); rwops = SDL_RWFromFile(FBASENAME2, "ab+"); - if (rwops == NULL) { + if (!rwops) { RWOP_ERR_QUIT(rwops); } SDL_RWclose(rwops); @@ -152,7 +152,7 @@ int main(int argc, char *argv[]) test : w mode, r mode, w+ mode */ rwops = SDL_RWFromFile(FBASENAME1, "wb"); /* write only */ - if (rwops == NULL) { + if (!rwops) { RWOP_ERR_QUIT(rwops); } if (10 != SDL_RWwrite(rwops, "1234567890", 10)) { @@ -174,7 +174,7 @@ int main(int argc, char *argv[]) SDL_RWclose(rwops); rwops = SDL_RWFromFile(FBASENAME1, "rb"); /* read mode, file must exist */ - if (rwops == NULL) { + if (!rwops) { RWOP_ERR_QUIT(rwops); } if (0 != SDL_RWseek(rwops, 0L, SDL_RW_SEEK_SET)) { @@ -212,7 +212,7 @@ int main(int argc, char *argv[]) /* test 3: same with w+ mode */ rwops = SDL_RWFromFile(FBASENAME1, "wb+"); /* write + read + truncation */ - if (rwops == NULL) { + if (!rwops) { RWOP_ERR_QUIT(rwops); } if (10 != SDL_RWwrite(rwops, "1234567890", 10)) { @@ -263,7 +263,7 @@ int main(int argc, char *argv[]) /* test 4: same in r+ mode */ rwops = SDL_RWFromFile(FBASENAME1, "rb+"); /* write + read + file must exists, no truncation */ - if (rwops == NULL) { + if (!rwops) { RWOP_ERR_QUIT(rwops); } if (10 != SDL_RWwrite(rwops, "1234567890", 10)) { @@ -314,7 +314,7 @@ int main(int argc, char *argv[]) /* test5 : append mode */ rwops = SDL_RWFromFile(FBASENAME1, "ab+"); /* write + read + append */ - if (rwops == NULL) { + if (!rwops) { RWOP_ERR_QUIT(rwops); } if (10 != SDL_RWwrite(rwops, "1234567890", 10)) { diff --git a/test/testfilesystem.c b/test/testfilesystem.c index bea7c0ccc..4792d563e 100644 --- a/test/testfilesystem.c +++ b/test/testfilesystem.c @@ -23,7 +23,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -41,7 +41,7 @@ int main(int argc, char *argv[]) } base_path = SDL_GetBasePath(); - if (base_path == NULL) { + if (!base_path) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find base path: %s\n", SDL_GetError()); } else { @@ -50,7 +50,7 @@ int main(int argc, char *argv[]) } pref_path = SDL_GetPrefPath("libsdl", "test_filesystem"); - if (pref_path == NULL) { + if (!pref_path) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find pref path: %s\n", SDL_GetError()); } else { @@ -59,7 +59,7 @@ int main(int argc, char *argv[]) } pref_path = SDL_GetPrefPath(NULL, "test_filesystem"); - if (pref_path == NULL) { + if (!pref_path) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find pref path without organization: %s\n", SDL_GetError()); } else { diff --git a/test/testgeometry.c b/test/testgeometry.c index d494d9560..46e5a5e34 100644 --- a/test/testgeometry.c +++ b/test/testgeometry.c @@ -173,7 +173,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } @@ -224,7 +224,7 @@ int 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); } diff --git a/test/testgl.c b/test/testgl.c index 0f592812b..635782e9b 100644 --- a/test/testgl.c +++ b/test/testgl.c @@ -220,7 +220,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testgles.c b/test/testgles.c index 0afae5428..4be391f99 100644 --- a/test/testgles.c +++ b/test/testgles.c @@ -32,7 +32,7 @@ quit(int rc) { int i; - if (context != NULL) { + if (context) { for (i = 0; i < state->num_windows; i++) { if (context[i]) { SDL_GL_DeleteContext(context[i]); @@ -112,7 +112,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } @@ -176,7 +176,7 @@ int main(int argc, char *argv[]) } context = (SDL_GLContext *)SDL_calloc(state->num_windows, sizeof(*context)); - if (context == NULL) { + if (!context) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); quit(2); } diff --git a/test/testgles2.c b/test/testgles2.c index 6975adbaf..ad4223c32 100644 --- a/test/testgles2.c +++ b/test/testgles2.c @@ -99,7 +99,7 @@ quit(int rc) { int i; - if (context != NULL) { + if (context) { for (i = 0; i < state->num_windows; i++) { if (context[i]) { SDL_GL_DeleteContext(context[i]); @@ -681,7 +681,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } for (i = 1; i < argc;) { @@ -749,7 +749,7 @@ int main(int argc, char *argv[]) } context = (SDL_GLContext *)SDL_calloc(state->num_windows, sizeof(*context)); - if (context == NULL) { + if (!context) { SDL_Log("Out of memory!\n"); quit(2); } diff --git a/test/testgles2_sdf.c b/test/testgles2_sdf.c index aadb031fd..715ce718d 100644 --- a/test/testgles2_sdf.c +++ b/test/testgles2_sdf.c @@ -91,7 +91,7 @@ quit(int rc) { int i; - if (context != NULL) { + if (context) { for (i = 0; i < state->num_windows; i++) { if (context[i]) { SDL_GL_DeleteContext(context[i]); @@ -449,7 +449,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } for (i = 1; i < argc;) { @@ -511,7 +511,7 @@ int main(int argc, char *argv[]) } context = (SDL_GLContext *)SDL_calloc(state->num_windows, sizeof(*context)); - if (context == NULL) { + if (!context) { SDL_Log("Out of memory!\n"); quit(2); } @@ -552,17 +552,17 @@ int main(int argc, char *argv[]) #if 1 path = GetNearbyFilename(f); - if (path == NULL) { + if (!path) { path = SDL_strdup(f); } - if (path == NULL) { + if (!path) { SDL_Log("out of memory\n"); exit(-1); } tmp = SDL_LoadBMP(path); - if (tmp == NULL) { + if (!tmp) { SDL_Log("missing image file: %s", path); exit(-1); } else { diff --git a/test/testhaptic.c b/test/testhaptic.c index 44fbb152e..0ace23540 100644 --- a/test/testhaptic.c +++ b/test/testhaptic.c @@ -43,7 +43,7 @@ int main(int argc, char **argv) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -87,7 +87,7 @@ int main(int argc, char **argv) } if (SDL_NumHaptics() > 0) { /* We'll just use index or the first force feedback device found */ - if (name == NULL) { + if (!name) { i = (index != -1) ? index : 0; } /* Try to find matching device */ @@ -106,7 +106,7 @@ int main(int argc, char **argv) } haptic = SDL_HapticOpen(i); - if (haptic == NULL) { + if (!haptic) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s\n", SDL_GetError()); return 1; @@ -297,7 +297,7 @@ int main(int argc, char **argv) } /* Quit */ - if (haptic != NULL) { + if (haptic) { SDL_HapticClose(haptic); } SDL_Quit(); diff --git a/test/testhittesting.c b/test/testhittesting.c index 955bef0d8..03b83071e 100644 --- a/test/testhittesting.c +++ b/test/testhittesting.c @@ -80,7 +80,7 @@ int main(int argc, char **argv) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } @@ -140,7 +140,7 @@ int main(int argc, char **argv) if (e.key.keysym.sym == SDLK_ESCAPE) { done = 1; } else if (e.key.keysym.sym == SDLK_x) { - if (areas == NULL) { + if (!areas) { areas = drag_areas; numareas = SDL_arraysize(drag_areas); } else { diff --git a/test/testhotplug.c b/test/testhotplug.c index 24ec6f481..82b389de9 100644 --- a/test/testhotplug.c +++ b/test/testhotplug.c @@ -32,7 +32,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -92,7 +92,7 @@ int main(int argc, char *argv[]) keepGoing = SDL_FALSE; break; case SDL_EVENT_JOYSTICK_ADDED: - if (joystick != NULL) { + if (joystick) { SDL_Log("Only one joystick supported by this test\n"); } else { joystick = SDL_OpenJoystick(event.jdevice.which); diff --git a/test/testiconv.c b/test/testiconv.c index daabe270c..0fd5cfbfb 100644 --- a/test/testiconv.c +++ b/test/testiconv.c @@ -61,7 +61,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -90,7 +90,7 @@ int main(int argc, char *argv[]) fname = GetResourceFilename(fname, "utf8.txt"); file = fopen(fname, "rb"); - if (file == NULL) { + if (!file) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to open %s\n", fname); return 1; } diff --git a/test/testime.c b/test/testime.c index 84d3aecbb..4e428a3e9 100644 --- a/test/testime.c +++ b/test/testime.c @@ -97,7 +97,7 @@ static Uint8 validate_hex(const char *cp, size_t len, Uint32 *np) } n = (n << 4) | c; } - if (np != NULL) { + if (np) { *np = n; } return 1; @@ -116,7 +116,7 @@ static int unifont_init(const char *fontname) /* Allocate memory for the glyph data so the file can be closed after initialization. */ unifontGlyph = (struct UnifontGlyph *)SDL_malloc(unifontGlyphSize); - if (unifontGlyph == NULL) { + if (!unifontGlyph) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to allocate %d KiB for glyph data.\n", (int)(unifontGlyphSize + 1023) / 1024); return -1; } @@ -124,20 +124,20 @@ static int unifont_init(const char *fontname) /* Allocate memory for texture pointers for all renderers. */ unifontTexture = (SDL_Texture **)SDL_malloc(unifontTextureSize); - if (unifontTexture == NULL) { + if (!unifontTexture) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to allocate %d KiB for texture pointer data.\n", (int)(unifontTextureSize + 1023) / 1024); return -1; } SDL_memset(unifontTexture, 0, unifontTextureSize); filename = GetResourceFilename(NULL, fontname); - if (filename == NULL) { + if (!filename) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory\n"); return -1; } hexFile = SDL_RWFromFile(filename, "rb"); SDL_free(filename); - if (hexFile == NULL) { + if (!hexFile) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to open font file: %s\n", fontname); return -1; } @@ -279,7 +279,7 @@ static int unifont_load_texture(Uint32 textureID) } textureRGBA = (Uint8 *)SDL_malloc(UNIFONT_TEXTURE_SIZE); - if (textureRGBA == NULL) { + if (!textureRGBA) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "unifont: Failed to allocate %d MiB for a texture.\n", UNIFONT_TEXTURE_SIZE / 1024 / 1024); return -1; } @@ -334,7 +334,7 @@ static Sint32 unifont_draw_glyph(Uint32 codepoint, int rendererID, SDL_FRect *ds } } texture = unifontTexture[UNIFONT_NUM_TEXTURES * rendererID + textureID]; - if (texture != NULL) { + if (texture) { const Uint32 cInTex = codepoint % UNIFONT_GLYPHS_IN_TEXTURE; srcrect.x = (float)(cInTex % UNIFONT_GLYPHS_IN_ROW * 16); srcrect.y = (float)(cInTex / UNIFONT_GLYPHS_IN_ROW * 16); @@ -348,12 +348,12 @@ static void unifont_cleanup(void) int i, j; for (i = 0; i < state->num_windows; ++i) { SDL_Renderer *renderer = state->renderers[i]; - if (state->windows[i] == NULL || renderer == NULL) { + if (state->windows[i] == NULL || !renderer) { continue; } for (j = 0; j < UNIFONT_NUM_TEXTURES; j++) { SDL_Texture *tex = unifontTexture[UNIFONT_NUM_TEXTURES * i + j]; - if (tex != NULL) { + if (tex) { SDL_DestroyTexture(tex); } } @@ -538,7 +538,7 @@ static void _Redraw(int rendererID) if (cursor) { char *p = utf8_advance(markedText, cursor); char c = 0; - if (p == NULL) { + if (!p) { p = &markedText[SDL_strlen(markedText)]; } @@ -639,7 +639,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } @@ -677,7 +677,7 @@ int main(int argc, char *argv[]) TTF_Init(); font = TTF_OpenFont(fontname, DEFAULT_PTSIZE); - if (font == NULL) { + if (!font) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed to find font: %s\n", TTF_GetError()); return -1; } diff --git a/test/testintersections.c b/test/testintersections.c index 41b20ec16..380c8e710 100644 --- a/test/testintersections.c +++ b/test/testintersections.c @@ -292,7 +292,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testkeys.c b/test/testkeys.c index 0db5a4b3d..c64b09b2f 100644 --- a/test/testkeys.c +++ b/test/testkeys.c @@ -25,7 +25,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testloadso.c b/test/testloadso.c index c938d9415..7a55f0a76 100644 --- a/test/testloadso.c +++ b/test/testloadso.c @@ -41,7 +41,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -88,13 +88,13 @@ int main(int argc, char *argv[]) } lib = SDL_LoadObject(libname); - if (lib == NULL) { + if (!lib) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadObject('%s') failed: %s\n", libname, SDL_GetError()); retval = 3; } else { fn = (fntype)SDL_LoadFunction(lib, symname); - if (fn == NULL) { + if (!fn) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_LoadFunction('%s') failed: %s\n", symname, SDL_GetError()); retval = 4; diff --git a/test/testlocale.c b/test/testlocale.c index d0c323976..8e7366bdb 100644 --- a/test/testlocale.c +++ b/test/testlocale.c @@ -16,7 +16,7 @@ static void log_locales(void) { SDL_Locale *locales = SDL_GetPreferredLocales(); - if (locales == NULL) { + if (!locales) { SDL_Log("Couldn't determine locales: %s", SDL_GetError()); } else { SDL_Locale *l; @@ -40,7 +40,7 @@ int main(int argc, char **argv) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testlock.c b/test/testlock.c index edf259ad4..221bd4a70 100644 --- a/test/testlock.c +++ b/test/testlock.c @@ -114,7 +114,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -182,7 +182,7 @@ int main(int argc, char *argv[]) SDL_AtomicSet(&doterminate, 0); mutex = SDL_CreateMutex(); - if (mutex == NULL) { + if (!mutex) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create mutex: %s\n", SDL_GetError()); exit(1); } diff --git a/test/testmessage.c b/test/testmessage.c index c490787d3..6723a6a7a 100644 --- a/test/testmessage.c +++ b/test/testmessage.c @@ -89,7 +89,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testmouse.c b/test/testmouse.c index 5f5ef10d5..b7852e744 100644 --- a/test/testmouse.c +++ b/test/testmouse.c @@ -87,7 +87,7 @@ static void DrawObject(SDL_Renderer *renderer, Object *object) static void DrawObjects(SDL_Renderer *renderer) { Object *next = objects; - while (next != NULL) { + while (next) { DrawObject(renderer, next); next = next->next; } @@ -97,7 +97,7 @@ static void AppendObject(Object *object) { if (objects) { Object *next = objects; - while (next->next != NULL) { + while (next->next) { next = next->next; } next->next = object; @@ -133,7 +133,7 @@ static void loop(void *arg) break; case SDL_EVENT_MOUSE_MOTION: - if (active == NULL) { + if (!active) { break; } @@ -142,7 +142,7 @@ static void loop(void *arg) break; case SDL_EVENT_MOUSE_BUTTON_DOWN: - if (active == NULL) { + if (!active) { active = SDL_calloc(1, sizeof(*active)); active->x1 = active->x2 = event.button.x; active->y1 = active->y2 = event.button.y; @@ -176,7 +176,7 @@ static void loop(void *arg) break; case SDL_EVENT_MOUSE_BUTTON_UP: - if (active == NULL) { + if (!active) { break; } @@ -259,7 +259,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testmultiaudio.c b/test/testmultiaudio.c index ecf0316cd..45da83351 100644 --- a/test/testmultiaudio.c +++ b/test/testmultiaudio.c @@ -146,7 +146,7 @@ int main(int argc, char **argv) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -184,7 +184,7 @@ int main(int argc, char **argv) filename = GetResourceFilename(filename, "sample.wav"); devices = SDL_GetAudioOutputDevices(&devcount); - if (devices == NULL) { + if (!devices) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Don't see any specific audio devices!"); } else { /* Load the wave file into memory */ diff --git a/test/testnative.c b/test/testnative.c index 166e5d8c9..cc5b1b071 100644 --- a/test/testnative.c +++ b/test/testnative.c @@ -48,7 +48,7 @@ static void quit(int rc) { SDL_Quit(); - if (native_window != NULL && factory != NULL) { + if (native_window && factory) { factory->DestroyNativeWindow(native_window); } SDLTest_CommonDestroyState(state); @@ -109,7 +109,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -135,19 +135,19 @@ int main(int argc, char *argv[]) break; } } - if (factory == NULL) { + if (!factory) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't find native window code for %s driver\n", driver); quit(2); } SDL_Log("Creating native window for %s driver\n", driver); native_window = factory->CreateNativeWindow(WINDOW_W, WINDOW_H); - if (native_window == NULL) { + if (!native_window) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create native window\n"); quit(3); } window = SDL_CreateWindowFrom(native_window); - if (window == NULL) { + if (!window) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create SDL window: %s\n", SDL_GetError()); quit(4); } @@ -155,7 +155,7 @@ int main(int argc, char *argv[]) /* Create the renderer */ renderer = SDL_CreateRenderer(window, NULL, 0); - if (renderer == NULL) { + if (!renderer) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); quit(5); } @@ -165,7 +165,7 @@ int main(int argc, char *argv[]) SDL_RenderClear(renderer); sprite = LoadTexture(renderer, "icon.bmp", SDL_TRUE, NULL, NULL); - if (sprite == NULL) { + if (!sprite) { quit(6); } @@ -174,7 +174,7 @@ int main(int argc, char *argv[]) SDL_QueryTexture(sprite, NULL, NULL, &sprite_w, &sprite_h); positions = (SDL_FRect *)SDL_malloc(NUM_SPRITES * sizeof(*positions)); velocities = (SDL_FRect *)SDL_malloc(NUM_SPRITES * sizeof(*velocities)); - if (positions == NULL || velocities == NULL) { + if (!positions || !velocities) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); quit(2); } diff --git a/test/testnativew32.c b/test/testnativew32.c index 13603b666..d3cbe125b 100644 --- a/test/testnativew32.c +++ b/test/testnativew32.c @@ -68,7 +68,7 @@ CreateWindowNative(int w, int h) CreateWindow("SDL Test", "", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, w, h, NULL, NULL, GetModuleHandle(NULL), NULL); - if (hwnd == NULL) { + if (!hwnd) { MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK); return 0; diff --git a/test/testoffscreen.c b/test/testoffscreen.c index 79852031b..3c2fc83f8 100644 --- a/test/testoffscreen.c +++ b/test/testoffscreen.c @@ -102,7 +102,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -125,14 +125,14 @@ int main(int argc, char *argv[]) /* If OPENGL fails to init it will fallback to using a framebuffer for rendering */ window = SDL_CreateWindow("Offscreen Test", width, height, 0); - if (window == NULL) { + if (!window) { SDL_Log("Couldn't create window: %s\n", SDL_GetError()); return SDL_FALSE; } renderer = SDL_CreateRenderer(window, NULL, 0); - if (renderer == NULL) { + if (!renderer) { SDL_Log("Couldn't create renderer: %s\n", SDL_GetError()); return SDL_FALSE; diff --git a/test/testoverlay.c b/test/testoverlay.c index 5d42efc74..7d693aaaf 100644 --- a/test/testoverlay.c +++ b/test/testoverlay.c @@ -231,7 +231,7 @@ static void MoveSprites(SDL_Renderer *renderer) } tmp = SDL_CreateTextureFromSurface(renderer, MooseYUVSurfaces[i]); - if (tmp == NULL) { + if (!tmp) { SDL_Log("Error %s", SDL_GetError()); quit(7); } @@ -326,7 +326,7 @@ int main(int argc, char **argv) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } @@ -430,20 +430,20 @@ int main(int argc, char **argv) } RawMooseData = (Uint8 *)SDL_malloc(MOOSEFRAME_SIZE * MOOSEFRAMES_COUNT); - if (RawMooseData == NULL) { + if (!RawMooseData) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't allocate memory for movie !\n"); quit(1); } /* load the trojan moose images */ filename = GetResourceFilename(NULL, "moose.dat"); - if (filename == NULL) { + if (!filename) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory\n"); quit(2); } handle = SDL_RWFromFile(filename, "rb"); SDL_free(filename); - if (handle == NULL) { + if (!handle) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n"); quit(2); } @@ -466,7 +466,7 @@ int main(int argc, char **argv) if (streaming) { MooseTexture = SDL_CreateTexture(renderer, yuv_format, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H); - if (MooseTexture == NULL) { + if (!MooseTexture) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError()); quit(5); } @@ -479,7 +479,7 @@ int main(int argc, char **argv) for (i = 0; i < MOOSEFRAMES_COUNT; i++) { /* Create RGB SDL_Surface */ SDL_Surface *mooseRGBSurface = SDL_CreateSurface(MOOSEPIC_W, MOOSEPIC_H, SDL_PIXELFORMAT_RGB24); - if (mooseRGBSurface == NULL) { + if (!mooseRGBSurface) { quit(6); } diff --git a/test/testplatform.c b/test/testplatform.c index d310fca25..a1f5ee06a 100644 --- a/test/testplatform.c +++ b/test/testplatform.c @@ -365,7 +365,7 @@ static int Test64Bit(SDL_bool verbose) LL_Test *t; int failed = 0; - for (t = LL_Tests; t->routine != NULL; t++) { + for (t = LL_Tests; t->routine; t++) { unsigned long long result = 0; unsigned int *al = (unsigned int *)&t->a; unsigned int *bl = (unsigned int *)&t->b; @@ -447,7 +447,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testpopup.c b/test/testpopup.c index 9631536ff..ec903d3ff 100644 --- a/test/testpopup.c +++ b/test/testpopup.c @@ -194,7 +194,7 @@ static void loop(void) /* Show the tooltip if the delay period has elapsed */ if (SDL_GetTicks() > tooltip_timer) { - if (tooltip.win == NULL) { + if (!tooltip.win) { create_popup(&tooltip, SDL_FALSE); } } @@ -244,7 +244,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testpower.c b/test/testpower.c index f9baefb8a..a65334419 100644 --- a/test/testpower.c +++ b/test/testpower.c @@ -65,7 +65,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testqsort.c b/test/testqsort.c index b4a17c2df..7299e907e 100644 --- a/test/testqsort.c +++ b/test/testqsort.c @@ -55,7 +55,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testrelative.c b/test/testrelative.c index c02518e89..3ad4d70ea 100644 --- a/test/testrelative.c +++ b/test/testrelative.c @@ -92,7 +92,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testrendercopyex.c b/test/testrendercopyex.c index ffb522957..7ca0b8aae 100644 --- a/test/testrendercopyex.c +++ b/test/testrendercopyex.c @@ -120,7 +120,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testrendertarget.c b/test/testrendertarget.c index abaf09c66..427351e48 100644 --- a/test/testrendertarget.c +++ b/test/testrendertarget.c @@ -141,7 +141,7 @@ Draw(DrawState *s) SDL_GetRenderViewport(s->renderer, &viewport); target = SDL_CreateTexture(s->renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_TARGET, viewport.w, viewport.h); - if (target == NULL) { + if (!target) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create render target texture: %s\n", SDL_GetError()); return SDL_FALSE; } @@ -217,7 +217,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } for (i = 1; i < argc;) { diff --git a/test/testresample.c b/test/testresample.c index 83661d345..b5c006d4c 100644 --- a/test/testresample.c +++ b/test/testresample.c @@ -41,7 +41,7 @@ int main(int argc, char **argv) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -116,7 +116,7 @@ int main(int argc, char **argv) /* write out a WAV header... */ io = SDL_RWFromFile(file_out, "wb"); - if (io == NULL) { + if (!io) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "fopen('%s') failed: %s\n", file_out, SDL_GetError()); ret = 5; goto end; diff --git a/test/testrumble.c b/test/testrumble.c index 965179e76..624fbff51 100644 --- a/test/testrumble.c +++ b/test/testrumble.c @@ -42,7 +42,7 @@ int main(int argc, char **argv) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -88,7 +88,7 @@ int main(int argc, char **argv) SDL_Log("%d Haptic devices detected.\n", SDL_NumHaptics()); if (SDL_NumHaptics() > 0) { /* We'll just use index or the first force feedback device found */ - if (name == NULL) { + if (!name) { i = (index != -1) ? index : 0; } /* Try to find matching device */ @@ -107,7 +107,7 @@ int main(int argc, char **argv) } haptic = SDL_HapticOpen(i); - if (haptic == NULL) { + if (!haptic) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create the haptic device: %s\n", SDL_GetError()); return 1; @@ -146,7 +146,7 @@ int main(int argc, char **argv) SDL_Delay(2000); /* Quit */ - if (haptic != NULL) { + if (haptic) { SDL_HapticClose(haptic); } diff --git a/test/testrwlock.c b/test/testrwlock.c index 7952a2ef7..03c764708 100644 --- a/test/testrwlock.c +++ b/test/testrwlock.c @@ -67,7 +67,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -141,7 +141,7 @@ int main(int argc, char *argv[]) SDL_AtomicSet(&doterminate, 0); rwlock = SDL_CreateRWLock(); - if (rwlock == NULL) { + if (!rwlock) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create rwlock: %s\n", SDL_GetError()); SDL_Quit(); SDLTest_CommonDestroyState(state); diff --git a/test/testscale.c b/test/testscale.c index 16acb3f83..091bb18c1 100644 --- a/test/testscale.c +++ b/test/testscale.c @@ -107,7 +107,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testsem.c b/test/testsem.c index 8da58613f..12201cc47 100644 --- a/test/testsem.c +++ b/test/testsem.c @@ -261,7 +261,7 @@ int main(int argc, char **argv) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testsensor.c b/test/testsensor.c index be200fddc..e9d0e0883 100644 --- a/test/testsensor.c +++ b/test/testsensor.c @@ -38,7 +38,7 @@ static const char *GetSensorTypeString(SDL_SensorType type) static void HandleSensorEvent(SDL_SensorEvent *event) { SDL_Sensor *sensor = SDL_GetSensorFromInstanceID(event->which); - if (sensor == NULL) { + if (!sensor) { SDL_Log("Couldn't get sensor for sensor event\n"); return; } @@ -64,7 +64,7 @@ int main(int argc, char **argv) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -97,7 +97,7 @@ int main(int argc, char **argv) if (SDL_GetSensorInstanceType(sensors[i]) != SDL_SENSOR_UNKNOWN) { SDL_Sensor *sensor = SDL_OpenSensor(sensors[i]); - if (sensor == NULL) { + if (!sensor) { SDL_Log("Couldn't open sensor %" SDL_PRIu32 ": %s\n", sensors[i], SDL_GetError()); } else { ++num_opened; diff --git a/test/testshader.c b/test/testshader.c index 2de2380df..3cb552fca 100644 --- a/test/testshader.c +++ b/test/testshader.c @@ -141,7 +141,7 @@ static SDL_bool CompileShader(GLhandleARB shader, const char *source) glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length); info = (char *)SDL_malloc((size_t)length + 1); - if (info == NULL) { + if (!info) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!"); } else { glGetInfoLogARB(shader, length, NULL, info); @@ -169,7 +169,7 @@ static SDL_bool LinkProgram(ShaderData *data) glGetObjectParameterivARB(data->program, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length); info = (char *)SDL_malloc((size_t)length + 1); - if (info == NULL) { + if (!info) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!"); } else { glGetInfoLogARB(data->program, length, NULL, info); @@ -327,7 +327,7 @@ SDL_GL_LoadTexture(SDL_Surface *surface, GLfloat *texcoord) texcoord[3] = (GLfloat)surface->h / h; /* Max Y */ image = SDL_CreateSurface(w, h, SDL_PIXELFORMAT_RGBA32); - if (image == NULL) { + if (!image) { return 0; } @@ -454,7 +454,7 @@ int main(int argc, char **argv) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -489,7 +489,7 @@ int main(int argc, char **argv) /* Create a 640x480 OpenGL screen */ window = SDL_CreateWindow("Shader Demo", 640, 480, SDL_WINDOW_OPENGL); - if (window == NULL) { + if (!window) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to create OpenGL window: %s\n", SDL_GetError()); SDL_Quit(); exit(2); @@ -505,7 +505,7 @@ int main(int argc, char **argv) surface = SDL_LoadBMP(filename); SDL_free(filename); - if (surface == NULL) { + if (!surface) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unable to load icon.bmp: %s\n", SDL_GetError()); SDL_Quit(); exit(3); diff --git a/test/testshape.c b/test/testshape.c index 6965b3aca..c5950b3f7 100644 --- a/test/testshape.c +++ b/test/testshape.c @@ -102,18 +102,18 @@ static int SDL3_SetWindowShape(SDL_Window *window, SDL_Surface *shape, SDL_Windo g_shape_surface = NULL; } - if (shape == NULL) { + if (!shape) { return SDL_SetError("shape"); } - if (shape_mode == NULL) { + if (!shape_mode) { return SDL_SetError("shape_mode"); } g_bitmap_w = shape->w; g_bitmap_h = shape->h; g_bitmap = (Uint8*) SDL_malloc(shape->w * shape->h); - if (g_bitmap == NULL) { + if (!g_bitmap) { return SDL_OutOfMemory(); } @@ -170,7 +170,7 @@ static void render(SDL_Renderer *renderer, SDL_Texture *texture) SDL_SetRenderDrawColor(renderer, r, g, b, a); } } else { - if (g_shape_texture == NULL) { + if (!g_shape_texture) { SDL_BlendMode bm; g_shape_texture = SDL_CreateTextureFromSurface(renderer, g_shape_surface); @@ -212,7 +212,7 @@ int main(int argc, char **argv) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -294,13 +294,13 @@ int main(int argc, char **argv) } window = SDL_CreateWindow("SDL_Shape test", SHAPED_WINDOW_DIMENSION, SHAPED_WINDOW_DIMENSION, SDL_WINDOW_TRANSPARENT); - if (window == NULL) { + if (!window) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create shaped window for SDL_Shape."); rc = -4; goto ret; } renderer = SDL_CreateRenderer(window, NULL, 0); - if (renderer == NULL) { + if (!renderer) { SDL_DestroyWindow(window); SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not create rendering context for SDL_Shape window."); rc = -4; diff --git a/test/testsprite.c b/test/testsprite.c index 217dc181b..a75431414 100644 --- a/test/testsprite.c +++ b/test/testsprite.c @@ -434,7 +434,7 @@ int SDL_AppInit(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return -1; } @@ -529,7 +529,7 @@ int SDL_AppInit(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"); return -1; } @@ -545,7 +545,7 @@ int SDL_AppInit(int argc, char *argv[]) /* Allocate memory for the sprite info */ positions = (SDL_FRect *)SDL_malloc(num_sprites * sizeof(*positions)); velocities = (SDL_FRect *)SDL_malloc(num_sprites * sizeof(*velocities)); - if (positions == NULL || velocities == NULL) { + if (!positions || !velocities) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); return -1; } diff --git a/test/testspriteminimal.c b/test/testspriteminimal.c index 0d89c5e3f..3981deec2 100644 --- a/test/testspriteminimal.c +++ b/test/testspriteminimal.c @@ -133,7 +133,7 @@ int main(int argc, char *argv[]) sprite = CreateTexture(renderer, icon_bmp, icon_bmp_len, &sprite_w, &sprite_h); - if (sprite == NULL) { + if (!sprite) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture (%s)", SDL_GetError()); return_code = 3; goto quit; diff --git a/test/teststreaming.c b/test/teststreaming.c index dcd5b4423..cf99bc476 100644 --- a/test/teststreaming.c +++ b/test/teststreaming.c @@ -139,7 +139,7 @@ int main(int argc, char **argv) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -158,13 +158,13 @@ int main(int argc, char **argv) /* load the moose images */ filename = GetResourceFilename(NULL, "moose.dat"); - if (filename == NULL) { + if (!filename) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory\n"); return -1; } handle = SDL_RWFromFile(filename, "rb"); SDL_free(filename); - if (handle == NULL) { + if (!handle) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n"); quit(2); } @@ -173,19 +173,19 @@ int main(int argc, char **argv) /* Create the window and renderer */ window = SDL_CreateWindow("Happy Moose", MOOSEPIC_W * 4, MOOSEPIC_H * 4, SDL_WINDOW_RESIZABLE); - if (window == NULL) { + if (!window) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError()); quit(3); } renderer = SDL_CreateRenderer(window, NULL, 0); - if (renderer == NULL) { + if (!renderer) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError()); quit(4); } MooseTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H); - if (MooseTexture == NULL) { + if (!MooseTexture) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError()); quit(5); } diff --git a/test/testsurround.c b/test/testsurround.c index 1edd1faf6..d263fdcb2 100644 --- a/test/testsurround.c +++ b/test/testsurround.c @@ -152,7 +152,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -212,7 +212,7 @@ int main(int argc, char *argv[]) active_channel = 0; stream = SDL_OpenAudioDeviceStream(devices[i], &spec, fill_buffer, NULL); - if (stream == NULL) { + if (!stream) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_OpenAudioDeviceStream() failed: %s\n", SDL_GetError()); continue; } diff --git a/test/testthread.c b/test/testthread.c index 8bcbf4b30..c840937d0 100644 --- a/test/testthread.c +++ b/test/testthread.c @@ -93,7 +93,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -139,7 +139,7 @@ int main(int argc, char *argv[]) alive = 1; thread = SDL_CreateThread(ThreadFunc, "One", "#1"); - if (thread == NULL) { + if (!thread) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError()); quit(1); } @@ -153,7 +153,7 @@ int main(int argc, char *argv[]) alive = 1; (void)signal(SIGTERM, killed); thread = SDL_CreateThread(ThreadFunc, "Two", "#2"); - if (thread == NULL) { + if (!thread) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread: %s\n", SDL_GetError()); quit(1); } diff --git a/test/testtimer.c b/test/testtimer.c index 76c806b54..1901d5cdb 100644 --- a/test/testtimer.c +++ b/test/testtimer.c @@ -76,7 +76,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testutils.c b/test/testutils.c index f49b38e1c..f6eb3780e 100644 --- a/test/testutils.c +++ b/test/testutils.c @@ -28,13 +28,13 @@ GetNearbyFilename(const char *file) base = SDL_GetBasePath(); - if (base != NULL) { + if (base) { SDL_RWops *rw; size_t len = SDL_strlen(base) + SDL_strlen(file) + 1; path = SDL_malloc(len); - if (path == NULL) { + if (!path) { SDL_free(base); SDL_OutOfMemory(); return NULL; @@ -54,7 +54,7 @@ GetNearbyFilename(const char *file) } path = SDL_strdup(file); - if (path == NULL) { + if (!path) { SDL_OutOfMemory(); } return path; @@ -72,10 +72,10 @@ GetNearbyFilename(const char *file) char * GetResourceFilename(const char *user_specified, const char *def) { - if (user_specified != NULL) { + if (user_specified) { char *ret = SDL_strdup(user_specified); - if (ret == NULL) { + if (!ret) { SDL_OutOfMemory(); } @@ -105,12 +105,12 @@ LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent, path = GetNearbyFilename(file); - if (path != NULL) { + if (path) { file = path; } temp = SDL_LoadBMP(file); - if (temp == NULL) { + if (!temp) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s", file, SDL_GetError()); } else { /* Set transparent pixel as the pixel at (0,0) */ @@ -137,16 +137,16 @@ LoadTexture(SDL_Renderer *renderer, const char *file, SDL_bool transparent, } } - if (width_out != NULL) { + if (width_out) { *width_out = temp->w; } - if (height_out != NULL) { + if (height_out) { *height_out = temp->h; } texture = SDL_CreateTextureFromSurface(renderer, temp); - if (texture == NULL) { + if (!texture) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create texture: %s\n", SDL_GetError()); } } diff --git a/test/testviewport.c b/test/testviewport.c index 006d3c244..4a900ad90 100644 --- a/test/testviewport.c +++ b/test/testviewport.c @@ -163,7 +163,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } @@ -191,7 +191,7 @@ int main(int argc, char *argv[]) sprite = LoadTexture(state->renderers[0], "icon.bmp", SDL_TRUE, &sprite_w, &sprite_h); - if (sprite == NULL) { + if (!sprite) { quit(2); } diff --git a/test/testvulkan.c b/test/testvulkan.c index 4555f8705..231e644ff 100644 --- a/test/testvulkan.c +++ b/test/testvulkan.c @@ -293,7 +293,7 @@ static void findPhysicalDevice(void) quit(2); } physicalDevices = (VkPhysicalDevice *)SDL_malloc(sizeof(VkPhysicalDevice) * physicalDeviceCount); - if (physicalDevices == NULL) { + if (!physicalDevices) { SDL_OutOfMemory(); quit(2); } @@ -327,7 +327,7 @@ static void findPhysicalDevice(void) SDL_free(queueFamiliesProperties); queueFamiliesPropertiesAllocatedSize = queueFamiliesCount; queueFamiliesProperties = (VkQueueFamilyProperties *)SDL_malloc(sizeof(VkQueueFamilyProperties) * queueFamiliesPropertiesAllocatedSize); - if (queueFamiliesProperties == NULL) { + if (!queueFamiliesProperties) { SDL_free(physicalDevices); SDL_free(deviceExtensions); SDL_OutOfMemory(); @@ -389,7 +389,7 @@ static void findPhysicalDevice(void) SDL_free(deviceExtensions); deviceExtensionsAllocatedSize = deviceExtensionCount; deviceExtensions = SDL_malloc(sizeof(VkExtensionProperties) * deviceExtensionsAllocatedSize); - if (deviceExtensions == NULL) { + if (!deviceExtensions) { SDL_free(physicalDevices); SDL_free(queueFamiliesProperties); SDL_OutOfMemory(); @@ -918,7 +918,7 @@ static void initVulkan(void) SDL_Vulkan_LoadLibrary(NULL); vulkanContexts = (VulkanContext *)SDL_calloc(state->num_windows, sizeof(VulkanContext)); - if (vulkanContexts == NULL) { + if (!vulkanContexts) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!"); quit(2); } @@ -1079,7 +1079,7 @@ int main(int argc, char **argv) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testwm.c b/test/testwm.c index 7de55701e..6efcb8027 100644 --- a/test/testwm.c +++ b/test/testwm.c @@ -205,7 +205,7 @@ static void loop(void) } if (event.type == SDL_EVENT_MOUSE_BUTTON_UP) { SDL_Window *window = SDL_GetMouseFocus(); - if (highlighted_mode != NULL && window != NULL) { + if (highlighted_mode && window) { SDL_memcpy(&state->fullscreen_mode, highlighted_mode, sizeof(state->fullscreen_mode)); SDL_SetWindowFullscreenMode(window, highlighted_mode); } @@ -215,7 +215,7 @@ static void loop(void) for (i = 0; i < state->num_windows; ++i) { SDL_Window *window = state->windows[i]; SDL_Renderer *renderer = state->renderers[i]; - if (window != NULL && renderer != NULL) { + if (window && renderer) { float y = 0.0f; SDL_Rect viewport; SDL_FRect menurect; @@ -251,7 +251,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testyuv.c b/test/testyuv.c index afe3cac51..6ba996fd0 100644 --- a/test/testyuv.c +++ b/test/testyuv.c @@ -73,7 +73,7 @@ static SDL_bool verify_yuv_data(Uint32 format, const Uint8 *yuv, int yuv_pitch, SDL_bool result = SDL_FALSE; rgb = (Uint8 *)SDL_malloc(size); - if (rgb == NULL) { + if (!rgb) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory"); return SDL_FALSE; } @@ -124,7 +124,7 @@ static int run_automated_tests(int pattern_size, int extra_pitch) int yuv1_pitch, yuv2_pitch; int result = -1; - if (pattern == NULL || yuv1 == NULL || yuv2 == NULL) { + if (!pattern || !yuv1 || !yuv2) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't allocate test surfaces"); goto done; } @@ -263,7 +263,7 @@ int main(int argc, char **argv) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; } @@ -372,7 +372,7 @@ int main(int argc, char **argv) bmp = SDL_LoadBMP(filename); original = SDL_ConvertSurfaceFormat(bmp, SDL_PIXELFORMAT_RGB24); SDL_DestroySurface(bmp); - if (original == NULL) { + if (!original) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError()); return 3; } @@ -384,7 +384,7 @@ int main(int argc, char **argv) pitch = CalculateYUVPitch(yuv_format, original->w); converted = SDL_CreateSurface(original->w, original->h, rgb_format); - if (converted == NULL) { + if (!converted) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create converted surface: %s\n", SDL_GetError()); return 3; } @@ -397,13 +397,13 @@ int main(int argc, char **argv) SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "%d iterations in %" SDL_PRIu64 " ms, %.2fms each\n", iterations, (now - then), (float)(now - then) / iterations); window = SDL_CreateWindow("YUV test", original->w, original->h, 0); - if (window == NULL) { + if (!window) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError()); return 4; } renderer = SDL_CreateRenderer(window, NULL, 0); - if (renderer == NULL) { + if (!renderer) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); return 4; } diff --git a/test/torturethread.c b/test/torturethread.c index c2a0dd1a8..033952619 100644 --- a/test/torturethread.c +++ b/test/torturethread.c @@ -84,7 +84,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, 0); - if (state == NULL) { + if (!state) { return 1; }