Pointer as bool (libsdl-org#7214)

This commit is contained in:
Sylvain
2023-11-09 22:29:15 +01:00
committed by Sam Lantinga
parent 23db971681
commit d8600f717e
371 changed files with 2448 additions and 2442 deletions

View File

@@ -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 */

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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);

View File

@@ -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;

View File

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

View File

@@ -112,7 +112,7 @@ static SDL_bool IBus_EnterVariant(DBusConnection *conn, DBusMessageIter *iter, S
}
dbus->message_iter_get_basic(inside, &struct_id);
if (struct_id == NULL || SDL_strncmp(struct_id, struct_id, id_size) != 0) {
if (!struct_id || SDL_strncmp(struct_id, struct_id, id_size) != 0) {
return SDL_FALSE;
}
return SDL_TRUE;
@@ -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;
}

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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)) {

View File

@@ -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);

View File

@@ -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 {

View File

@@ -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);
}
}

View File

@@ -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);

View File

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

View File

@@ -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);

View File

@@ -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);

View File

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

View File

@@ -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");