From 04b6b2979f730d0cc9d0f192998ca78e8c0432b5 Mon Sep 17 00:00:00 2001 From: Sylvain Becker Date: Sat, 11 Nov 2023 10:28:24 +0100 Subject: [PATCH] Re-add SDL_assert() with non boolean ptr syntax (#8530) --- src/audio/SDL_audio.c | 32 +++++++++++------------ src/audio/SDL_audiocvt.c | 6 ++--- src/audio/SDL_audioqueue.c | 4 +-- src/audio/alsa/SDL_alsa_audio.c | 4 +-- src/audio/directsound/SDL_directsound.c | 2 +- src/audio/haiku/SDL_haikuaudio.cc | 6 ++--- src/audio/pipewire/SDL_pipewire.c | 4 +-- src/audio/pulseaudio/SDL_pulseaudio.c | 12 ++++----- src/audio/wasapi/SDL_wasapi.c | 10 +++---- src/audio/wasapi/SDL_wasapi_win32.c | 4 +-- src/core/linux/SDL_evdev.c | 6 ++--- src/core/windows/SDL_immdevice.c | 4 +-- src/events/SDL_keyboard.c | 2 +- src/filesystem/haiku/SDL_sysfilesystem.cc | 2 +- src/filesystem/unix/SDL_sysfilesystem.c | 2 +- src/haptic/android/SDL_syshaptic.c | 2 +- src/haptic/darwin/SDL_syshaptic.c | 2 +- src/haptic/linux/SDL_syshaptic.c | 2 +- src/haptic/windows/SDL_windowshaptic.c | 2 +- src/joystick/android/SDL_sysjoystick.c | 2 +- src/joystick/bsd/SDL_bsdjoystick.c | 2 +- src/joystick/linux/SDL_sysjoystick.c | 6 ++--- src/locale/windows/SDL_syslocale.c | 2 +- src/render/SDL_render.c | 20 +++++++------- src/render/direct3d/SDL_render_d3d.c | 2 +- src/render/software/SDL_render_sw.c | 2 +- src/video/SDL_shape.c | 2 +- src/video/SDL_video.c | 4 +-- src/video/wayland/SDL_waylandmouse.c | 2 +- src/video/windows/SDL_windowsopengl.c | 4 +-- src/video/x11/SDL_x11events.c | 2 +- src/video/x11/SDL_x11xfixes.c | 2 +- src/video/x11/SDL_x11xinput2.c | 4 +-- test/testaudio.c | 2 +- test/testautomation_surface.c | 10 +++---- 35 files changed, 88 insertions(+), 88 deletions(-) diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index 7d44695d2..a19807b48 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); + SDL_assert(stream != NULL); // 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); + SDL_assert(stream != NULL); // 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! @@ -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); + SDL_assert(name != NULL); 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); - SDL_assert(!current_audio.pending_events_tail->next); + SDL_assert(current_audio.pending_events_tail != NULL); + SDL_assert(current_audio.pending_events_tail->next == NULL); current_audio.pending_events_tail->next = p; current_audio.pending_events_tail = p; SDL_UnlockRWLock(current_audio.device_hash_lock); @@ -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); - SDL_assert(!current_audio.pending_events_tail->next); + SDL_assert(current_audio.pending_events_tail != NULL); + SDL_assert(current_audio.pending_events_tail->next == NULL); current_audio.pending_events_tail->next = pending.next; current_audio.pending_events_tail = pending_tail; SDL_UnlockRWLock(current_audio.device_hash_lock); @@ -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); + SDL_assert(device != NULL); SDL_assert(!device->iscapture); SDL_OutputAudioThreadSetup(device); @@ -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); + SDL_assert(device != NULL); SDL_assert(device->iscapture); SDL_CaptureAudioThreadSetup(device); @@ -1726,7 +1726,7 @@ 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)); + SDL_assert(!logdev->bound_streams || (logdev->bound_streams->prev_binding == NULL)); // 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++) { @@ -1735,7 +1735,7 @@ int SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream **streams, int retval = SDL_SetError("Stream #%d is NULL", i); } else { SDL_LockMutex(stream->lock); - SDL_assert((!stream->bound_device) == ((!stream->prev_binding) || (!stream->next_binding))); + SDL_assert((stream->bound_device == NULL) == ((stream->prev_binding == NULL) || (stream->next_binding == NULL))); 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. @@ -1892,7 +1892,7 @@ SDL_AudioStream *SDL_OpenAudioDeviceStream(SDL_AudioDeviceID devid, const SDL_Au } else { SDL_AtomicSet(&logdev->paused, 1); // start the device paused, to match SDL2. - SDL_assert(device); + SDL_assert(device != NULL); const SDL_bool iscapture = device->iscapture; if (iscapture) { @@ -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); - SDL_assert(!current_audio.pending_events_tail->next); + SDL_assert(current_audio.pending_events_tail != NULL); + SDL_assert(current_audio.pending_events_tail->next == NULL); current_audio.pending_events_tail->next = pending.next; current_audio.pending_events_tail = pending_tail; SDL_UnlockRWLock(current_audio.device_hash_lock); @@ -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); - SDL_assert(!current_audio.pending_events_tail->next); + SDL_assert(current_audio.pending_events_tail != NULL); + SDL_assert(current_audio.pending_events_tail->next == NULL); current_audio.pending_events_tail->next = pending.next; current_audio.pending_events_tail = pending_tail; SDL_UnlockRWLock(current_audio.device_hash_lock); diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c index ed93684f2..a10141009 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); - SDL_assert(dst); + SDL_assert(src != NULL); + SDL_assert(dst != NULL); SDL_assert(SDL_IsSupportedAudioFormat(src_format)); SDL_assert(SDL_IsSupportedAudioFormat(dst_format)); SDL_assert(SDL_IsSupportedChannelCount(src_channels)); @@ -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); + SDL_assert(channel_converter != NULL); // swap in some SIMD versions for a few of these. if (channel_converter == SDL_ConvertStereoToMono) { diff --git a/src/audio/SDL_audioqueue.c b/src/audio/SDL_audioqueue.c index 37a2f8457..763809fdc 100644 --- a/src/audio/SDL_audioqueue.c +++ b/src/audio/SDL_audioqueue.c @@ -153,7 +153,7 @@ static int WriteToChunkedAudioTrack(void *ctx, const Uint8 *data, size_t len) return SDL_OutOfMemory(); } - SDL_assert((!track->head) && (!track->tail) && (track->queued_bytes == 0)); + SDL_assert((track->head == NULL) && (track->tail == NULL) && (track->queued_bytes == 0)); track->head = chunk; track->tail = chunk; } @@ -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); + SDL_assert(iter != NULL); SDL_copyp(out_spec, &iter->spec); diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index 71977c23f..e7505b88d 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -224,7 +224,7 @@ static const ALSA_Device default_capture_handle = { static const char *get_audio_device(void *handle, const int channels) { - SDL_assert(handle); // SDL2 used NULL to mean "default" but that's not true in SDL3. + SDL_assert(handle != NULL); // 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) { @@ -723,7 +723,7 @@ static void add_device(const SDL_bool iscapture, const char *name, void *hint, A desc = (char *)name; } - SDL_assert(name); + SDL_assert(name != NULL); // 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 diff --git a/src/audio/directsound/SDL_directsound.c b/src/audio/directsound/SDL_directsound.c index dc869bc46..f9ae97871 100644 --- a/src/audio/directsound/SDL_directsound.c +++ b/src/audio/directsound/SDL_directsound.c @@ -358,7 +358,7 @@ static int DSOUND_CaptureFromDevice(SDL_AudioDevice *device, void *buffer, int b } SDL_assert(ptr1len == (DWORD)buflen); - SDL_assert(!ptr2); + SDL_assert(ptr2 == NULL); SDL_assert(ptr2len == 0); SDL_memcpy(buffer, ptr1, ptr1len); diff --git a/src/audio/haiku/SDL_haikuaudio.cc b/src/audio/haiku/SDL_haikuaudio.cc index 1c2237213..5772fbe05 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); + SDL_assert(device->hidden->current_buffer != NULL); 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); + SDL_assert(device->hidden->current_buffer != NULL); 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); + SDL_assert(device->hidden->current_buffer == NULL); 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/pipewire/SDL_pipewire.c b/src/audio/pipewire/SDL_pipewire.c index 2e5586eb8..bd4ee2ed0 100644 --- a/src/audio/pipewire/SDL_pipewire.c +++ b/src/audio/pipewire/SDL_pipewire.c @@ -361,7 +361,7 @@ static struct io_node *io_list_get_by_id(Uint32 id) static void node_object_destroy(struct node_object *node) { - SDL_assert(node); + SDL_assert(node != NULL); spa_list_remove(&node->link); spa_hook_remove(&node->node_listener); @@ -373,7 +373,7 @@ static void node_object_destroy(struct node_object *node) // The pending node list static void pending_list_add(struct node_object *node) { - SDL_assert(node); + SDL_assert(node != NULL); spa_list_append(&hotplug_pending_list, &node->link); } diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c index 4cf9a6cf0..b4fd97e5c 100644 --- a/src/audio/pulseaudio/SDL_pulseaudio.c +++ b/src/audio/pulseaudio/SDL_pulseaudio.c @@ -297,7 +297,7 @@ 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); + SDL_assert(pulseaudio_threaded_mainloop != NULL); 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. @@ -339,8 +339,8 @@ static int ConnectToPulseServer(void) pa_mainloop_api *mainloop_api = NULL; int state = 0; - SDL_assert(!pulseaudio_threaded_mainloop); - SDL_assert(!pulseaudio_context); + SDL_assert(pulseaudio_threaded_mainloop == NULL); + SDL_assert(pulseaudio_context == NULL); // Set up a new main loop if (!(pulseaudio_threaded_mainloop = PULSEAUDIO_pa_threaded_mainloop_new())) { @@ -360,7 +360,7 @@ static int ConnectToPulseServer(void) PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop); mainloop_api = PULSEAUDIO_pa_threaded_mainloop_get_api(pulseaudio_threaded_mainloop); - SDL_assert(mainloop_api); // this never fails, right? + SDL_assert(mainloop_api != NULL); // this never fails, right? pulseaudio_context = PULSEAUDIO_pa_context_new(mainloop_api, getAppName()); if (!pulseaudio_context) { @@ -609,8 +609,8 @@ static int PULSEAUDIO_OpenDevice(SDL_AudioDevice *device) int format = PA_SAMPLE_INVALID; int retval = 0; - SDL_assert(pulseaudio_threaded_mainloop); - SDL_assert(pulseaudio_context); + SDL_assert(pulseaudio_threaded_mainloop != NULL); + SDL_assert(pulseaudio_context != NULL); // Initialize all variables that we clean on shutdown h = device->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*device->hidden)); diff --git a/src/audio/wasapi/SDL_wasapi.c b/src/audio/wasapi/SDL_wasapi.c index 934ac4e6e..938811a4a 100644 --- a/src/audio/wasapi/SDL_wasapi.c +++ b/src/audio/wasapi/SDL_wasapi.c @@ -433,7 +433,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); + SDL_assert(buffer == NULL); 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. } @@ -562,7 +562,7 @@ static int mgmtthrtask_PrepDevice(void *userdata) const AUDCLNT_SHAREMODE sharemode = AUDCLNT_SHAREMODE_SHARED; IAudioClient *client = device->hidden->client; - SDL_assert(client); + SDL_assert(client != NULL); #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); @@ -581,7 +581,7 @@ static int mgmtthrtask_PrepDevice(void *userdata) if (FAILED(ret)) { return WIN_SetErrorFromHRESULT("WASAPI can't determine mix format", ret); } - SDL_assert(waveformat); + SDL_assert(waveformat != NULL); device->hidden->waveformat = waveformat; SDL_AudioSpec newspec; @@ -662,7 +662,7 @@ static int mgmtthrtask_PrepDevice(void *userdata) return WIN_SetErrorFromHRESULT("WASAPI can't get capture client service", ret); } - SDL_assert(capture); + SDL_assert(capture != NULL); device->hidden->capture = capture; ret = IAudioClient_Start(client); if (FAILED(ret)) { @@ -677,7 +677,7 @@ static int mgmtthrtask_PrepDevice(void *userdata) return WIN_SetErrorFromHRESULT("WASAPI can't get render client service", ret); } - SDL_assert(render); + SDL_assert(render != NULL); device->hidden->render = render; ret = IAudioClient_Start(client); if (FAILED(ret)) { diff --git a/src/audio/wasapi/SDL_wasapi_win32.c b/src/audio/wasapi/SDL_wasapi_win32.c index 25af3225c..db8397c41 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); + SDL_assert(device->hidden->client == NULL); return WIN_SetErrorFromHRESULT("WASAPI can't activate audio endpoint", ret); } - SDL_assert(device->hidden->client); + SDL_assert(device->hidden->client != NULL); if (WASAPI_PrepDevice(device) == -1) { // not async, fire it right away. return -1; } diff --git a/src/core/linux/SDL_evdev.c b/src/core/linux/SDL_evdev.c index 38f28602e..829c7d864 100644 --- a/src/core/linux/SDL_evdev.c +++ b/src/core/linux/SDL_evdev.c @@ -250,8 +250,8 @@ void SDL_EVDEV_Quit(void) SDL_EVDEV_kbd_quit(_this->kbd); - SDL_assert(!_this->first); - SDL_assert(!_this->last); + SDL_assert(_this->first == NULL); + SDL_assert(_this->last == NULL); SDL_assert(_this->num_devices == 0); SDL_free(_this); @@ -292,7 +292,7 @@ void SDL_EVDEV_SetVTSwitchCallbacks(void (*release_callback)(void*), void *relea void (*acquire_callback)(void*), void *acquire_callback_data) { SDL_EVDEV_kbd_set_vt_switch_callbacks(_this->kbd, - release_callback, release_callback_data, + release_callback, release_callback_data, acquire_callback, acquire_callback_data); } diff --git a/src/core/windows/SDL_immdevice.c b/src/core/windows/SDL_immdevice.c index e2d1266ef..629f4a181 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); - SDL_assert(immdevice); + SDL_assert(device != NULL); + SDL_assert(immdevice != NULL); LPCWSTR devid = SDL_IMMDevice_GetDevID(device); SDL_assert(devid != NULL); diff --git a/src/events/SDL_keyboard.c b/src/events/SDL_keyboard.c index 6bb763e46..c8ddf1250 100644 --- a/src/events/SDL_keyboard.c +++ b/src/events/SDL_keyboard.c @@ -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 || !(window->flags & SDL_WINDOW_MOUSE_CAPTURE)); + SDL_assert(window == NULL || !(window->flags & SDL_WINDOW_MOUSE_CAPTURE)); /* old window must lose an existing mouse capture. */ if (keyboard->focus->flags & SDL_WINDOW_MOUSE_CAPTURE) { diff --git a/src/filesystem/haiku/SDL_sysfilesystem.cc b/src/filesystem/haiku/SDL_sysfilesystem.cc index a70e297bd..9a5f2575c 100644 --- a/src/filesystem/haiku/SDL_sysfilesystem.cc +++ b/src/filesystem/haiku/SDL_sysfilesystem.cc @@ -47,7 +47,7 @@ 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); + SDL_assert(str != NULL); const size_t len = SDL_strlen(str); char *retval = (char *) SDL_malloc(len + 2); diff --git a/src/filesystem/unix/SDL_sysfilesystem.c b/src/filesystem/unix/SDL_sysfilesystem.c index d75dd5066..491f0f0d8 100644 --- a/src/filesystem/unix/SDL_sysfilesystem.c +++ b/src/filesystem/unix/SDL_sysfilesystem.c @@ -89,7 +89,7 @@ static char *search_path_for_binary(const char *bin) return NULL; } - SDL_assert(bin); + SDL_assert(bin != NULL); alloc_size = SDL_strlen(bin) + SDL_strlen(envr) + 2; exe = (char *)SDL_malloc(alloc_size); diff --git a/src/haptic/android/SDL_syshaptic.c b/src/haptic/android/SDL_syshaptic.c index 65e7b3920..b3d9b21eb 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); + SDL_assert(item != NULL); --index; item = item->next; } diff --git a/src/haptic/darwin/SDL_syshaptic.c b/src/haptic/darwin/SDL_syshaptic.c index 9d50ac643..c0583640a 100644 --- a/src/haptic/darwin/SDL_syshaptic.c +++ b/src/haptic/darwin/SDL_syshaptic.c @@ -193,7 +193,7 @@ static SDL_hapticlist_item *HapticByDevIndex(int device_index) } while (device_index > 0) { - SDL_assert(item); + SDL_assert(item != NULL); --device_index; item = item->next; } diff --git a/src/haptic/linux/SDL_syshaptic.c b/src/haptic/linux/SDL_syshaptic.c index d1375c180..00e60411b 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); + SDL_assert(item != NULL); --device_index; item = item->next; } diff --git a/src/haptic/windows/SDL_windowshaptic.c b/src/haptic/windows/SDL_windowshaptic.c index a203f3e28..771ba012b 100644 --- a/src/haptic/windows/SDL_windowshaptic.c +++ b/src/haptic/windows/SDL_windowshaptic.c @@ -120,7 +120,7 @@ static SDL_hapticlist_item *HapticByDevIndex(int device_index) } while (device_index > 0) { - SDL_assert(item); + SDL_assert(item != NULL); --device_index; item = item->next; } diff --git a/src/joystick/android/SDL_sysjoystick.c b/src/joystick/android/SDL_sysjoystick.c index 1e1003aea..bcc2a715c 100644 --- a/src/joystick/android/SDL_sysjoystick.c +++ b/src/joystick/android/SDL_sysjoystick.c @@ -499,7 +499,7 @@ static SDL_joylist_item *GetJoystickByDevIndex(int device_index) } while (device_index > 0) { - SDL_assert(item); + SDL_assert(item != NULL); device_index--; item = item->next; } diff --git a/src/joystick/bsd/SDL_bsdjoystick.c b/src/joystick/bsd/SDL_bsdjoystick.c index f764d16f6..4b52509c6 100644 --- a/src/joystick/bsd/SDL_bsdjoystick.c +++ b/src/joystick/bsd/SDL_bsdjoystick.c @@ -526,7 +526,7 @@ static SDL_joylist_item *GetJoystickByDevIndex(int device_index) } while (device_index > 0) { - SDL_assert(item); + SDL_assert(item != NULL); device_index--; item = item->next; } diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c index 0430a7380..8a3dc2e16 100644 --- a/src/joystick/linux/SDL_sysjoystick.c +++ b/src/joystick/linux/SDL_sysjoystick.c @@ -1001,7 +1001,7 @@ static SDL_joylist_item *GetJoystickByDevIndex(int device_index) item = SDL_joylist; while (device_index > 0) { - SDL_assert(item); + SDL_assert(item != NULL); device_index--; item = item->next; } @@ -1481,8 +1481,8 @@ static int LINUX_JoystickOpen(SDL_Joystick *joystick, int device_index) return -1; /* SDL_SetError will already have been called */ } - SDL_assert(!item->hwdata); - SDL_assert(!item_sensor || !item_sensor->hwdata); + SDL_assert(item->hwdata == NULL); + SDL_assert(!item_sensor || item_sensor->hwdata == NULL); item->hwdata = joystick->hwdata; if (item_sensor) { item_sensor->hwdata = joystick->hwdata; diff --git a/src/locale/windows/SDL_syslocale.c b/src/locale/windows/SDL_syslocale.c index 634e8370a..977ed0461 100644 --- a/src/locale/windows/SDL_syslocale.c +++ b/src/locale/windows/SDL_syslocale.c @@ -61,7 +61,7 @@ static int SDL_SYS_GetPreferredLocales_vista(char *buf, size_t buflen) ULONG wbuflen = 0; SDL_bool isstack; - SDL_assert(pGetUserPreferredUILanguages); + SDL_assert(pGetUserPreferredUILanguages != NULL); pGetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &numlangs, NULL, &wbuflen); wbuf = SDL_small_alloc(WCHAR, wbuflen, &isstack); diff --git a/src/render/SDL_render.c b/src/render/SDL_render.c index 0498f0edf..55904a38c 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -229,7 +229,7 @@ static int FlushRenderCommands(SDL_Renderer *renderer) { int retval; - SDL_assert((!renderer->render_commands) == (!renderer->render_commands_tail)); + SDL_assert((renderer->render_commands == NULL) == (renderer->render_commands_tail == NULL)); if (!renderer->render_commands) { /* nothing to do! */ SDL_assert(renderer->vertex_data_used == 0); @@ -327,7 +327,7 @@ static SDL_RenderCommand *AllocateRenderCommand(SDL_Renderer *renderer) } } - SDL_assert((!renderer->render_commands) == (!renderer->render_commands_tail)); + SDL_assert((renderer->render_commands == NULL) == (renderer->render_commands_tail == NULL)); if (renderer->render_commands_tail) { renderer->render_commands_tail->next = retval; } else { @@ -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); - 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); + 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); } static SDL_RenderLineMethod SDL_GetRenderLineMethod(void) @@ -2304,7 +2304,7 @@ static void SDL_RenderLogicalBorders(SDL_Renderer *renderer) static void SDL_RenderLogicalPresentation(SDL_Renderer *renderer) { - SDL_assert(!renderer->target); + SDL_assert(renderer->target == NULL); SDL_SetRenderViewport(renderer, NULL); SDL_SetRenderClipRect(renderer, NULL); SDL_SetRenderScale(renderer, 1.0f, 1.0f); diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index 7870d10eb..4fd16b4e9 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -928,7 +928,7 @@ static int SetupTextureState(D3D_RenderData *data, SDL_Texture *texture, LPDIREC { D3D_TextureData *texturedata = (D3D_TextureData *)texture->driverdata; - SDL_assert(!*shader); + SDL_assert(*shader == NULL); if (!texturedata) { return SDL_SetError("Texture is not currently available"); diff --git a/src/render/software/SDL_render_sw.c b/src/render/software/SDL_render_sw.c index e6516a43b..ed428d3fc 100644 --- a/src/render/software/SDL_render_sw.c +++ b/src/render/software/SDL_render_sw.c @@ -641,7 +641,7 @@ 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); /* the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT */ + SDL_assert_release(viewport != NULL); /* the higher level should have forced a SDL_RENDERCMD_SETVIEWPORT */ if (cliprect) { SDL_Rect clip_rect; diff --git a/src/video/SDL_shape.c b/src/video/SDL_shape.c index 2afcf6319..2362ed7f7 100644 --- a/src/video/SDL_shape.c +++ b/src/video/SDL_shape.c @@ -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); + SDL_assert(tree != NULL); if (tree->kind == QuadShape) { SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.upleft, function, closure); SDL_TraverseShapeTree((SDL_ShapeTree *)tree->data.children.upright, function, closure); diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 591e0277c..a293b7dc4 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -271,7 +271,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U } } - SDL_assert(renderer); /* should have explicitly checked this above. */ + SDL_assert(renderer != NULL); /* 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)); @@ -570,7 +570,7 @@ int SDL_VideoInit(const char *driver_name) return 0; pre_driver_error: - SDL_assert(!_this); + SDL_assert(_this == NULL); if (init_video_capture) { SDL_QuitVideoCapture(); } diff --git a/src/video/wayland/SDL_waylandmouse.c b/src/video/wayland/SDL_waylandmouse.c index 02d30b25d..8c1bae80f 100644 --- a/src/video/wayland/SDL_waylandmouse.c +++ b/src/video/wayland/SDL_waylandmouse.c @@ -442,7 +442,7 @@ static int create_buffer_from_shm(Wayland_CursorData *d, return SDL_SetError("mmap() failed."); } - SDL_assert(d->shm_data); + SDL_assert(d->shm_data != NULL); shm_pool = wl_shm_create_pool(data->shm, shm_fd, size); d->buffer = wl_shm_pool_create_buffer(shm_pool, diff --git a/src/video/windows/SDL_windowsopengl.c b/src/video/windows/SDL_windowsopengl.c index 88e274f8d..41103805e 100644 --- a/src/video/windows/SDL_windowsopengl.c +++ b/src/video/windows/SDL_windowsopengl.c @@ -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); + SDL_assert(_this->gl_data != NULL); 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,7 +829,7 @@ int WIN_GL_MakeCurrent(SDL_VideoDevice *_this, SDL_Window *window, SDL_GLContext } /* sanity check that higher level handled this. */ - SDL_assert(window || (!window && !context)); + SDL_assert(window || (window == NULL && !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 diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 59a0b969d..75acc17af 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -821,7 +821,7 @@ static void X11_DispatchEvent(SDL_VideoDevice *_this, XEvent *xevent) XClientMessageEvent m; int i; - SDL_assert(videodata); + SDL_assert(videodata != NULL); display = videodata->display; /* Save the original keycode for dead keys, which are filtered out by diff --git a/src/video/x11/SDL_x11xfixes.c b/src/video/x11/SDL_x11xfixes.c index 89952a100..28ea7a6ad 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); + SDL_assert(window != NULL); 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 fa7a651be..eb7f89a74 100644 --- a/src/video/x11/SDL_x11xinput2.c +++ b/src/video/x11/SDL_x11xinput2.c @@ -190,7 +190,7 @@ static void xinput2_remove_device_info(SDL_VideoData *videodata, const int devic for (devinfo = videodata->mouse_device_info; devinfo; devinfo = devinfo->next) { if (devinfo->device_id == device_id) { - SDL_assert((devinfo == videodata->mouse_device_info) == (!prev)); + SDL_assert((devinfo == videodata->mouse_device_info) == (prev == NULL)); if (!prev) { videodata->mouse_device_info = devinfo->next; } else { @@ -214,7 +214,7 @@ static SDL_XInput2DeviceInfo *xinput2_get_device_info(SDL_VideoData *videodata, for (devinfo = videodata->mouse_device_info; devinfo; devinfo = devinfo->next) { if (devinfo->device_id == device_id) { - SDL_assert((devinfo == videodata->mouse_device_info) == (!prev)); + SDL_assert((devinfo == videodata->mouse_device_info) == (prev == NULL)); 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; diff --git a/test/testaudio.c b/test/testaudio.c index 924924187..0738b1884 100644 --- a/test/testaudio.c +++ b/test/testaudio.c @@ -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); + SDL_assert(texture != NULL); if (w < 0) { w = texture->w; } diff --git a/test/testautomation_surface.c b/test/testautomation_surface.c index c75c85d93..5567ece46 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); + SDL_assert(fmt1 != NULL); cvt1 = SDL_ConvertSurface(face, fmt1); - SDL_assert(cvt1); + SDL_assert(cvt1 != NULL); fmt2 = SDL_CreatePixelFormat(pixel_formats[j]); - SDL_assert(fmt1); + SDL_assert(fmt1 != NULL); cvt2 = SDL_ConvertSurface(cvt1, fmt2); - SDL_assert(cvt2); + SDL_assert(cvt2 != NULL); 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); + SDL_assert(final != NULL); /* Compare surface. */ ret = SDLTest_CompareSurfaces(face, final, 0);