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

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

View File

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