diff --git a/Xcode-iOS/Demos/src/accelerometer.c b/Xcode-iOS/Demos/src/accelerometer.c index 3ce8125134e26..4c166a621ceb8 100644 --- a/Xcode-iOS/Demos/src/accelerometer.c +++ b/Xcode-iOS/Demos/src/accelerometer.c @@ -118,7 +118,7 @@ initializeTextures(SDL_Renderer *renderer) /* load the ship */ bmp_surface = SDL_LoadBMP("ship.bmp"); - if (bmp_surface == NULL) { + if (!bmp_surface) { fatalError("could not ship.bmp"); } /* set blue to transparent on the ship */ @@ -127,7 +127,7 @@ initializeTextures(SDL_Renderer *renderer) /* create ship texture from surface */ ship = SDL_CreateTextureFromSurface(renderer, bmp_surface); - if (ship == NULL) { + if (!ship) { fatalError("could not create ship texture"); } SDL_SetTextureBlendMode(ship, SDL_BLENDMODE_BLEND); @@ -140,12 +140,12 @@ initializeTextures(SDL_Renderer *renderer) /* load the space background */ bmp_surface = SDL_LoadBMP("space.bmp"); - if (bmp_surface == NULL) { + if (!bmp_surface) { fatalError("could not load space.bmp"); } /* create space texture from surface */ space = SDL_CreateTextureFromSurface(renderer, bmp_surface); - if (space == NULL) { + if (!space) { fatalError("could not create space texture"); } SDL_FreeSurface(bmp_surface); @@ -179,7 +179,7 @@ main(int argc, char *argv[]) printf("There are %d joysticks available\n", SDL_NumJoysticks()); printf("Default joystick (index 0) is %s\n", SDL_JoystickName(0)); accelerometer = SDL_JoystickOpen(0); - if (accelerometer == NULL) { + if (!accelerometer) { fatalError("Could not open joystick (accelerometer)"); } printf("joystick number of axis = %d\n", diff --git a/Xcode-iOS/Demos/src/fireworks.c b/Xcode-iOS/Demos/src/fireworks.c index eb3bb4cdeec94..a9af3fb583aa8 100644 --- a/Xcode-iOS/Demos/src/fireworks.c +++ b/Xcode-iOS/Demos/src/fireworks.c @@ -334,7 +334,7 @@ initializeTexture() to format passed into OpenGL */ bmp_surface = SDL_LoadBMP("stroke.bmp"); - if (bmp_surface == NULL) { + if (!bmp_surface) { fatalError("could not load stroke.bmp"); } diff --git a/Xcode-iOS/Demos/src/happy.c b/Xcode-iOS/Demos/src/happy.c index 42562007e1ff8..163d3463f5369 100644 --- a/Xcode-iOS/Demos/src/happy.c +++ b/Xcode-iOS/Demos/src/happy.c @@ -108,7 +108,7 @@ initializeTexture(SDL_Renderer *renderer) SDL_Surface *bmp_surface; /* load the bmp */ bmp_surface = SDL_LoadBMP("icon.bmp"); - if (bmp_surface == NULL) { + if (!bmp_surface) { fatalError("could not load bmp"); } /* set white to transparent on the happyface */ @@ -117,7 +117,7 @@ initializeTexture(SDL_Renderer *renderer) /* convert RGBA surface to texture */ texture = SDL_CreateTextureFromSurface(renderer, bmp_surface); - if (texture == NULL) { + if (!texture) { fatalError("could not create texture"); } SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND); diff --git a/Xcode-iOS/Demos/src/keyboard.c b/Xcode-iOS/Demos/src/keyboard.c index 6ab1db213aa4f..4d630bae5f5ca 100644 --- a/Xcode-iOS/Demos/src/keyboard.c +++ b/Xcode-iOS/Demos/src/keyboard.c @@ -165,7 +165,7 @@ loadFont(void) { SDL_Surface *surface = SDL_LoadBMP("kromasky_16x16.bmp"); - if (surface == NULL) { + if (!surface) { printf("Error loading bitmap: %s\n", SDL_GetError()); return 0; } else { @@ -183,7 +183,7 @@ loadFont(void) SDL_BlitSurface(surface, NULL, converted, NULL); /* create our texture */ texture = SDL_CreateTextureFromSurface(renderer, converted); - if (texture == NULL) { + if (!texture) { printf("texture creation failed: %s\n", SDL_GetError()); } else { /* set blend mode for our texture */ diff --git a/Xcode-iOS/Demos/src/rectangles.c b/Xcode-iOS/Demos/src/rectangles.c index 9102cf279517d..a08f9979061ed 100644 --- a/Xcode-iOS/Demos/src/rectangles.c +++ b/Xcode-iOS/Demos/src/rectangles.c @@ -58,11 +58,11 @@ main(int argc, char *argv[]) /* create window and renderer */ window = SDL_CreateWindow(NULL, 0, 0, 320, 480, SDL_WINDOW_ALLOW_HIGHDPI); - if (window == NULL) { + if (!window) { fatalError("Could not initialize Window"); } renderer = SDL_CreateRenderer(window, -1, 0); - if (renderer == NULL) { + if (!renderer) { fatalError("Could not create renderer"); } diff --git a/Xcode-iOS/Demos/src/touch.c b/Xcode-iOS/Demos/src/touch.c index 22a251be1487e..4b7ff95484d5a 100644 --- a/Xcode-iOS/Demos/src/touch.c +++ b/Xcode-iOS/Demos/src/touch.c @@ -57,13 +57,13 @@ initializeTexture(SDL_Renderer *renderer) { SDL_Surface *bmp_surface; bmp_surface = SDL_LoadBMP("stroke.bmp"); - if (bmp_surface == NULL) { + if (!bmp_surface) { fatalError("could not load stroke.bmp"); } brush = SDL_CreateTextureFromSurface(renderer, bmp_surface); SDL_FreeSurface(bmp_surface); - if (brush == NULL) { + if (!brush) { fatalError("could not create brush texture"); } /* additive blending -- laying strokes on top of eachother makes them brighter */ diff --git a/cmake/test/main_gui.c b/cmake/test/main_gui.c index 4ffe9be1c4078..ca2d92ecd48e6 100644 --- a/cmake/test/main_gui.c +++ b/cmake/test/main_gui.c @@ -14,7 +14,7 @@ int main(int argc, char *argv[]) { 640, 480, SDL_WINDOW_SHOWN ); - if (window == NULL) { + if (!window) { fprintf(stderr, "could not create window: %s\n", SDL_GetError()); return 1; } diff --git a/src/SDL.c b/src/SDL.c index da3a4ccce5e96..14dbd0326f1e8 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -533,7 +533,7 @@ void SDL_GetVersion(SDL_version *ver) static SDL_bool check_hint = SDL_TRUE; static SDL_bool legacy_version = SDL_FALSE; - if (ver == NULL) { + if (!ver) { return; } diff --git a/src/SDL_assert.c b/src/SDL_assert.c index 1c7f7b656ac27..57cd47762ba5b 100644 --- a/src/SDL_assert.c +++ b/src/SDL_assert.c @@ -437,7 +437,7 @@ void SDL_ResetAssertionReport(void) { SDL_assert_data *next = NULL; SDL_assert_data *item; - for (item = triggered_assertions; item != NULL; item = next) { + for (item = triggered_assertions; item; item = next) { next = (SDL_assert_data *)item->next; item->always_ignore = SDL_FALSE; item->trigger_count = 0; diff --git a/src/SDL_dataqueue.c b/src/SDL_dataqueue.c index 2019c3083cc80..30fc336f8c1b4 100644 --- a/src/SDL_dataqueue.c +++ b/src/SDL_dataqueue.c @@ -54,7 +54,7 @@ SDL_DataQueue *SDL_NewDataQueue(const size_t _packetlen, const size_t initialsla { SDL_DataQueue *queue = (SDL_DataQueue *)SDL_calloc(1, sizeof(SDL_DataQueue)); - if (queue == NULL) { + if (!queue) { SDL_OutOfMemory(); } else { const size_t packetlen = _packetlen ? _packetlen : 1024; @@ -101,7 +101,7 @@ void SDL_ClearDataQueue(SDL_DataQueue *queue, const size_t slack) SDL_DataQueuePacket *prev = NULL; size_t i; - if (queue == NULL) { + if (!queue) { return; } @@ -144,16 +144,16 @@ static SDL_DataQueuePacket *AllocateDataQueuePacket(SDL_DataQueue *queue) { SDL_DataQueuePacket *packet; - SDL_assert(queue != NULL); + SDL_assert(queue); packet = queue->pool; - if (packet != NULL) { + if (packet) { /* we have one available in the pool. */ queue->pool = packet->next; } else { /* Have to allocate a new one! */ packet = (SDL_DataQueuePacket *)SDL_malloc(sizeof(SDL_DataQueuePacket) + queue->packet_size); - if (packet == NULL) { + if (!packet) { return NULL; } } @@ -162,8 +162,8 @@ static SDL_DataQueuePacket *AllocateDataQueuePacket(SDL_DataQueue *queue) packet->startpos = 0; packet->next = NULL; - SDL_assert((queue->head != NULL) == (queue->queued_bytes != 0)); - if (queue->tail == NULL) { + SDL_assert((queue->head) == (queue->queued_bytes != 0)); + if (!queue->tail) { queue->head = packet; } else { queue->tail->next = packet; @@ -182,7 +182,7 @@ int SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *_data, const size_t _ size_t origlen; size_t datalen; - if (queue == NULL) { + if (!queue) { return SDL_InvalidParamError("queue"); } @@ -194,13 +194,13 @@ int SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *_data, const size_t _ while (len > 0) { SDL_DataQueuePacket *packet = queue->tail; - SDL_assert(packet == NULL || (packet->datalen <= packet_size)); - if (packet == NULL || (packet->datalen >= packet_size)) { + SDL_assert(!packet || (packet->datalen <= packet_size)); + if (!packet || (packet->datalen >= packet_size)) { /* tail packet missing or completely full; we need a new packet. */ packet = AllocateDataQueuePacket(queue); - if (packet == NULL) { + if (!packet) { /* uhoh, reset so we've queued nothing new, free what we can. */ - if (origtail == NULL) { + if (!origtail) { packet = queue->head; /* whole queue. */ } else { packet = origtail->next; /* what we added to existing queue. */ @@ -238,7 +238,7 @@ SDL_PeekIntoDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len) Uint8 *ptr = buf; SDL_DataQueuePacket *packet; - if (queue == NULL) { + if (!queue) { return 0; } @@ -267,7 +267,7 @@ SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len) Uint8 *ptr = buf; SDL_DataQueuePacket *packet; - if (queue == NULL) { + if (!queue) { return 0; } @@ -286,15 +286,15 @@ SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len) if (packet->startpos == packet->datalen) { /* packet is done, put it in the pool. */ queue->head = packet->next; - SDL_assert((packet->next != NULL) || (packet == queue->tail)); + SDL_assert((packet->next) || (packet == queue->tail)); packet->next = queue->pool; queue->pool = packet; } } - SDL_assert((queue->head != NULL) == (queue->queued_bytes != 0)); + SDL_assert((queue->head) == (queue->queued_bytes != 0)); - if (queue->head == NULL) { + if (!queue->head) { queue->tail = NULL; /* in case we drained the queue entirely. */ } diff --git a/src/SDL_guid.c b/src/SDL_guid.c index f8c4c60080586..d8d20cdddfed1 100644 --- a/src/SDL_guid.c +++ b/src/SDL_guid.c @@ -29,7 +29,7 @@ void SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID) static const char k_rgchHexToASCII[] = "0123456789abcdef"; int i; - if ((pszGUID == NULL) || (cbGUID <= 0)) { + if ((!pszGUID) || (cbGUID <= 0)) { return; } diff --git a/src/SDL_hints.c b/src/SDL_hints.c index 2144960a42106..88f112258af33 100644 --- a/src/SDL_hints.c +++ b/src/SDL_hints.c @@ -66,7 +66,7 @@ SDL_bool SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPr return SDL_FALSE; } if (hint->value != value && - (value == NULL || !hint->value || SDL_strcmp(hint->value, value) != 0)) { + (!value || !hint->value || SDL_strcmp(hint->value, value) != 0)) { for (entry = hint->callbacks; entry;) { /* Save the next entry in case this one is deleted */ SDL_HintWatch *next = entry->next; @@ -196,7 +196,7 @@ void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *user SDL_HintWatch *entry; const char *value; - if (name == NULL || !*name) { + if (!name || !*name) { SDL_InvalidParamError("name"); return; } @@ -208,7 +208,7 @@ void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *user SDL_DelHintCallback(name, callback, userdata); entry = (SDL_HintWatch *)SDL_malloc(sizeof(*entry)); - if (entry == NULL) { + if (!entry) { SDL_OutOfMemory(); return; } @@ -220,10 +220,10 @@ void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *user break; } } - if (hint == NULL) { + if (!hint) { /* Need to add a hint entry for this watcher */ hint = (SDL_Hint *)SDL_malloc(sizeof(*hint)); - if (hint == NULL) { + if (!hint) { SDL_OutOfMemory(); SDL_free(entry); return; diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c index e551b79b10d6c..bf6665df5db48 100644 --- a/src/audio/SDL_audiocvt.c +++ b/src/audio/SDL_audiocvt.c @@ -266,7 +266,7 @@ int SDL_ConvertAudio(SDL_AudioCVT *cvt) /* !!! FIXME: (actually, we can't...len_cvt needs to be updated. Grr.) */ /* Make sure there's data to convert */ - if (cvt->buf == NULL) { + if (!cvt->buf) { return SDL_SetError("No buffer allocated for conversion"); } @@ -517,7 +517,7 @@ static void SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioF /* we keep no streaming state here, so pad with silence on both ends. */ padding = (float *)SDL_calloc(paddingsamples ? paddingsamples : 1, sizeof(float)); - if (padding == NULL) { + if (!padding) { SDL_OutOfMemory(); return; } @@ -614,7 +614,7 @@ static int SDL_BuildAudioResampleCVT(SDL_AudioCVT *cvt, const int dst_channels, } filter = ChooseCVTResampler(dst_channels); - if (filter == NULL) { + if (!filter) { return SDL_SetError("No conversion available for these rates"); } @@ -687,7 +687,7 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt, SDL_AudioFilter channel_converter = NULL; /* Sanity check target pointer */ - if (cvt == NULL) { + if (!cvt) { return SDL_InvalidParamError("cvt"); } @@ -782,7 +782,7 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt, SDL_assert(dst_channels <= SDL_arraysize(channel_converters[0])); channel_converter = channel_converters[src_channels - 1][dst_channels - 1]; - if ((channel_converter == NULL) != (src_channels == dst_channels)) { + if ((!channel_converter) != (src_channels == dst_channels)) { /* All combinations of supported channel counts should have been handled by now, but let's be defensive */ return SDL_SetError("Invalid channel combination"); } else if (channel_converter != NULL) { @@ -878,7 +878,7 @@ static Uint8 *EnsureStreamBufferSize(SDL_AudioStream *stream, int newlen) ptr = stream->work_buffer_base; } else { ptr = (Uint8 *)SDL_realloc(stream->work_buffer_base, (size_t)newlen + 32); - if (ptr == NULL) { + if (!ptr) { SDL_OutOfMemory(); return NULL; } @@ -950,12 +950,12 @@ static SDL_bool SetupLibSampleRateResampling(SDL_AudioStream *stream) if (SRC_available) { state = SRC_src_new(SRC_converter, stream->pre_resample_channels, &result); - if (state == NULL) { + if (!state) { SDL_SetError("src_new() failed: %s", SRC_src_strerror(result)); } } - if (state == NULL) { + if (!state) { SDL_CleanupAudioStreamResampler_SRC(stream); return SDL_FALSE; } @@ -1027,7 +1027,7 @@ SDL_AudioStream *SDL_NewAudioStream(const SDL_AudioFormat src_format, } retval = (SDL_AudioStream *)SDL_calloc(1, sizeof(SDL_AudioStream)); - if (retval == NULL) { + if (!retval) { SDL_OutOfMemory(); return NULL; } @@ -1053,7 +1053,7 @@ SDL_AudioStream *SDL_NewAudioStream(const SDL_AudioFormat src_format, retval->resampler_padding_samples = ResamplerPadding(retval->src_rate, retval->dst_rate) * pre_resample_channels; retval->resampler_padding = (float *)SDL_calloc(retval->resampler_padding_samples ? retval->resampler_padding_samples : 1, sizeof(float)); - if (retval->resampler_padding == NULL) { + if (!retval->resampler_padding) { SDL_FreeAudioStream(retval); SDL_OutOfMemory(); return NULL; @@ -1062,7 +1062,7 @@ SDL_AudioStream *SDL_NewAudioStream(const SDL_AudioFormat src_format, retval->staging_buffer_size = ((retval->resampler_padding_samples / retval->pre_resample_channels) * retval->src_sample_frame_size); if (retval->staging_buffer_size > 0) { retval->staging_buffer = (Uint8 *)SDL_malloc(retval->staging_buffer_size); - if (retval->staging_buffer == NULL) { + if (!retval->staging_buffer) { SDL_FreeAudioStream(retval); SDL_OutOfMemory(); return NULL; @@ -1169,7 +1169,7 @@ static int SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf, #endif workbuf = EnsureStreamBufferSize(stream, workbuflen); - if (workbuf == NULL) { + if (!workbuf) { return -1; /* probably out of memory. */ } @@ -1260,10 +1260,10 @@ int SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len) SDL_Log("AUDIOSTREAM: wants to put %d preconverted bytes\n", buflen); #endif - if (stream == NULL) { + if (!stream) { return SDL_InvalidParamError("stream"); } - if (buf == NULL) { + if (!buf) { return SDL_InvalidParamError("buf"); } if (len == 0) { @@ -1373,10 +1373,10 @@ int SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len) SDL_Log("AUDIOSTREAM: want to get %d converted bytes\n", len); #endif - if (stream == NULL) { + if (!stream) { return SDL_InvalidParamError("stream"); } - if (buf == NULL) { + if (!buf) { return SDL_InvalidParamError("buf"); } if (len <= 0) { @@ -1397,7 +1397,7 @@ int SDL_AudioStreamAvailable(SDL_AudioStream *stream) void SDL_AudioStreamClear(SDL_AudioStream *stream) { - if (stream == NULL) { + if (!stream) { SDL_InvalidParamError("stream"); } else { SDL_ClearDataQueue(stream->queue, (size_t)stream->packetlen * 2); diff --git a/src/audio/SDL_audiodev.c b/src/audio/SDL_audiodev.c index ac35cb265819f..fb2fb9904c33e 100644 --- a/src/audio/SDL_audiodev.c +++ b/src/audio/SDL_audiodev.c @@ -81,16 +81,16 @@ static void SDL_EnumUnixAudioDevices_Internal(const int iscapture, const int cla const char *audiodev; char audiopath[1024]; - if (test == NULL) { + if (!test) { test = test_stub; } /* Figure out what our audio device is */ audiodev = SDL_getenv("SDL_PATH_DSP"); - if (audiodev == NULL) { + if (!audiodev) { audiodev = SDL_getenv("AUDIODEV"); } - if (audiodev == NULL) { + if (!audiodev) { if (classic) { audiodev = _PATH_DEV_AUDIO; } else { diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c index 63de906e04232..5504b257b56d2 100644 --- a/src/audio/SDL_wave.c +++ b/src/audio/SDL_wave.c @@ -2085,16 +2085,16 @@ SDL_AudioSpec *SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, SDL_zero(file); /* Make sure we are passed a valid data source */ - if (src == NULL) { + if (!src) { /* Error may come from RWops. */ return NULL; - } else if (spec == NULL) { + } else if (!spec) { SDL_InvalidParamError("spec"); return NULL; - } else if (audio_buf == NULL) { + } else if (!audio_buf) { SDL_InvalidParamError("audio_buf"); return NULL; - } else if (audio_len == NULL) { + } else if (!audio_len) { SDL_InvalidParamError("audio_len"); return NULL; } diff --git a/src/audio/aaudio/SDL_aaudio.c b/src/audio/aaudio/SDL_aaudio.c index f1168d62da67b..4e389a157c2a0 100644 --- a/src/audio/aaudio/SDL_aaudio.c +++ b/src/audio/aaudio/SDL_aaudio.c @@ -77,8 +77,8 @@ static int aaudio_OpenDevice(_THIS, const char *devname) aaudio_result_t res; LOGI(__func__); - SDL_assert((captureDevice == NULL) || !iscapture); - SDL_assert((audioDevice == NULL) || iscapture); + SDL_assert((!captureDevice) || !iscapture); + SDL_assert((!audioDevice) || iscapture); if (iscapture) { if (!Android_JNI_RequestPermission("android.permission.RECORD_AUDIO")) { @@ -94,14 +94,14 @@ static int aaudio_OpenDevice(_THIS, const char *devname) } this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } private = this->hidden; ctx.AAudioStreamBuilder_setSampleRate(ctx.builder, this->spec.freq); ctx.AAudioStreamBuilder_setChannelCount(ctx.builder, this->spec.channels); - if(devname != NULL) { + if(devname) { int aaudio_device_id = SDL_atoi(devname); LOGI("Opening device id %d", aaudio_device_id); ctx.AAudioStreamBuilder_setDeviceId(ctx.builder, aaudio_device_id); @@ -153,7 +153,7 @@ static int aaudio_OpenDevice(_THIS, const char *devname) if (!iscapture) { private->mixlen = this->spec.size; private->mixbuf = (Uint8 *)SDL_malloc(private->mixlen); - if (private->mixbuf == NULL) { + if (!private->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(private->mixbuf, this->spec.silence, this->spec.size); @@ -300,7 +300,7 @@ static SDL_bool aaudio_Init(SDL_AudioDriverImpl *impl) goto failure; } - if (ctx.builder == NULL) { + if (!ctx.builder) { LOGI("SDL Failed AAudio_createStreamBuilder - builder NULL"); goto failure; } @@ -344,7 +344,7 @@ void aaudio_PauseDevices(void) { /* TODO: Handle multiple devices? */ struct SDL_PrivateAudioData *private; - if (audioDevice != NULL && audioDevice->hidden != NULL) { + if (audioDevice && audioDevice->hidden) { private = (struct SDL_PrivateAudioData *)audioDevice->hidden; if (private->stream) { @@ -365,7 +365,7 @@ void aaudio_PauseDevices(void) } } - if (captureDevice != NULL && captureDevice->hidden != NULL) { + if (captureDevice && captureDevice->hidden) { private = (struct SDL_PrivateAudioData *)captureDevice->hidden; if (private->stream) { @@ -393,7 +393,7 @@ void aaudio_ResumeDevices(void) { /* TODO: Handle multiple devices? */ struct SDL_PrivateAudioData *private; - if (audioDevice != NULL && audioDevice->hidden != NULL) { + if (audioDevice && audioDevice->hidden) { private = (struct SDL_PrivateAudioData *)audioDevice->hidden; if (private->resume) { @@ -411,7 +411,7 @@ void aaudio_ResumeDevices(void) } } - if (captureDevice != NULL && captureDevice->hidden != NULL) { + if (captureDevice && captureDevice->hidden) { private = (struct SDL_PrivateAudioData *)captureDevice->hidden; if (private->resume) { @@ -441,7 +441,7 @@ SDL_bool aaudio_DetectBrokenPlayState(void) int64_t framePosition, timeNanoseconds; aaudio_result_t res; - if (audioDevice == NULL || !audioDevice->hidden) { + if (!audioDevice || !audioDevice->hidden) { return SDL_FALSE; } diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index f766573de9bf5..ab837f6cb2215 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -98,7 +98,7 @@ static void *alsa_handle = NULL; static int load_alsa_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(alsa_handle, fn); - if (*addr == NULL) { + if (!*addr) { /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ return 0; } @@ -208,13 +208,13 @@ static const char *get_audio_device(void *handle, const int channels) { const char *device; - if (handle != NULL) { + if (handle) { return (const char *)handle; } /* !!! FIXME: we also check "SDL_AUDIO_DEVICE_NAME" at the higher level. */ device = SDL_getenv("AUDIODEV"); /* Is there a standard variable name? */ - if (device != NULL) { + if (device) { return device; } @@ -539,7 +539,7 @@ static int ALSA_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -687,7 +687,7 @@ static int ALSA_OpenDevice(_THIS, const char *devname) if (!iscapture) { this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->hidden->mixlen); @@ -735,20 +735,20 @@ static void add_device(const int iscapture, const char *name, void *hint, ALSA_D desc = (char *)name; } - SDL_assert(name != NULL); + SDL_assert(name); /* some strings have newlines, like "HDA NVidia, HDMI 0\nHDMI Audio Output". just chop the extra lines off, this seems to get a reasonable device name without extra details. */ ptr = SDL_strchr(desc, '\n'); - if (ptr != NULL) { + if (ptr) { *ptr = '\0'; } /*printf("ALSA: adding %s device '%s' (%s)\n", iscapture ? "capture" : "output", name, desc);*/ handle = SDL_strdup(name); - if (handle == NULL) { + if (!handle) { if (hint) { free(desc); } @@ -829,20 +829,20 @@ static void ALSA_HotplugIteration(void) char *name; /* if we didn't find a device name prefix we like at all... */ - if ((match == NULL) && (defaultdev != i)) { + if ((!match) && (defaultdev != i)) { continue; /* ...skip anything that isn't the default device. */ } name = ALSA_snd_device_name_get_hint(hints[i], "NAME"); - if (name == NULL) { + if (!name) { continue; } /* only want physical hardware interfaces */ - if (match == NULL || (SDL_strncmp(name, match, match_len) == 0)) { + if (!match || (SDL_strncmp(name, match, match_len) == 0)) { char *ioid = ALSA_snd_device_name_get_hint(hints[i], "IOID"); - const SDL_bool isoutput = (ioid == NULL) || (SDL_strcmp(ioid, "Output") == 0); - const SDL_bool isinput = (ioid == NULL) || (SDL_strcmp(ioid, "Input") == 0); + const SDL_bool isoutput = (!ioid) || (SDL_strcmp(ioid, "Output") == 0); + const SDL_bool isinput = (!ioid) || (SDL_strcmp(ioid, "Input") == 0); SDL_bool have_output = SDL_FALSE; SDL_bool have_input = SDL_FALSE; diff --git a/src/audio/android/SDL_androidaudio.c b/src/audio/android/SDL_androidaudio.c index b46fdda093a70..03874d0eb50d8 100644 --- a/src/audio/android/SDL_androidaudio.c +++ b/src/audio/android/SDL_androidaudio.c @@ -41,8 +41,8 @@ static int ANDROIDAUDIO_OpenDevice(_THIS, const char *devname) SDL_AudioFormat test_format; SDL_bool iscapture = this->iscapture; - SDL_assert((captureDevice == NULL) || !iscapture); - SDL_assert((audioDevice == NULL) || iscapture); + SDL_assert((!captureDevice) || !iscapture); + SDL_assert((!audioDevice) || iscapture); if (iscapture) { captureDevice = this; @@ -51,7 +51,7 @@ static int ANDROIDAUDIO_OpenDevice(_THIS, const char *devname) } this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } @@ -71,7 +71,7 @@ static int ANDROIDAUDIO_OpenDevice(_THIS, const char *devname) { int audio_device_id = 0; - if (devname != NULL) { + if (devname) { audio_device_id = SDL_atoi(devname); } if (Android_JNI_OpenAudioDevice(iscapture, audio_device_id, &this->spec) < 0) { @@ -149,7 +149,7 @@ void ANDROIDAUDIO_PauseDevices(void) { /* TODO: Handle multiple devices? */ struct SDL_PrivateAudioData *private; - if (audioDevice != NULL && audioDevice->hidden != NULL) { + if (audioDevice && audioDevice->hidden) { private = (struct SDL_PrivateAudioData *)audioDevice->hidden; if (SDL_AtomicGet(&audioDevice->paused)) { /* The device is already paused, leave it alone */ @@ -161,7 +161,7 @@ void ANDROIDAUDIO_PauseDevices(void) } } - if (captureDevice != NULL && captureDevice->hidden != NULL) { + if (captureDevice && captureDevice->hidden) { private = (struct SDL_PrivateAudioData *)captureDevice->hidden; if (SDL_AtomicGet(&captureDevice->paused)) { /* The device is already paused, leave it alone */ @@ -179,7 +179,7 @@ void ANDROIDAUDIO_ResumeDevices(void) { /* TODO: Handle multiple devices? */ struct SDL_PrivateAudioData *private; - if (audioDevice != NULL && audioDevice->hidden != NULL) { + if (audioDevice && audioDevice->hidden) { private = (struct SDL_PrivateAudioData *)audioDevice->hidden; if (private->resume) { SDL_AtomicSet(&audioDevice->paused, 0); @@ -188,7 +188,7 @@ void ANDROIDAUDIO_ResumeDevices(void) } } - if (captureDevice != NULL && captureDevice->hidden != NULL) { + if (captureDevice && captureDevice->hidden) { private = (struct SDL_PrivateAudioData *)captureDevice->hidden; if (private->resume) { SDL_AtomicSet(&captureDevice->paused, 0); diff --git a/src/audio/arts/SDL_artsaudio.c b/src/audio/arts/SDL_artsaudio.c index f3aa94b1504e3..632df6fe7c41d 100644 --- a/src/audio/arts/SDL_artsaudio.c +++ b/src/audio/arts/SDL_artsaudio.c @@ -88,7 +88,7 @@ static struct static void UnloadARTSLibrary() { - if (arts_handle != NULL) { + if (arts_handle) { SDL_UnloadObject(arts_handle); arts_handle = NULL; } @@ -98,9 +98,9 @@ static int LoadARTSLibrary(void) { int i, retval = -1; - if (arts_handle == NULL) { + if (!arts_handle) { arts_handle = SDL_LoadObject(arts_library); - if (arts_handle != NULL) { + if (arts_handle) { retval = 0; for (i = 0; i < SDL_arraysize(arts_functions); ++i) { *arts_functions[i].func = @@ -214,7 +214,7 @@ static int ARTS_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -281,7 +281,7 @@ static int ARTS_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); diff --git a/src/audio/directsound/SDL_directsound.c b/src/audio/directsound/SDL_directsound.c index 705837b01b316..99755b812ae74 100644 --- a/src/audio/directsound/SDL_directsound.c +++ b/src/audio/directsound/SDL_directsound.c @@ -354,7 +354,7 @@ static int DSOUND_CaptureFromDevice(_THIS, void *buffer, int buflen) } SDL_assert(ptr1len == this->spec.size); - SDL_assert(ptr2 == NULL); + SDL_assert(!ptr2); SDL_assert(ptr2len == 0); SDL_memcpy(buffer, ptr1, ptr1len); @@ -379,18 +379,18 @@ static void DSOUND_FlushCapture(_THIS) static void DSOUND_CloseDevice(_THIS) { - if (this->hidden->mixbuf != NULL) { + if (this->hidden->mixbuf) { IDirectSoundBuffer_Stop(this->hidden->mixbuf); IDirectSoundBuffer_Release(this->hidden->mixbuf); } - if (this->hidden->sound != NULL) { + if (this->hidden->sound) { IDirectSound_Release(this->hidden->sound); } - if (this->hidden->capturebuf != NULL) { + if (this->hidden->capturebuf) { IDirectSoundCaptureBuffer_Stop(this->hidden->capturebuf); IDirectSoundCaptureBuffer_Release(this->hidden->capturebuf); } - if (this->hidden->capture != NULL) { + if (this->hidden->capture) { IDirectSoundCapture_Release(this->hidden->capture); } SDL_free(this->hidden); @@ -493,7 +493,7 @@ static int DSOUND_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); diff --git a/src/audio/disk/SDL_diskaudio.c b/src/audio/disk/SDL_diskaudio.c index e98dbea7e8c4f..cd37e53bbb3b7 100644 --- a/src/audio/disk/SDL_diskaudio.c +++ b/src/audio/disk/SDL_diskaudio.c @@ -98,7 +98,7 @@ static void DISKAUDIO_FlushCapture(_THIS) static void DISKAUDIO_CloseDevice(_THIS) { - if (_this->hidden->io != NULL) { + if (_this->hidden->io) { SDL_RWclose(_this->hidden->io); } SDL_free(_this->hidden->mixbuf); @@ -107,9 +107,9 @@ static void DISKAUDIO_CloseDevice(_THIS) static const char *get_filename(const SDL_bool iscapture, const char *devname) { - if (devname == NULL) { + if (!devname) { devname = SDL_getenv(iscapture ? DISKENVR_INFILE : DISKENVR_OUTFILE); - if (devname == NULL) { + if (!devname) { devname = iscapture ? DISKDEFAULT_INFILE : DISKDEFAULT_OUTFILE; } } @@ -126,12 +126,12 @@ static int DISKAUDIO_OpenDevice(_THIS, const char *devname) _this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*_this->hidden)); - if (_this->hidden == NULL) { + if (!_this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(_this->hidden); - if (envr != NULL) { + if (envr) { _this->hidden->io_delay = SDL_atoi(envr); } else { _this->hidden->io_delay = ((_this->spec.samples * 1000) / _this->spec.freq); @@ -139,14 +139,14 @@ static int DISKAUDIO_OpenDevice(_THIS, const char *devname) /* Open the audio device */ _this->hidden->io = SDL_RWFromFile(fname, iscapture ? "rb" : "wb"); - if (_this->hidden->io == NULL) { + if (!_this->hidden->io) { return -1; } /* Allocate mixing buffer */ if (!iscapture) { _this->hidden->mixbuf = (Uint8 *)SDL_malloc(_this->spec.size); - if (_this->hidden->mixbuf == NULL) { + if (!_this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(_this->hidden->mixbuf, _this->spec.silence, _this->spec.size); diff --git a/src/audio/dsp/SDL_dspaudio.c b/src/audio/dsp/SDL_dspaudio.c index 441aa2574f41a..cb8bb7a6826a3 100644 --- a/src/audio/dsp/SDL_dspaudio.c +++ b/src/audio/dsp/SDL_dspaudio.c @@ -67,9 +67,9 @@ static int DSP_OpenDevice(_THIS, const char *devname) /* We don't care what the devname is...we'll try to open anything. */ /* ...but default to first name in the list... */ - if (devname == NULL) { + if (!devname) { devname = SDL_GetAudioDeviceName(0, iscapture); - if (devname == NULL) { + if (!devname) { return SDL_SetError("No such audio device"); } } @@ -86,7 +86,7 @@ static int DSP_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -228,7 +228,7 @@ static int DSP_OpenDevice(_THIS, const char *devname) if (!iscapture) { this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); diff --git a/src/audio/emscripten/SDL_emscriptenaudio.c b/src/audio/emscripten/SDL_emscriptenaudio.c index a7dca5d8832ba..a89d34fd81ad2 100644 --- a/src/audio/emscripten/SDL_emscriptenaudio.c +++ b/src/audio/emscripten/SDL_emscriptenaudio.c @@ -70,7 +70,7 @@ static void HandleAudioProcess(_THIS) return; } - if (this->stream == NULL) { /* no conversion necessary. */ + if (!this->stream) { /* no conversion necessary. */ SDL_assert(this->spec.size == stream_len); callback(this->callbackspec.userdata, this->work_buffer, stream_len); } else { /* streaming/converting */ @@ -130,7 +130,7 @@ static void HandleCaptureProcess(_THIS) /* okay, we've got an interleaved float32 array in C now. */ - if (this->stream == NULL) { /* no conversion necessary. */ + if (!this->stream) { /* no conversion necessary. */ SDL_assert(this->spec.size == stream_len); callback(this->callbackspec.userdata, this->work_buffer, stream_len); } else { /* streaming/converting */ diff --git a/src/audio/esd/SDL_esdaudio.c b/src/audio/esd/SDL_esdaudio.c index 800caaf0b8078..c2ad33ba8fc9d 100644 --- a/src/audio/esd/SDL_esdaudio.c +++ b/src/audio/esd/SDL_esdaudio.c @@ -66,7 +66,7 @@ static struct static void UnloadESDLibrary() { - if (esd_handle != NULL) { + if (esd_handle) { SDL_UnloadObject(esd_handle); esd_handle = NULL; } @@ -76,7 +76,7 @@ static int LoadESDLibrary(void) { int i, retval = -1; - if (esd_handle == NULL) { + if (!esd_handle) { esd_handle = SDL_LoadObject(esd_library); if (esd_handle) { retval = 0; @@ -185,7 +185,7 @@ static char *get_progname(void) if (fp != NULL) { if (fgets(temp, sizeof(temp) - 1, fp)) { progname = SDL_strrchr(temp, '/'); - if (progname == NULL) { + if (!progname) { progname = temp; } else { progname = progname + 1; @@ -206,7 +206,7 @@ static int ESD_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -264,7 +264,7 @@ static int ESD_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); diff --git a/src/audio/fusionsound/SDL_fsaudio.c b/src/audio/fusionsound/SDL_fsaudio.c index f79ab22f70c4a..077fa57c8aea1 100644 --- a/src/audio/fusionsound/SDL_fsaudio.c +++ b/src/audio/fusionsound/SDL_fsaudio.c @@ -79,7 +79,7 @@ static struct static void UnloadFusionSoundLibrary() { - if (fs_handle != NULL) { + if (fs_handle) { SDL_UnloadObject(fs_handle); fs_handle = NULL; } @@ -89,9 +89,9 @@ static int LoadFusionSoundLibrary(void) { int i, retval = -1; - if (fs_handle == NULL) { + if (!fs_handle) { fs_handle = SDL_LoadObject(fs_library); - if (fs_handle != NULL) { + if (fs_handle) { retval = 0; for (i = 0; i < SDL_arraysize(fs_functions); ++i) { *fs_functions[i].func = @@ -175,7 +175,7 @@ static int SDL_FS_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -250,7 +250,7 @@ static int SDL_FS_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); diff --git a/src/audio/haiku/SDL_haikuaudio.cc b/src/audio/haiku/SDL_haikuaudio.cc index ca946ed756877..02678ff19738a 100644 --- a/src/audio/haiku/SDL_haikuaudio.cc +++ b/src/audio/haiku/SDL_haikuaudio.cc @@ -59,7 +59,7 @@ static void FillSound(void *device, void *stream, size_t len, } else { SDL_assert(audio->spec.size == len); - if (audio->stream == NULL) { /* no conversion necessary. */ + if (!audio->stream) { /* no conversion necessary. */ callback(audio->callbackspec.userdata, (Uint8 *) stream, len); } else { /* streaming/converting */ const int stream_len = audio->callbackspec.size; diff --git a/src/audio/jack/SDL_jackaudio.c b/src/audio/jack/SDL_jackaudio.c index b47bb2217ec55..94ea12dc510a9 100644 --- a/src/audio/jack/SDL_jackaudio.c +++ b/src/audio/jack/SDL_jackaudio.c @@ -58,7 +58,7 @@ static void *jack_handle = NULL; static int load_jack_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(jack_handle, fn); - if (*addr == NULL) { + if (!*addr) { /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ return 0; } @@ -341,7 +341,7 @@ static int JACK_OpenDevice(_THIS, const char *devname) /* Build SDL's ports, which we will connect to the device ports. */ this->hidden->sdlports = (jack_port_t **)SDL_calloc(channels, sizeof(jack_port_t *)); - if (this->hidden->sdlports == NULL) { + if (!this->hidden->sdlports) { SDL_free(audio_ports); return SDL_OutOfMemory(); } diff --git a/src/audio/n3ds/SDL_n3dsaudio.c b/src/audio/n3ds/SDL_n3dsaudio.c index a72e364d54447..78d1a65257ac7 100644 --- a/src/audio/n3ds/SDL_n3dsaudio.c +++ b/src/audio/n3ds/SDL_n3dsaudio.c @@ -89,7 +89,7 @@ static int N3DSAUDIO_OpenDevice(_THIS, const char *devname) float mix[12]; this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } @@ -127,14 +127,14 @@ static int N3DSAUDIO_OpenDevice(_THIS, const char *devname) this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->spec.size); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); data_vaddr = (Uint8 *)linearAlloc(this->hidden->mixlen * NUM_BUFFERS); - if (data_vaddr == NULL) { + if (!data_vaddr) { return SDL_OutOfMemory(); } diff --git a/src/audio/nacl/SDL_naclaudio.c b/src/audio/nacl/SDL_naclaudio.c index cdb01bcb7b1f8..36ef6a0f15224 100644 --- a/src/audio/nacl/SDL_naclaudio.c +++ b/src/audio/nacl/SDL_naclaudio.c @@ -62,7 +62,7 @@ static void nacl_audio_callback(void* stream, uint32_t buffer_size, PP_TimeDelta } else { SDL_assert(_this->spec.size == len); - if (_this->stream == NULL) { /* no conversion necessary. */ + if (!_this->stream) { /* no conversion necessary. */ callback(_this->callbackspec.userdata, stream, len); } else { /* streaming/converting */ const int stream_len = _this->callbackspec.size; @@ -103,7 +103,7 @@ static int NACLAUDIO_OpenDevice(_THIS, const char *devname) const PPB_AudioConfig *ppb_audiocfg = PSInterfaceAudioConfig(); private = (SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*private)); - if (private == NULL) { + if (!private) { return SDL_OutOfMemory(); } diff --git a/src/audio/nas/SDL_nasaudio.c b/src/audio/nas/SDL_nasaudio.c index d6807203d85fa..0362cd6068c1a 100644 --- a/src/audio/nas/SDL_nasaudio.c +++ b/src/audio/nas/SDL_nasaudio.c @@ -59,7 +59,7 @@ static void *nas_handle = NULL; static int load_nas_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(nas_handle, fn); - if (*addr == NULL) { + if (!*addr) { return 0; } return 1; @@ -94,7 +94,7 @@ static int load_nas_syms(void) static void UnloadNASLibrary(void) { - if (nas_handle != NULL) { + if (nas_handle) { SDL_UnloadObject(nas_handle); nas_handle = NULL; } @@ -103,9 +103,9 @@ static void UnloadNASLibrary(void) static int LoadNASLibrary(void) { int retval = 0; - if (nas_handle == NULL) { + if (!nas_handle) { nas_handle = SDL_LoadObject(nas_library); - if (nas_handle == NULL) { + if (!nas_handle) { /* Copy error string so we can use it in a new SDL_SetError(). */ const char *origerr = SDL_GetError(); const size_t len = SDL_strlen(origerr) + 1; @@ -305,7 +305,7 @@ static int NAS_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -389,7 +389,7 @@ static int NAS_OpenDevice(_THIS, const char *devname) if (!iscapture) { this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); @@ -410,7 +410,7 @@ static SDL_bool NAS_Init(SDL_AudioDriverImpl * impl) return SDL_FALSE; } else { AuServer *aud = NAS_AuOpenServer("", 0, NULL, 0, NULL, NULL); - if (aud == NULL) { + if (!aud) { SDL_SetError("NAS: AuOpenServer() failed (no audio server?)"); return SDL_FALSE; } diff --git a/src/audio/netbsd/SDL_netbsdaudio.c b/src/audio/netbsd/SDL_netbsdaudio.c index d90f28a9431a1..42e638d6b09e2 100644 --- a/src/audio/netbsd/SDL_netbsdaudio.c +++ b/src/audio/netbsd/SDL_netbsdaudio.c @@ -202,16 +202,16 @@ static int NETBSDAUDIO_OpenDevice(_THIS, const char *devname) /* We don't care what the devname is...we'll try to open anything. */ /* ...but default to first name in the list... */ - if (devname == NULL) { + if (!devname) { devname = SDL_GetAudioDeviceName(0, iscapture); - if (devname == NULL) { + if (!devname) { return SDL_SetError("No such audio device"); } } /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -296,7 +296,7 @@ static int NETBSDAUDIO_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); diff --git a/src/audio/openslES/SDL_openslES.c b/src/audio/openslES/SDL_openslES.c index 998104c24ca2f..41f9ba148d61e 100644 --- a/src/audio/openslES/SDL_openslES.c +++ b/src/audio/openslES/SDL_openslES.c @@ -320,7 +320,7 @@ static int openslES_CreatePCMRecorder(_THIS) /* Create the sound buffers */ audiodata->mixbuff = (Uint8 *)SDL_malloc(NUM_BUFFERS * this->spec.size); - if (audiodata->mixbuff == NULL) { + if (!audiodata->mixbuff) { LOGE("mixbuffer allocate - out of memory"); goto failed; } @@ -566,7 +566,7 @@ static int openslES_CreatePCMPlayer(_THIS) /* Create the sound buffers */ audiodata->mixbuff = (Uint8 *)SDL_malloc(NUM_BUFFERS * this->spec.size); - if (audiodata->mixbuff == NULL) { + if (!audiodata->mixbuff) { LOGE("mixbuffer allocate - out of memory"); goto failed; } @@ -591,7 +591,7 @@ static int openslES_CreatePCMPlayer(_THIS) static int openslES_OpenDevice(_THIS, const char *devname) { this->hidden = (struct SDL_PrivateAudioData *)SDL_calloc(1, sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } diff --git a/src/audio/os2/SDL_os2audio.c b/src/audio/os2/SDL_os2audio.c index 2f1e6bc66399a..9eaa21d08cc57 100644 --- a/src/audio/os2/SDL_os2audio.c +++ b/src/audio/os2/SDL_os2audio.c @@ -43,7 +43,7 @@ static ULONG _getEnvULong(const char *name, ULONG ulMax, ULONG ulDefault) char* end; char* envval = SDL_getenv(name); - if (envval == NULL) + if (!envval) return ulDefault; ulValue = SDL_strtoul(envval, &end, 10); @@ -351,7 +351,7 @@ static void OS2_CloseDevice(_THIS) debug_os2("Enter"); - if (pAData == NULL) + if (!pAData) return; pAData->ulState = 2; @@ -429,7 +429,7 @@ static int OS2_OpenDevice(_THIS, const char *devname) } pAData = (SDL_PrivateAudioData *) SDL_calloc(1, sizeof(struct SDL_PrivateAudioData)); - if (pAData == NULL) + if (!pAData) return SDL_OutOfMemory(); _this->hidden = pAData; diff --git a/src/audio/paudio/SDL_paudio.c b/src/audio/paudio/SDL_paudio.c index 5c5c36fc29775..266cadd1d1b42 100644 --- a/src/audio/paudio/SDL_paudio.c +++ b/src/audio/paudio/SDL_paudio.c @@ -78,11 +78,11 @@ static int OpenUserDefinedDevice(char *path, int maxlen, int flags) if ((audiodev = SDL_getenv("SDL_PATH_DSP")) == NULL) { audiodev = SDL_getenv("AUDIODEV"); } - if (audiodev == NULL) { + if (!audiodev) { return -1; } fd = open(audiodev, flags, 0); - if (path != NULL) { + if (path) { SDL_strlcpy(path, audiodev, maxlen); path[maxlen - 1] = '\0'; } @@ -110,7 +110,7 @@ static int OpenAudioPath(char *path, int maxlen, int flags, int classic) if (stat(audiopath, &sb) == 0) { fd = open(audiopath, flags, 0); if (fd >= 0) { - if (path != NULL) { + if (path) { SDL_strlcpy(path, audiopath, maxlen); } return fd; @@ -232,7 +232,7 @@ static int PAUDIO_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -403,7 +403,7 @@ static int PAUDIO_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); @@ -445,7 +445,7 @@ static int PAUDIO_OpenDevice(_THIS, const char *devname) } /* Check to see if we need to use SDL_IOReady() workaround */ - if (workaround != NULL) { + if (workaround) { this->hidden->frame_ticks = (float) (this->spec.samples * 1000) / this->spec.freq; this->hidden->next_frame = SDL_GetTicks() + this->hidden->frame_ticks; diff --git a/src/audio/pipewire/SDL_pipewire.c b/src/audio/pipewire/SDL_pipewire.c index 203fc7d926ba3..60dde24fd58d6 100644 --- a/src/audio/pipewire/SDL_pipewire.c +++ b/src/audio/pipewire/SDL_pipewire.c @@ -129,7 +129,7 @@ static void *pipewire_handle = NULL; static int pipewire_dlsym(const char *fn, void **addr) { *addr = SDL_LoadFunction(pipewire_handle, fn); - if (*addr == NULL) { + if (!*addr) { /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ return 0; } @@ -347,10 +347,10 @@ static void io_list_sort() /* Find and move the default nodes to the beginning of the list */ spa_list_for_each_safe (n, temp, &hotplug_io_list, link) { - if (pipewire_default_sink_id != NULL && SDL_strcmp(n->path, pipewire_default_sink_id) == 0) { + if (pipewire_default_sink_id && SDL_strcmp(n->path, pipewire_default_sink_id) == 0) { default_sink = n; spa_list_remove(&n->link); - } else if (pipewire_default_source_id != NULL && SDL_strcmp(n->path, pipewire_default_source_id) == 0) { + } else if (pipewire_default_source_id && SDL_strcmp(n->path, pipewire_default_source_id) == 0) { default_source = n; spa_list_remove(&n->link); } @@ -648,15 +648,15 @@ static int metadata_property(void *object, Uint32 subject, const char *key, cons { struct node_object *node = object; - if (subject == PW_ID_CORE && key != NULL && value != NULL) { + if (subject == PW_ID_CORE && key && value) { if (!SDL_strcmp(key, "default.audio.sink")) { - if (pipewire_default_sink_id != NULL) { + if (pipewire_default_sink_id) { SDL_free(pipewire_default_sink_id); } pipewire_default_sink_id = get_name_from_json(value); node->persist = SDL_TRUE; } else if (!SDL_strcmp(key, "default.audio.source")) { - if (pipewire_default_source_id != NULL) { + if (pipewire_default_source_id) { SDL_free(pipewire_default_source_id); } pipewire_default_source_id = get_name_from_json(value); @@ -961,7 +961,7 @@ static void output_callback(void *data) /* See if a buffer is available */ pw_buf = PIPEWIRE_pw_stream_dequeue_buffer(stream); - if (pw_buf == NULL) { + if (!pw_buf) { return; } @@ -1025,13 +1025,13 @@ static void input_callback(void *data) } pw_buf = PIPEWIRE_pw_stream_dequeue_buffer(stream); - if (pw_buf == NULL) { + if (!pw_buf) { return; } spa_buf = pw_buf->buffer; (src = (Uint8 *)spa_buf->datas[0].data); - if (src == NULL) { + if (!src) { return; } @@ -1079,7 +1079,7 @@ static void stream_add_buffer_callback(void *data, struct pw_buffer *buffer) this->spec.samples = buffer->buffer->datas[0].maxsize / this->hidden->stride; this->spec.size = buffer->buffer->datas[0].maxsize; } - } else if (this->hidden->buffer == NULL) { + } else if (!this->hidden->buffer) { /* * The latency of source nodes can change, so buffering is always required. * @@ -1137,7 +1137,7 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname) struct SDL_PrivateAudioData *priv; struct pw_properties *props; const char *app_name, *stream_name, *stream_role, *error; - Uint32 node_id = this->handle == NULL ? PW_ID_ANY : PW_HANDLE_TO_ID(this->handle); + Uint32 node_id = !this->handle ? PW_ID_ANY : PW_HANDLE_TO_ID(this->handle); SDL_bool iscapture = this->iscapture; int res; @@ -1163,20 +1163,20 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname) * but 'Game' seems more appropriate for the majority of SDL applications. */ stream_role = SDL_GetHint(SDL_HINT_AUDIO_DEVICE_STREAM_ROLE); - if (stream_role == NULL || *stream_role == '\0') { + if (!stream_role || *stream_role == '\0') { stream_role = "Game"; } /* Initialize the Pipewire stream info from the SDL audio spec */ initialize_spa_info(&this->spec, &spa_info); params = spa_format_audio_raw_build(&b, SPA_PARAM_EnumFormat, &spa_info); - if (params == NULL) { + if (!params) { return SDL_SetError("Pipewire: Failed to set audio format parameters"); } priv = SDL_calloc(1, sizeof(struct SDL_PrivateAudioData)); this->hidden = priv; - if (priv == NULL) { + if (!priv) { return SDL_OutOfMemory(); } @@ -1190,23 +1190,23 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname) (void)SDL_snprintf(thread_name, sizeof(thread_name), "SDLAudio%c%ld", (iscapture) ? 'C' : 'P', (long)this->handle); priv->loop = PIPEWIRE_pw_thread_loop_new(thread_name, NULL); - if (priv->loop == NULL) { + if (!priv->loop) { return SDL_SetError("Pipewire: Failed to create stream loop (%i)", errno); } /* Load the realtime module so Pipewire can set the loop thread to the appropriate priority. */ props = PIPEWIRE_pw_properties_new(PW_KEY_CONFIG_NAME, "client-rt.conf", NULL); - if (props == NULL) { + if (!props) { return SDL_SetError("Pipewire: Failed to create stream context properties (%i)", errno); } priv->context = PIPEWIRE_pw_context_new(PIPEWIRE_pw_thread_loop_get_loop(priv->loop), props, 0); - if (priv->context == NULL) { + if (!priv->context) { return SDL_SetError("Pipewire: Failed to create stream context (%i)", errno); } props = PIPEWIRE_pw_properties_new(NULL, NULL); - if (props == NULL) { + if (!props) { return SDL_SetError("Pipewire: Failed to create stream properties (%i)", errno); } @@ -1244,7 +1244,7 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname) /* Create the new stream */ priv->stream = PIPEWIRE_pw_stream_new_simple(PIPEWIRE_pw_thread_loop_get_loop(priv->loop), stream_name, props, iscapture ? &stream_input_events : &stream_output_events, this); - if (priv->stream == NULL) { + if (!priv->stream) { return SDL_SetError("Pipewire: Failed to create stream (%i)", errno); } @@ -1272,7 +1272,7 @@ static int PIPEWIRE_OpenDevice(_THIS, const char *devname) } /* If this is a capture stream, make sure the intermediate buffer was successfully allocated. */ - if (iscapture && priv->buffer == NULL) { + if (iscapture && !priv->buffer) { return SDL_SetError("Pipewire: Failed to allocate source buffer"); } @@ -1313,13 +1313,13 @@ static int PIPEWIRE_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int is PIPEWIRE_pw_thread_loop_lock(hotplug_loop); if (iscapture) { - if (pipewire_default_source_id == NULL) { + if (!pipewire_default_source_id) { ret = SDL_SetError("PipeWire could not find a default source"); goto failed; } target = pipewire_default_source_id; } else { - if (pipewire_default_sink_id == NULL) { + if (!pipewire_default_sink_id) { ret = SDL_SetError("PipeWire could not find a default sink"); goto failed; } @@ -1327,12 +1327,12 @@ static int PIPEWIRE_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int is } node = io_list_get_by_path(target); - if (node == NULL) { + if (!node) { ret = SDL_SetError("PipeWire device list is out of sync with defaults"); goto failed; } - if (name != NULL) { + if (name) { *name = SDL_strdup(node->name); } SDL_copyp(spec, &node->spec); diff --git a/src/audio/ps2/SDL_ps2audio.c b/src/audio/ps2/SDL_ps2audio.c index ffbf6c5cf116c..d796c119b2a2e 100644 --- a/src/audio/ps2/SDL_ps2audio.c +++ b/src/audio/ps2/SDL_ps2audio.c @@ -42,7 +42,7 @@ static int PS2AUDIO_OpenDevice(_THIS, const char *devname) this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -90,7 +90,7 @@ static int PS2AUDIO_OpenDevice(_THIS, const char *devname) 64, so spec->size should be a multiple of 64 as well. */ mixlen = this->spec.size * NUM_BUFFERS; this->hidden->rawbuf = (Uint8 *)memalign(64, mixlen); - if (this->hidden->rawbuf == NULL) { + if (!this->hidden->rawbuf) { return SDL_SetError("Couldn't allocate mixing buffer"); } @@ -129,7 +129,7 @@ static void PS2AUDIO_CloseDevice(_THIS) this->hidden->channel = -1; } - if (this->hidden->rawbuf != NULL) { + if (this->hidden->rawbuf) { free(this->hidden->rawbuf); this->hidden->rawbuf = NULL; } diff --git a/src/audio/psp/SDL_pspaudio.c b/src/audio/psp/SDL_pspaudio.c index 3b0156489aa66..c19a4b8aa7729 100644 --- a/src/audio/psp/SDL_pspaudio.c +++ b/src/audio/psp/SDL_pspaudio.c @@ -52,7 +52,7 @@ static int PSPAUDIO_OpenDevice(_THIS, const char *devname) this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -108,7 +108,7 @@ static int PSPAUDIO_OpenDevice(_THIS, const char *devname) 64, so spec->size should be a multiple of 64 as well. */ mixlen = this->spec.size * NUM_BUFFERS; this->hidden->rawbuf = (Uint8 *)memalign(64, mixlen); - if (this->hidden->rawbuf == NULL) { + if (!this->hidden->rawbuf) { return SDL_SetError("Couldn't allocate mixing buffer"); } @@ -156,7 +156,7 @@ static void PSPAUDIO_CloseDevice(_THIS) this->hidden->channel = -1; } - if (this->hidden->rawbuf != NULL) { + if (this->hidden->rawbuf) { free(this->hidden->rawbuf); this->hidden->rawbuf = NULL; } diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c index 05db9e6658701..1d8d0cc91d752 100644 --- a/src/audio/pulseaudio/SDL_pulseaudio.c +++ b/src/audio/pulseaudio/SDL_pulseaudio.c @@ -125,7 +125,7 @@ static void *pulseaudio_handle = NULL; static int load_pulseaudio_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(pulseaudio_handle, fn); - if (*addr == NULL) { + if (!*addr) { /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ return 0; } @@ -257,7 +257,7 @@ static const char *getAppName(void) } else { const char *verstr = PULSEAUDIO_pa_get_library_version(); retval = "SDL Application"; /* the "oh well" default. */ - if (verstr != NULL) { + if (verstr) { int maj, min, patch; if (SDL_sscanf(verstr, "%d.%d.%d", &maj, &min, &patch) == 3) { if (squashVersion(maj, min, patch) >= squashVersion(0, 9, 15)) { @@ -275,7 +275,7 @@ static const char *getAppName(void) static void WaitForPulseOperation(pa_operation *o) { /* This checks for NO errors currently. Either fix that, check results elsewhere, or do things you don't care about. */ - SDL_assert(pulseaudio_threaded_mainloop != NULL); + SDL_assert(pulseaudio_threaded_mainloop); if (o) { while (PULSEAUDIO_pa_operation_get_state(o) == PA_OPERATION_RUNNING) { PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop); /* this releases the lock and blocks on an internal condition variable. */ @@ -445,7 +445,7 @@ static int PULSEAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop); while (SDL_AtomicGet(&this->enabled)) { - if (h->capturebuf != NULL) { + if (h->capturebuf) { const int cpy = SDL_min(buflen, h->capturelen); SDL_memcpy(buffer, h->capturebuf, cpy); /*printf("PULSEAUDIO: fed %d captured bytes\n", cpy);*/ @@ -478,7 +478,7 @@ static int PULSEAUDIO_CaptureFromDevice(_THIS, void *buffer, int buflen) PULSEAUDIO_pa_stream_peek(h->stream, &data, &nbytes); SDL_assert(nbytes > 0); /* If data == NULL, then the buffer had a hole, ignore that */ - if (data == NULL) { + if (!data) { PULSEAUDIO_pa_stream_drop(h->stream); /* drop this fragment. */ } else { /* store this fragment's data, start feeding it to SDL. */ @@ -530,7 +530,7 @@ static void PULSEAUDIO_CloseDevice(_THIS) PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop); if (this->hidden->stream) { - if (this->hidden->capturebuf != NULL) { + if (this->hidden->capturebuf) { PULSEAUDIO_pa_stream_drop(this->hidden->stream); } PULSEAUDIO_pa_stream_disconnect(this->hidden->stream); @@ -566,7 +566,7 @@ static SDL_bool FindDeviceName(struct SDL_PrivateAudioData *h, const SDL_bool is { const uint32_t idx = ((uint32_t)((intptr_t)handle)) - 1; - if (handle == NULL) { /* NULL == default device. */ + if (!handle) { /* NULL == default device. */ return SDL_TRUE; } @@ -596,12 +596,12 @@ static int PULSEAUDIO_OpenDevice(_THIS, const char *devname) int format = PA_SAMPLE_INVALID; int retval = 0; - SDL_assert(pulseaudio_threaded_mainloop != NULL); - SDL_assert(pulseaudio_context != NULL); + SDL_assert(pulseaudio_threaded_mainloop); + SDL_assert(pulseaudio_context); /* Initialize all variables that we clean on shutdown */ h = this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -651,7 +651,7 @@ static int PULSEAUDIO_OpenDevice(_THIS, const char *devname) if (!iscapture) { h->mixlen = this->spec.size; h->mixbuf = (Uint8 *)SDL_malloc(h->mixlen); - if (h->mixbuf == NULL) { + if (!h->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(h->mixbuf, this->spec.silence, this->spec.size); @@ -686,7 +686,7 @@ static int PULSEAUDIO_OpenDevice(_THIS, const char *devname) &pacmap /* channel map */ ); - if (h->stream == NULL) { + if (!h->stream) { retval = SDL_SetError("Could not set up PulseAudio stream"); } else { int rc; @@ -694,7 +694,7 @@ static int PULSEAUDIO_OpenDevice(_THIS, const char *devname) PULSEAUDIO_pa_stream_set_state_callback(h->stream, PulseStreamStateChangeCallback, NULL); /* now that we have multi-device support, don't move a stream from a device that was unplugged to something else, unless we're default. */ - if (h->device_name != NULL) { + if (h->device_name) { flags |= PA_STREAM_DONT_MOVE; } @@ -772,8 +772,8 @@ static void SinkInfoCallback(pa_context *c, const pa_sink_info *i, int is_last, SDL_AddAudioDevice(SDL_FALSE, i->description, &spec, (void *)((intptr_t)i->index + 1)); } - if (default_sink_path != NULL && SDL_strcmp(i->name, default_sink_path) == 0) { - if (default_sink_name != NULL) { + if (default_sink_path && SDL_strcmp(i->name, default_sink_path) == 0) { + if (default_sink_name) { SDL_free(default_sink_name); } default_sink_name = SDL_strdup(i->description); @@ -803,8 +803,8 @@ static void SourceInfoCallback(pa_context *c, const pa_source_info *i, int is_la SDL_AddAudioDevice(SDL_TRUE, i->description, &spec, (void *)((intptr_t)i->index + 1)); } - if (default_source_path != NULL && SDL_strcmp(i->name, default_source_path) == 0) { - if (default_source_name != NULL) { + if (default_source_path && SDL_strcmp(i->name, default_source_path) == 0) { + if (default_source_name) { SDL_free(default_source_name); } default_source_name = SDL_strdup(i->description); @@ -909,12 +909,12 @@ static int PULSEAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int char *target; if (iscapture) { - if (default_source_name == NULL) { + if (!default_source_name) { return SDL_SetError("PulseAudio could not find a default source"); } target = default_source_name; } else { - if (default_sink_name == NULL) { + if (!default_sink_name) { return SDL_SetError("PulseAudio could not find a default sink"); } target = default_sink_name; @@ -923,7 +923,7 @@ static int PULSEAUDIO_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int numdevices = SDL_GetNumAudioDevices(iscapture); for (i = 0; i < numdevices; i += 1) { if (SDL_strcmp(SDL_GetAudioDeviceName(i, iscapture), target) == 0) { - if (name != NULL) { + if (name) { *name = SDL_strdup(target); } SDL_GetAudioDeviceSpec(i, iscapture, spec); diff --git a/src/audio/qsa/SDL_qsa_audio.c b/src/audio/qsa/SDL_qsa_audio.c index 1a80f94f047c0..893eb4ea86a94 100644 --- a/src/audio/qsa/SDL_qsa_audio.c +++ b/src/audio/qsa/SDL_qsa_audio.c @@ -232,7 +232,7 @@ static Uint8 *QSA_GetDeviceBuf(_THIS) static void QSA_CloseDevice(_THIS) { - if (this->hidden->audio_handle != NULL) { + if (this->hidden->audio_handle) { #if _NTO_VERSION < 710 if (!this->iscapture) { /* Finish playing available samples */ @@ -267,14 +267,14 @@ static int QSA_OpenDevice(_THIS, const char *devname) (sizeof (struct SDL_PrivateAudioData))); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } /* Initialize channel transfer parameters to default */ QSA_InitAudioParams(&cparams); - if (device != NULL) { + if (device) { /* Open requested audio device */ this->hidden->deviceno = device->deviceno; this->hidden->cardno = device->cardno; @@ -387,7 +387,7 @@ static int QSA_OpenDevice(_THIS, const char *devname) */ this->hidden->pcm_buf = (Uint8 *) SDL_malloc(this->hidden->pcm_len); - if (this->hidden->pcm_buf == NULL) { + if (!this->hidden->pcm_buf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->pcm_buf, this->spec.silence, diff --git a/src/audio/sndio/SDL_sndioaudio.c b/src/audio/sndio/SDL_sndioaudio.c index 0b6ab7bc3f7b8..03cc6e68ea163 100644 --- a/src/audio/sndio/SDL_sndioaudio.c +++ b/src/audio/sndio/SDL_sndioaudio.c @@ -73,7 +73,7 @@ static void *sndio_handle = NULL; static int load_sndio_sym(const char *fn, void **addr) { *addr = SDL_LoadFunction(sndio_handle, fn); - if (*addr == NULL) { + if (!*addr) { /* Don't call SDL_SetError(): SDL_LoadFunction already did. */ return 0; } @@ -122,9 +122,9 @@ static void UnloadSNDIOLibrary(void) static int LoadSNDIOLibrary(void) { int retval = 0; - if (sndio_handle == NULL) { + if (!sndio_handle) { sndio_handle = SDL_LoadObject(sndio_library); - if (sndio_handle == NULL) { + if (!sndio_handle) { retval = -1; /* Don't call SDL_SetError(): SDL_LoadObject already did. */ } else { @@ -211,10 +211,10 @@ static Uint8 *SNDIO_GetDeviceBuf(_THIS) static void SNDIO_CloseDevice(_THIS) { - if (this->hidden->pfd != NULL) { + if (this->hidden->pfd) { SDL_free(this->hidden->pfd); } - if (this->hidden->dev != NULL) { + if (this->hidden->dev) { SNDIO_sio_stop(this->hidden->dev); SNDIO_sio_close(this->hidden->dev); } @@ -230,7 +230,7 @@ static int SNDIO_OpenDevice(_THIS, const char *devname) this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -238,16 +238,16 @@ static int SNDIO_OpenDevice(_THIS, const char *devname) this->hidden->mixlen = this->spec.size; /* Capture devices must be non-blocking for SNDIO_FlushCapture */ - this->hidden->dev = SNDIO_sio_open(devname != NULL ? devname : SIO_DEVANY, + this->hidden->dev = SNDIO_sio_open(devname ? devname : SIO_DEVANY, iscapture ? SIO_REC : SIO_PLAY, iscapture); - if (this->hidden->dev == NULL) { + if (!this->hidden->dev) { return SDL_SetError("sio_open() failed"); } /* Allocate the pollfd array for capture devices */ if (iscapture) { this->hidden->pfd = SDL_malloc(sizeof(struct pollfd) * SNDIO_sio_nfds(this->hidden->dev)); - if (this->hidden->pfd == NULL) { + if (!this->hidden->pfd) { return SDL_OutOfMemory(); } } @@ -315,7 +315,7 @@ static int SNDIO_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ this->hidden->mixlen = this->spec.size; this->hidden->mixbuf = (Uint8 *)SDL_malloc(this->hidden->mixlen); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->hidden->mixlen); diff --git a/src/audio/sun/SDL_sunaudio.c b/src/audio/sun/SDL_sunaudio.c index 25deb90984e6c..2c15b479d34f5 100644 --- a/src/audio/sun/SDL_sunaudio.c +++ b/src/audio/sun/SDL_sunaudio.c @@ -194,16 +194,16 @@ static int SUNAUDIO_OpenDevice(_THIS, const char *devname) /* We don't care what the devname is...we'll try to open anything. */ /* ...but default to first name in the list... */ - if (devname == NULL) { + if (!devname) { devname = SDL_GetAudioDeviceName(0, iscapture); - if (devname == NULL) { + if (!devname) { return SDL_SetError("No such audio device"); } } /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -305,7 +305,7 @@ static int SUNAUDIO_OpenDevice(_THIS, const char *devname) (this->spec.freq / 8); this->hidden->frequency = 8; this->hidden->ulaw_buf = (Uint8 *) SDL_malloc(this->hidden->fragsize); - if (this->hidden->ulaw_buf == NULL) { + if (!this->hidden->ulaw_buf) { return SDL_OutOfMemory(); } this->spec.channels = 1; @@ -325,7 +325,7 @@ static int SUNAUDIO_OpenDevice(_THIS, const char *devname) /* Allocate mixing buffer */ this->hidden->mixbuf = (Uint8 *) SDL_malloc(this->spec.size); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); diff --git a/src/audio/vita/SDL_vitaaudio.c b/src/audio/vita/SDL_vitaaudio.c index 058896be2da8b..018cf0ab57d5c 100644 --- a/src/audio/vita/SDL_vitaaudio.c +++ b/src/audio/vita/SDL_vitaaudio.c @@ -67,7 +67,7 @@ static int VITAAUD_OpenDevice(_THIS, const char *devname) this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_memset(this->hidden, 0, sizeof(*this->hidden)); @@ -98,7 +98,7 @@ static int VITAAUD_OpenDevice(_THIS, const char *devname) 64, so spec->size should be a multiple of 64 as well. */ mixlen = this->spec.size * NUM_BUFFERS; this->hidden->rawbuf = (Uint8 *)memalign(64, mixlen); - if (this->hidden->rawbuf == NULL) { + if (!this->hidden->rawbuf) { return SDL_SetError("Couldn't allocate mixing buffer"); } @@ -162,7 +162,7 @@ static void VITAAUD_CloseDevice(_THIS) this->hidden->port = -1; } - if (!this->iscapture && this->hidden->rawbuf != NULL) { + if (!this->iscapture && this->hidden->rawbuf) { free(this->hidden->rawbuf); /* this uses memalign(), not SDL_malloc(). */ this->hidden->rawbuf = NULL; } diff --git a/src/audio/wasapi/SDL_wasapi.c b/src/audio/wasapi/SDL_wasapi.c index c465776643428..fa1e7f546b2fd 100644 --- a/src/audio/wasapi/SDL_wasapi.c +++ b/src/audio/wasapi/SDL_wasapi.c @@ -114,7 +114,7 @@ static int UpdateAudioStream(_THIS, const SDL_AudioSpec *oldspec) /* make sure our scratch buffer can cover the new device spec. */ if (this->spec.size > this->work_buffer_len) { Uint8 *ptr = (Uint8 *)SDL_realloc(this->work_buffer, this->spec.size); - if (ptr == NULL) { + if (!ptr) { return SDL_OutOfMemory(); } this->work_buffer = ptr; @@ -181,7 +181,7 @@ static Uint8 *WASAPI_GetDeviceBuf(_THIS) if (!WasapiFailed(this, IAudioRenderClient_GetBuffer(this->hidden->render, this->spec.samples, &buffer))) { return (Uint8 *)buffer; } - SDL_assert(buffer == NULL); + SDL_assert(!buffer); } return (Uint8 *)buffer; @@ -189,7 +189,7 @@ static Uint8 *WASAPI_GetDeviceBuf(_THIS) static void WASAPI_PlayDevice(_THIS) { - if (this->hidden->render != NULL) { /* definitely activated? */ + if (this->hidden->render) { /* definitely activated? */ /* WasapiFailed() will mark the device for reacquisition or removal elsewhere. */ WasapiFailed(this, IAudioRenderClient_ReleaseBuffer(this->hidden->render, this->spec.samples, 0)); } @@ -407,7 +407,7 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream) HRESULT ret = S_OK; DWORD streamflags = 0; - SDL_assert(client != NULL); + SDL_assert(client); #if defined(__WINRT__) || defined(__GDK__) /* CreateEventEx() arrived in Vista, so we need an #ifdef for XP. */ this->hidden->event = CreateEventEx(NULL, NULL, 0, EVENT_ALL_ACCESS); @@ -415,7 +415,7 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream) this->hidden->event = CreateEventW(NULL, 0, 0, NULL); #endif - if (this->hidden->event == NULL) { + if (!this->hidden->event) { return WIN_SetError("WASAPI can't create an event handle"); } @@ -424,7 +424,7 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream) return WIN_SetErrorFromHRESULT("WASAPI can't determine mix format", ret); } - SDL_assert(waveformat != NULL); + SDL_assert(waveformat); this->hidden->waveformat = waveformat; this->spec.channels = (Uint8)waveformat->nChannels; @@ -502,7 +502,7 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream) return WIN_SetErrorFromHRESULT("WASAPI can't get capture client service", ret); } - SDL_assert(capture != NULL); + SDL_assert(capture); this->hidden->capture = capture; ret = IAudioClient_Start(client); if (FAILED(ret)) { @@ -516,7 +516,7 @@ int WASAPI_PrepDevice(_THIS, const SDL_bool updatestream) return WIN_SetErrorFromHRESULT("WASAPI can't get render client service", ret); } - SDL_assert(render != NULL); + SDL_assert(render); this->hidden->render = render; ret = IAudioClient_Start(client); if (FAILED(ret)) { @@ -537,7 +537,7 @@ static int WASAPI_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); diff --git a/src/audio/wasapi/SDL_wasapi_win32.c b/src/audio/wasapi/SDL_wasapi_win32.c index 965e7ff695ceb..1b31311aa2baa 100644 --- a/src/audio/wasapi/SDL_wasapi_win32.c +++ b/src/audio/wasapi/SDL_wasapi_win32.c @@ -120,11 +120,11 @@ int WASAPI_ActivateDevice(_THIS, const SDL_bool isrecovery) IMMDevice_Release(device); if (FAILED(ret)) { - SDL_assert(this->hidden->client == NULL); + SDL_assert(!this->hidden->client); return WIN_SetErrorFromHRESULT("WASAPI can't activate audio endpoint", ret); } - SDL_assert(this->hidden->client != NULL); + SDL_assert(this->hidden->client); if (WASAPI_PrepDevice(this, isrecovery) == -1) { /* not async, fire it right away. */ return -1; } diff --git a/src/audio/wasapi/SDL_wasapi_winrt.cpp b/src/audio/wasapi/SDL_wasapi_winrt.cpp index 93ed3b834c899..aa0130012df0d 100644 --- a/src/audio/wasapi/SDL_wasapi_winrt.cpp +++ b/src/audio/wasapi/SDL_wasapi_winrt.cpp @@ -405,7 +405,7 @@ static void WASAPI_AddDevice(const SDL_bool iscapture, const char *devname, WAVE } devidlist = (DevIdList *)SDL_malloc(sizeof(*devidlist)); - if (devidlist == NULL) { + if (!devidlist) { return; /* oh well. */ } diff --git a/src/audio/winmm/SDL_winmm.c b/src/audio/winmm/SDL_winmm.c index d0c4b97689e1b..d3c5b1ba67e2b 100644 --- a/src/audio/winmm/SDL_winmm.c +++ b/src/audio/winmm/SDL_winmm.c @@ -279,7 +279,7 @@ static int WINMM_OpenDevice(_THIS, const char *devname) UINT devId = WAVE_MAPPER; /* WAVE_MAPPER == choose system's default */ UINT i; - if (handle != NULL) { /* specific device requested? */ + if (handle) { /* specific device requested? */ /* -1 because we increment the original value to avoid NULL. */ const size_t val = ((size_t) handle) - 1; devId = (UINT) val; @@ -287,7 +287,7 @@ static int WINMM_OpenDevice(_THIS, const char *devname) /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *)SDL_malloc(sizeof(*this->hidden)); - if (this->hidden == NULL) { + if (!this->hidden) { return SDL_OutOfMemory(); } SDL_zerop(this->hidden); @@ -365,14 +365,14 @@ static int WINMM_OpenDevice(_THIS, const char *devname) /* Create the audio buffer semaphore */ this->hidden->audio_sem = CreateSemaphore(NULL, iscapture ? 0 : NUM_BUFFERS - 1, NUM_BUFFERS, NULL); - if (this->hidden->audio_sem == NULL) { + if (!this->hidden->audio_sem) { return SDL_SetError("Couldn't create semaphore"); } /* Create the sound buffers */ this->hidden->mixbuf = (Uint8 *) SDL_malloc(NUM_BUFFERS * this->spec.size); - if (this->hidden->mixbuf == NULL) { + if (!this->hidden->mixbuf) { return SDL_OutOfMemory(); } diff --git a/src/core/linux/SDL_evdev_kbd.c b/src/core/linux/SDL_evdev_kbd.c index a15308f27fab0..71b3732db8f5f 100644 --- a/src/core/linux/SDL_evdev_kbd.c +++ b/src/core/linux/SDL_evdev_kbd.c @@ -385,7 +385,7 @@ static int kbd_vt_init(int console_fd) vt_release_signal = find_free_signal(kbd_vt_release_signal_action); vt_acquire_signal = find_free_signal(kbd_vt_acquire_signal_action); - if (!vt_release_signal || !vt_acquire_signal ) { + if (!vt_release_signal || !vt_acquire_signal) { kbd_vt_quit(console_fd); return -1; } @@ -499,7 +499,7 @@ void SDL_EVDEV_kbd_set_muted(SDL_EVDEV_keyboard_state *state, SDL_bool muted) void SDL_EVDEV_kbd_set_vt_switch_callbacks(SDL_EVDEV_keyboard_state *state, void (*release_callback)(void*), void *release_callback_data, void (*acquire_callback)(void*), void *acquire_callback_data) { - if (state == NULL) { + if (!state) { return; } @@ -520,7 +520,7 @@ void SDL_EVDEV_kbd_update(SDL_EVDEV_keyboard_state *state) void SDL_EVDEV_kbd_quit(SDL_EVDEV_keyboard_state *state) { - if (state == NULL) { + if (!state) { return; } diff --git a/src/core/linux/SDL_udev.c b/src/core/linux/SDL_udev.c index 302b2dfa58ffc..7eab8200cd250 100644 --- a/src/core/linux/SDL_udev.c +++ b/src/core/linux/SDL_udev.c @@ -158,7 +158,7 @@ void SDL_UDEV_Quit(void) { SDL_UDEV_CallbackList *item; - if (_this == NULL) { + if (!_this) { return; } @@ -166,17 +166,17 @@ void SDL_UDEV_Quit(void) if (_this->ref_count < 1) { - if (_this->udev_mon != NULL) { + if (_this->udev_mon) { _this->syms.udev_monitor_unref(_this->udev_mon); _this->udev_mon = NULL; } - if (_this->udev != NULL) { + if (_this->udev) { _this->syms.udev_unref(_this->udev); _this->udev = NULL; } /* Remove existing devices */ - while (_this->first != NULL) { + while (_this->first) { item = _this->first; _this->first = _this->first->next; SDL_free(item); @@ -194,12 +194,12 @@ void SDL_UDEV_Scan(void) struct udev_list_entry *devs = NULL; struct udev_list_entry *item = NULL; - if (_this == NULL) { + if (!_this) { return; } enumerate = _this->syms.udev_enumerate_new(_this->udev); - if (enumerate == NULL) { + if (!enumerate) { SDL_UDEV_Quit(); SDL_SetError("udev_enumerate_new() failed"); return; @@ -213,7 +213,7 @@ void SDL_UDEV_Scan(void) for (item = devs; item; item = _this->syms.udev_list_entry_get_next(item)) { const char *path = _this->syms.udev_list_entry_get_name(item); struct udev_device *dev = _this->syms.udev_device_new_from_syspath(_this->udev, path); - if (dev != NULL) { + if (dev) { device_event(SDL_UDEV_DEVICEADDED, dev); _this->syms.udev_device_unref(dev); } @@ -229,12 +229,12 @@ SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 struct udev_list_entry *item = NULL; SDL_bool found = SDL_FALSE; - if (_this == NULL) { + if (!_this) { return SDL_FALSE; } enumerate = _this->syms.udev_enumerate_new(_this->udev); - if (enumerate == NULL) { + if (!enumerate) { SDL_SetError("udev_enumerate_new() failed"); return SDL_FALSE; } @@ -244,7 +244,7 @@ SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 for (item = devs; item && !found; item = _this->syms.udev_list_entry_get_next(item)) { const char *path = _this->syms.udev_list_entry_get_name(item); struct udev_device *dev = _this->syms.udev_device_new_from_syspath(_this->udev, path); - if (dev != NULL) { + if (dev) { const char *val = NULL; const char *existing_path; @@ -253,17 +253,17 @@ SDL_bool SDL_UDEV_GetProductInfo(const char *device_path, Uint16 *vendor, Uint16 found = SDL_TRUE; val = _this->syms.udev_device_get_property_value(dev, "ID_VENDOR_ID"); - if (val != NULL) { + if (val) { *vendor = (Uint16)SDL_strtol(val, NULL, 16); } val = _this->syms.udev_device_get_property_value(dev, "ID_MODEL_ID"); - if (val != NULL) { + if (val) { *product = (Uint16)SDL_strtol(val, NULL, 16); } val = _this->syms.udev_device_get_property_value(dev, "ID_REVISION"); - if (val != NULL) { + if (val) { *version = (Uint16)SDL_strtol(val, NULL, 16); } } @@ -281,7 +281,7 @@ void SDL_UDEV_UnloadLibrary(void) return; } - if (_this->udev_handle != NULL) { + if (_this->udev_handle) { SDL_UnloadObject(_this->udev_handle); _this->udev_handle = NULL; } @@ -441,14 +441,14 @@ static void device_event(SDL_UDEV_deviceevent type, struct udev_device *dev) Ref: http://cgit.freedesktop.org/systemd/systemd/tree/src/udev/udev-builtin-input_id.c#n183 */ val = _this->syms.udev_device_get_property_value(dev, "ID_INPUT_KEY"); - if (val != NULL && SDL_strcmp(val, "1") == 0) { + if (val && SDL_strcmp(val, "1") == 0) { devclass |= SDL_UDEV_DEVICE_KEYBOARD; } if (devclass == 0) { /* Fall back to old style input classes */ val = _this->syms.udev_device_get_property_value(dev, "ID_CLASS"); - if (val != NULL) { + if (val) { if (SDL_strcmp(val, "joystick") == 0) { devclass = SDL_UDEV_DEVICE_JOYSTICK; } else if (SDL_strcmp(val, "mouse") == 0) { diff --git a/src/core/openbsd/SDL_wscons_kbd.c b/src/core/openbsd/SDL_wscons_kbd.c index f6253ed1f59b1..99d63a9f2925a 100644 --- a/src/core/openbsd/SDL_wscons_kbd.c +++ b/src/core/openbsd/SDL_wscons_kbd.c @@ -433,7 +433,7 @@ static SDL_WSCONS_input_data *SDL_WSCONS_Init_Keyboard(const char *dev) return NULL; } input->keymap.map = SDL_calloc(sizeof(struct wscons_keymap), KS_NUMKEYCODES); - if (input->keymap.map == NULL) { + if (!input->keymap.map) { free(input); return NULL; } diff --git a/src/core/os2/geniconv/os2cp.c b/src/core/os2/geniconv/os2cp.c index ae8bec7b4b191..2d44860ffd248 100644 --- a/src/core/os2/geniconv/os2cp.c +++ b/src/core/os2/geniconv/os2cp.c @@ -357,7 +357,7 @@ unsigned long os2cpFromName(char *cp) PCHAR pcEnd; CHAR acBuf[64]; - if (cp == NULL) { + if (!cp) { ULONG aulCP[3]; ULONG cCP; return (DosQueryCp(sizeof(aulCP), aulCP, &cCP) != NO_ERROR)? 0 : aulCP[0]; @@ -368,7 +368,7 @@ unsigned long os2cpFromName(char *cp) } pcEnd = SDL_strchr(cp, ' '); - if (pcEnd == NULL) { + if (!pcEnd) { pcEnd = SDL_strchr(cp, '\0'); } ulNext = pcEnd - cp; diff --git a/src/core/os2/geniconv/os2iconv.c b/src/core/os2/geniconv/os2iconv.c index 0e75484cfb0ea..2e7d97a04043b 100644 --- a/src/core/os2/geniconv/os2iconv.c +++ b/src/core/os2/geniconv/os2iconv.c @@ -76,7 +76,7 @@ static int _createUconvObj(const char *code, UconvObject *uobj) const unsigned char *ch = (const unsigned char *)code; - if (code == NULL) + if (!code) uc_code[0] = 0; else { for (i = 0; i < MAX_CP_NAME_LEN; i++) { @@ -119,10 +119,10 @@ iconv_t _System os2_iconv_open(const char* tocode, const char* fromcode) int rc; iuconv_obj *iuobj; - if (tocode == NULL) { + if (!tocode) { tocode = ""; } - if (fromcode == NULL) { + if (!fromcode) { fromcode = ""; } @@ -169,7 +169,7 @@ size_t _System os2_iconv(iconv_t cd, int rc; size_t ret = (size_t)(-1); - if (uo_tocode == NULL && uo_fromcode == NULL) { + if (!uo_tocode && !uo_fromcode) { uc_buf_len = SDL_min(*inbytesleft, *outbytesleft); SDL_memcpy(*outbuf, *inbuf, uc_buf_len); *inbytesleft -= uc_buf_len; diff --git a/src/core/os2/geniconv/sys2utf8.c b/src/core/os2/geniconv/sys2utf8.c index 1c8be8a17903d..1c3305c7932cc 100644 --- a/src/core/os2/geniconv/sys2utf8.c +++ b/src/core/os2/geniconv/sys2utf8.c @@ -95,7 +95,7 @@ char *StrUTF8New(int to_utf8, char *str, int c_str) int c_newstr = (((c_str > 4) ? c_str : 4) + 1) * 2; char * newstr = (char *) SDL_malloc(c_newstr); - if (newstr == NULL) { + if (!newstr) { return NULL; } diff --git a/src/core/windows/SDL_immdevice.c b/src/core/windows/SDL_immdevice.c index d2900f9ccff7b..93ca729ab0cf2 100644 --- a/src/core/windows/SDL_immdevice.c +++ b/src/core/windows/SDL_immdevice.c @@ -136,7 +136,7 @@ static void SDL_IMMDevice_Add(const SDL_bool iscapture, const char *devname, WAV } devidlist = (DevIdList *)SDL_malloc(sizeof(*devidlist)); - if (devidlist == NULL) { + if (!devidlist) { return; /* oh well. */ } @@ -361,10 +361,10 @@ int SDL_IMMDevice_Get(LPCWSTR devid, IMMDevice **device, SDL_bool iscapture) const Uint64 timeout = SDL_GetTicks64() + 8000; /* intel's audio drivers can fail for up to EIGHT SECONDS after a device is connected or we wake from sleep. */ HRESULT ret; - SDL_assert(device != NULL); + SDL_assert(device); while (SDL_TRUE) { - if (devid == NULL) { + if (!devid) { const EDataFlow dataflow = iscapture ? eCapture : eRender; ret = IMMDeviceEnumerator_GetDefaultAudioEndpoint(enumerator, dataflow, SDL_IMMDevice_role, device); } else { @@ -443,7 +443,7 @@ static void EnumerateEndpointsForFlow(const SDL_bool iscapture) } items = (EndpointItem *)SDL_calloc(total, sizeof(EndpointItem)); - if (items == NULL) { + if (!items) { return; /* oh well. */ } @@ -496,11 +496,11 @@ int SDL_IMMDevice_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int isca HRESULT ret = IMMDeviceEnumerator_GetDefaultAudioEndpoint(enumerator, dataflow, SDL_IMMDevice_role, &device); if (FAILED(ret)) { - SDL_assert(device == NULL); + SDL_assert(!device); return WIN_SetErrorFromHRESULT("WASAPI can't find default audio endpoint", ret); } - if (name == NULL) { + if (!name) { name = &filler; } diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index 337ae335afb0b..bdc6b3e0b6157 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -1198,7 +1198,7 @@ void *SDL_SIMDRealloc(void *mem, const size_t len) ptr = (Uint8 *)SDL_realloc(mem, to_allocate); - if (ptr == NULL) { + if (!ptr) { return NULL; /* Out of memory, bail! */ } diff --git a/src/events/SDL_displayevents.c b/src/events/SDL_displayevents.c index ec5e158bb734f..d4dc2c2b213e1 100644 --- a/src/events/SDL_displayevents.c +++ b/src/events/SDL_displayevents.c @@ -29,7 +29,7 @@ int SDL_SendDisplayEvent(SDL_VideoDisplay *display, Uint8 displayevent, int data { int posted; - if (display == NULL) { + if (!display) { return 0; } switch (displayevent) { diff --git a/src/events/SDL_gesture.c b/src/events/SDL_gesture.c index cc18f84ed1af0..960a12ffa6c1c 100644 --- a/src/events/SDL_gesture.c +++ b/src/events/SDL_gesture.c @@ -129,7 +129,7 @@ static unsigned long SDL_HashDollar(SDL_FloatPoint *points) static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops *dst) { - if (dst == NULL) { + if (!dst) { return 0; } @@ -200,7 +200,7 @@ static int SDL_AddDollarGesture_one(SDL_GestureTouch *inTouch, SDL_FloatPoint *p (SDL_DollarTemplate *)SDL_realloc(inTouch->dollarTemplate, (index + 1) * sizeof(SDL_DollarTemplate)); - if (dollarTemplate == NULL) { + if (!dollarTemplate) { return SDL_OutOfMemory(); } inTouch->dollarTemplate = dollarTemplate; @@ -217,7 +217,7 @@ static int SDL_AddDollarGesture(SDL_GestureTouch *inTouch, SDL_FloatPoint *path) { int index = -1; int i = 0; - if (inTouch == NULL) { + if (!inTouch) { if (SDL_numGestureTouches == 0) { return SDL_SetError("no gesture touch devices registered"); } @@ -238,7 +238,7 @@ int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) { int i, loaded = 0; SDL_GestureTouch *touch = NULL; - if (src == NULL) { + if (!src) { return 0; } if (touchId >= 0) { @@ -247,7 +247,7 @@ int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) touch = &SDL_gestureTouch[i]; } } - if (touch == NULL) { + if (!touch) { return SDL_SetError("given touch id not found"); } } @@ -475,7 +475,7 @@ int SDL_GestureAddTouch(SDL_TouchID touchId) (SDL_numGestureTouches + 1) * sizeof(SDL_GestureTouch)); - if (gestureTouch == NULL) { + if (!gestureTouch) { return SDL_OutOfMemory(); } @@ -589,7 +589,7 @@ void SDL_GestureProcessEvent(SDL_Event *event) SDL_GestureTouch *inTouch = SDL_GetGestureTouch(event->tfinger.touchId); /* Shouldn't be possible */ - if (inTouch == NULL) { + if (!inTouch) { return; } diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index 80e58e682b3b4..1821cc0293383 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -1284,7 +1284,7 @@ SDL_Cursor *SDL_CreateCursor(const Uint8 *data, const Uint8 *mask, 0x0000FF00, 0x000000FF, 0xFF000000); - if (surface == NULL) { + if (!surface) { return NULL; } for (y = 0; y < h; ++y) { @@ -1331,7 +1331,7 @@ SDL_Cursor *SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y) if (surface->format->format != SDL_PIXELFORMAT_ARGB8888) { temp = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888, 0); - if (temp == NULL) { + if (!temp) { return NULL; } surface = temp; @@ -1398,7 +1398,7 @@ void SDL_SetCursor(SDL_Cursor *cursor) break; } } - if (found == NULL) { + if (!found) { SDL_SetError("Cursor not associated with the current mouse"); return; } @@ -1483,7 +1483,7 @@ int SDL_ShowCursor(int toggle) SDL_Mouse *mouse = SDL_GetMouse(); SDL_bool shown; - if (mouse == NULL) { + if (!mouse) { return 0; } diff --git a/src/events/SDL_touch.c b/src/events/SDL_touch.c index 1ce4b4d47e532..c8f8dc110ae99 100644 --- a/src/events/SDL_touch.c +++ b/src/events/SDL_touch.c @@ -413,7 +413,7 @@ int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, SDL_Window *windo } finger = SDL_GetFinger(touch, fingerid); - if (finger == NULL) { + if (!finger) { return SDL_SendTouch(id, fingerid, window, SDL_TRUE, x, y, pressure); } diff --git a/src/file/SDL_rwops.c b/src/file/SDL_rwops.c index 0b051a677bde8..ac345a93d897e 100644 --- a/src/file/SDL_rwops.c +++ b/src/file/SDL_rwops.c @@ -86,7 +86,7 @@ static int SDLCALL windows_file_open(SDL_RWops *context, const char *filename, c DWORD must_exist, truncate; int a_mode; - if (context == NULL) { + if (!context) { return -1; /* failed (invalid call) */ } @@ -154,7 +154,7 @@ static Sint64 SDLCALL windows_file_size(SDL_RWops *context) { LARGE_INTEGER size; - if (context == NULL || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) { + if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) { return SDL_SetError("windows_file_size: invalid context/file not opened"); } @@ -170,7 +170,7 @@ static Sint64 SDLCALL windows_file_seek(SDL_RWops *context, Sint64 offset, int w DWORD windowswhence; LARGE_INTEGER windowsoffset; - if (context == NULL || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) { + if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) { return SDL_SetError("windows_file_seek: invalid context/file not opened"); } @@ -211,7 +211,7 @@ windows_file_read(SDL_RWops *context, void *ptr, size_t size, size_t maxnum) total_need = size * maxnum; - if (context == NULL || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !total_need) { + if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !total_need) { return 0; } @@ -264,7 +264,7 @@ windows_file_write(SDL_RWops *context, const void *ptr, size_t size, total_bytes = size * num; - if (context == NULL || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !size || !total_bytes) { + if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !size || !total_bytes) { return 0; } @@ -559,7 +559,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode) /* Try to open the file from the asset system */ rwops = SDL_AllocRW(); - if (rwops == NULL) { + if (!rwops) { return NULL; /* SDL_SetError already setup by SDL_AllocRW() */ } @@ -576,7 +576,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode) #elif defined(__WIN32__) || defined(__GDK__) rwops = SDL_AllocRW(); - if (rwops == NULL) { + if (!rwops) { return NULL; /* SDL_SetError already setup by SDL_AllocRW() */ } @@ -621,7 +621,7 @@ SDL_RWops *SDL_RWFromFP(FILE * fp, SDL_bool autoclose) SDL_RWops *rwops = NULL; rwops = SDL_AllocRW(); - if (rwops != NULL) { + if (rwops) { rwops->size = stdio_size; rwops->seek = stdio_seek; rwops->read = stdio_read; @@ -644,7 +644,7 @@ SDL_RWops *SDL_RWFromFP(void * fp, SDL_bool autoclose) SDL_RWops *SDL_RWFromMem(void *mem, int size) { SDL_RWops *rwops = NULL; - if (mem == NULL) { + if (!mem) { SDL_InvalidParamError("mem"); return rwops; } @@ -654,7 +654,7 @@ SDL_RWops *SDL_RWFromMem(void *mem, int size) } rwops = SDL_AllocRW(); - if (rwops != NULL) { + if (rwops) { rwops->size = mem_size; rwops->seek = mem_seek; rwops->read = mem_read; @@ -671,7 +671,7 @@ SDL_RWops *SDL_RWFromMem(void *mem, int size) SDL_RWops *SDL_RWFromConstMem(const void *mem, int size) { SDL_RWops *rwops = NULL; - if (mem == NULL) { + if (!mem) { SDL_InvalidParamError("mem"); return rwops; } @@ -681,7 +681,7 @@ SDL_RWops *SDL_RWFromConstMem(const void *mem, int size) } rwops = SDL_AllocRW(); - if (rwops != NULL) { + if (rwops) { rwops->size = mem_size; rwops->seek = mem_seek; rwops->read = mem_read; @@ -700,7 +700,7 @@ SDL_RWops *SDL_AllocRW(void) SDL_RWops *area; area = (SDL_RWops *)SDL_malloc(sizeof(*area)); - if (area == NULL) { + if (!area) { SDL_OutOfMemory(); } else { area->type = SDL_RWOPS_UNKNOWN; @@ -737,7 +737,7 @@ void *SDL_LoadFile_RW(SDL_RWops *src, size_t *datasize, int freesrc) if ((((Sint64)size_total) + FILE_CHUNK_SIZE) > size) { size = (size_total + FILE_CHUNK_SIZE); newdata = SDL_realloc(data, (size_t)(size + 1)); - if (newdata == NULL) { + if (!newdata) { SDL_free(data); data = NULL; SDL_OutOfMemory(); diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c index 035176b37f953..0ba336bda4388 100644 --- a/src/joystick/SDL_gamecontroller.c +++ b/src/joystick/SDL_gamecontroller.c @@ -177,7 +177,7 @@ static void SDL_LoadVIDPIDListFromHint(const char *hint, SDL_vidpid_list *list) spot = (char *)hint; } - if (spot == NULL) { + if (!spot) { return; } @@ -185,7 +185,7 @@ static 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); @@ -193,7 +193,7 @@ static 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; } @@ -273,7 +273,7 @@ static void HandleJoystickAxis(SDL_GameController *gamecontroller, int axis, int } } - 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(gamecontroller, last_match); } @@ -1105,7 +1105,7 @@ static void SDL_PrivateLoadButtonMapping(SDL_GameController *gamecontroller, Con gamecontroller->name = pControllerMapping->name; gamecontroller->num_bindings = 0; gamecontroller->mapping = pControllerMapping; - if (gamecontroller->joystick->naxes != 0 && gamecontroller->last_match_axis != NULL) { + if (gamecontroller->joystick->naxes != 0 && gamecontroller->last_match_axis) { SDL_memset(gamecontroller->last_match_axis, 0, gamecontroller->joystick->naxes * sizeof(*gamecontroller->last_match_axis)); } @@ -1134,7 +1134,7 @@ static char *SDL_PrivateGetControllerGUIDFromMappingString(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; } @@ -1173,17 +1173,17 @@ static char *SDL_PrivateGetControllerNameFromMappingString(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; } @@ -1200,12 +1200,12 @@ static char *SDL_PrivateGetControllerMappingFromMappingString(const char *pMappi const char *pFirstComma, *pSecondComma; pFirstComma = SDL_strchr(pMapping, ','); - if (pFirstComma == NULL) { + if (!pFirstComma) { return NULL; } pSecondComma = SDL_strchr(pFirstComma + 1, ','); - if (pSecondComma == NULL) { + if (!pSecondComma) { return NULL; } @@ -1248,13 +1248,13 @@ static ControllerMapping_t *SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, SDL_AssertJoysticksLocked(); pchName = SDL_PrivateGetControllerNameFromMappingString(mappingString); - if (pchName == NULL) { + if (!pchName) { SDL_SetError("Couldn't parse name from %s", mappingString); return NULL; } pchMapping = SDL_PrivateGetControllerMappingFromMappingString(mappingString); - if (pchMapping == NULL) { + if (!pchMapping) { SDL_free(pchName); SDL_SetError("Couldn't parse %s", mappingString); return NULL; @@ -1311,7 +1311,7 @@ static ControllerMapping_t *SDL_PrivateAddMappingForGUID(SDL_JoystickGUID jGUID, *existing = SDL_TRUE; } else { pControllerMapping = SDL_malloc(sizeof(*pControllerMapping)); - if (pControllerMapping == NULL) { + if (!pControllerMapping) { SDL_free(pchName); SDL_free(pchMapping); SDL_OutOfMemory(); @@ -1356,7 +1356,7 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForNameAndGUID(const mapping = SDL_PrivateGetControllerMappingForGUID(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; @@ -1367,7 +1367,7 @@ static ControllerMapping_t *SDL_PrivateGetControllerMappingForNameAndGUID(const } #endif /* __LINUX__ */ - if (mapping == NULL) { + if (!mapping) { mapping = s_pDefaultMapping; } return mapping; @@ -1468,7 +1468,7 @@ static ControllerMapping_t *SDL_PrivateGetControllerMapping(int device_index) name = SDL_JoystickNameForIndex(device_index); guid = SDL_JoystickGetDeviceGUID(device_index); mapping = SDL_PrivateGetControllerMappingForNameAndGUID(name, guid); - if (mapping == NULL) { + if (!mapping) { SDL_GamepadMapping raw_map; SDL_zero(raw_map); @@ -1490,13 +1490,13 @@ int SDL_GameControllerAddMappingsFromRW(SDL_RWops *rw, int freerw) char *buf, *line, *line_end, *tmp, *comma, line_platform[64]; size_t db_size, platform_len; - if (rw == NULL) { + if (!rw) { return SDL_SetError("Invalid RWops"); } db_size = (size_t)SDL_RWsize(rw); buf = (char *)SDL_malloc(db_size + 1); - if (buf == NULL) { + if (!buf) { if (freerw) { SDL_RWclose(rw); } @@ -1520,7 +1520,7 @@ int SDL_GameControllerAddMappingsFromRW(SDL_RWops *rw, int freerw) 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; @@ -1528,10 +1528,10 @@ int SDL_GameControllerAddMappingsFromRW(SDL_RWops *rw, int freerw) /* Extract and verify the platform */ tmp = SDL_strstr(line, SDL_CONTROLLER_PLATFORM_FIELD); - if (tmp != NULL) { + if (tmp) { tmp += SDL_CONTROLLER_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); @@ -1564,7 +1564,7 @@ static int SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_Co SDL_AssertJoysticksLocked(); - if (mappingString == NULL) { + if (!mappingString) { return SDL_InvalidParamError("mappingString"); } @@ -1572,7 +1572,7 @@ static int SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_Co const char *tmp; tmp = SDL_strstr(mappingString, SDL_CONTROLLER_HINT_FIELD); - if (tmp != NULL) { + if (tmp) { SDL_bool default_value, value, negate; int len; char hint[128]; @@ -1614,14 +1614,14 @@ static int SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_Co const char *tmp; tmp = SDL_strstr(mappingString, SDL_CONTROLLER_SDKGE_FIELD); - if (tmp != NULL) { + if (tmp) { tmp += SDL_CONTROLLER_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_CONTROLLER_SDKLE_FIELD); - if (tmp != NULL) { + if (tmp) { tmp += SDL_CONTROLLER_SDKLE_FIELD_SIZE; if (!(SDL_GetAndroidSDKVersion() <= SDL_atoi(tmp))) { return SDL_SetError("SDK version %d > maximum version %d", SDL_GetAndroidSDKVersion(), SDL_atoi(tmp)); @@ -1631,7 +1631,7 @@ static int SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_Co #endif pchGUID = SDL_PrivateGetControllerGUIDFromMappingString(mappingString); - if (pchGUID == NULL) { + if (!pchGUID) { return SDL_SetError("Couldn't parse GUID from %s", mappingString); } if (!SDL_strcasecmp(pchGUID, "default")) { @@ -1643,7 +1643,7 @@ static int SDL_PrivateGameControllerAddMapping(const char *mappingString, SDL_Co SDL_free(pchGUID); pControllerMapping = SDL_PrivateAddMappingForGUID(jGUID, mappingString, &existing, priority); - if (pControllerMapping == NULL) { + if (!pControllerMapping) { return -1; } @@ -1724,7 +1724,7 @@ static char *CreateMappingString(ControllerMapping_t *mapping, SDL_JoystickGUID } pMappingString = SDL_malloc(needed); - if (pMappingString == NULL) { + if (!pMappingString) { SDL_OutOfMemory(); return NULL; } @@ -1774,7 +1774,7 @@ char *SDL_GameControllerMappingForIndex(int mapping_index) } SDL_UnlockJoysticks(); - if (retval == NULL) { + if (!retval) { SDL_SetError("Mapping not available"); } return retval; @@ -1932,7 +1932,7 @@ const char *SDL_GameControllerNameForIndex(int joystick_index) SDL_LockJoysticks(); { ControllerMapping_t *mapping = SDL_PrivateGetControllerMapping(joystick_index); - if (mapping != NULL) { + if (mapping) { if (SDL_strcmp(mapping->name, "*") == 0) { retval = SDL_JoystickNameForIndex(joystick_index); } else { @@ -1955,7 +1955,7 @@ const char *SDL_GameControllerPathForIndex(int joystick_index) SDL_LockJoysticks(); { ControllerMapping_t *mapping = SDL_PrivateGetControllerMapping(joystick_index); - if (mapping != NULL) { + if (mapping) { retval = SDL_JoystickPathForIndex(joystick_index); } } @@ -1984,7 +1984,7 @@ char *SDL_GameControllerMappingForDeviceIndex(int joystick_index) SDL_LockJoysticks(); { ControllerMapping_t *mapping = SDL_PrivateGetControllerMapping(joystick_index); - if (mapping != NULL) { + if (mapping) { SDL_JoystickGUID guid; char pchGUID[33]; size_t needed; @@ -1993,7 +1993,7 @@ char *SDL_GameControllerMappingForDeviceIndex(int joystick_index) /* 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(); @@ -2155,7 +2155,7 @@ SDL_GameController *SDL_GameControllerOpen(int joystick_index) gamecontrollerlist = SDL_gamecontrollers; /* If the controller is already open, return it */ instance_id = SDL_JoystickGetDeviceInstanceID(joystick_index); - while (gamecontrollerlist != NULL) { + while (gamecontrollerlist) { if (instance_id == gamecontrollerlist->joystick->instance_id) { gamecontroller = gamecontrollerlist; ++gamecontroller->ref_count; @@ -2167,7 +2167,7 @@ SDL_GameController *SDL_GameControllerOpen(int joystick_index) /* Find a controller mapping */ pSupportedController = SDL_PrivateGetControllerMapping(joystick_index); - if (pSupportedController == NULL) { + if (!pSupportedController) { SDL_SetError("Couldn't find mapping for device (%d)", joystick_index); SDL_UnlockJoysticks(); return NULL; @@ -2175,7 +2175,7 @@ SDL_GameController *SDL_GameControllerOpen(int joystick_index) /* Create and initialize the controller */ gamecontroller = (SDL_GameController *)SDL_calloc(1, sizeof(*gamecontroller)); - if (gamecontroller == NULL) { + if (!gamecontroller) { SDL_OutOfMemory(); SDL_UnlockJoysticks(); return NULL; @@ -2183,7 +2183,7 @@ SDL_GameController *SDL_GameControllerOpen(int joystick_index) gamecontroller->magic = &gamecontroller_magic; gamecontroller->joystick = SDL_JoystickOpen(joystick_index); - if (gamecontroller->joystick == NULL) { + if (!gamecontroller->joystick) { SDL_free(gamecontroller); SDL_UnlockJoysticks(); return NULL; @@ -2655,7 +2655,7 @@ const char *SDL_GameControllerPath(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return NULL; } return SDL_JoystickPath(joystick); @@ -2665,7 +2665,7 @@ SDL_GameControllerType SDL_GameControllerGetType(SDL_GameController *gamecontrol { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return SDL_CONTROLLER_TYPE_UNKNOWN; } return SDL_GetJoystickGameControllerTypeFromGUID(SDL_JoystickGetGUID(joystick), SDL_JoystickName(joystick)); @@ -2675,7 +2675,7 @@ int SDL_GameControllerGetPlayerIndex(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return -1; } return SDL_JoystickGetPlayerIndex(joystick); @@ -2688,7 +2688,7 @@ void SDL_GameControllerSetPlayerIndex(SDL_GameController *gamecontroller, int pl { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return; } SDL_JoystickSetPlayerIndex(joystick, player_index); @@ -2698,7 +2698,7 @@ Uint16 SDL_GameControllerGetVendor(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return 0; } return SDL_JoystickGetVendor(joystick); @@ -2708,7 +2708,7 @@ Uint16 SDL_GameControllerGetProduct(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return 0; } return SDL_JoystickGetProduct(joystick); @@ -2718,7 +2718,7 @@ Uint16 SDL_GameControllerGetProductVersion(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return 0; } return SDL_JoystickGetProductVersion(joystick); @@ -2728,7 +2728,7 @@ Uint16 SDL_GameControllerGetFirmwareVersion(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return 0; } return SDL_JoystickGetFirmwareVersion(joystick); @@ -2738,7 +2738,7 @@ const char * SDL_GameControllerGetSerial(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return NULL; } return SDL_JoystickGetSerial(joystick); @@ -2752,7 +2752,7 @@ SDL_bool SDL_GameControllerGetAttached(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return SDL_FALSE; } return SDL_JoystickGetAttached(joystick); @@ -2894,7 +2894,7 @@ int SDL_GameControllerRumble(SDL_GameController *gamecontroller, Uint16 low_freq { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return -1; } return SDL_JoystickRumble(joystick, low_frequency_rumble, high_frequency_rumble, duration_ms); @@ -2904,7 +2904,7 @@ int SDL_GameControllerRumbleTriggers(SDL_GameController *gamecontroller, Uint16 { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return -1; } return SDL_JoystickRumbleTriggers(joystick, left_rumble, right_rumble, duration_ms); @@ -2914,7 +2914,7 @@ SDL_bool SDL_GameControllerHasLED(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return SDL_FALSE; } return SDL_JoystickHasLED(joystick); @@ -2924,7 +2924,7 @@ SDL_bool SDL_GameControllerHasRumble(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return SDL_FALSE; } return SDL_JoystickHasRumble(joystick); @@ -2934,7 +2934,7 @@ SDL_bool SDL_GameControllerHasRumbleTriggers(SDL_GameController *gamecontroller) { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return SDL_FALSE; } return SDL_JoystickHasRumbleTriggers(joystick); @@ -2944,7 +2944,7 @@ int SDL_GameControllerSetLED(SDL_GameController *gamecontroller, Uint8 red, Uint { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return -1; } return SDL_JoystickSetLED(joystick, red, green, blue); @@ -2954,7 +2954,7 @@ int SDL_GameControllerSendEffect(SDL_GameController *gamecontroller, const void { SDL_Joystick *joystick = SDL_GameControllerGetJoystick(gamecontroller); - if (joystick == NULL) { + if (!joystick) { return -1; } return SDL_JoystickSendEffect(joystick, data, size); @@ -2966,7 +2966,7 @@ void SDL_GameControllerClose(SDL_GameController *gamecontroller) SDL_LockJoysticks(); - if (gamecontroller == NULL || gamecontroller->magic != &gamecontroller_magic) { + if (!gamecontroller || gamecontroller->magic != &gamecontroller_magic) { SDL_UnlockJoysticks(); return; } diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index e8a0a6ac243f4..3d4488b65ca88 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -1474,7 +1474,7 @@ static void UpdateEventsForDeviceRemoval(int device_index, Uint32 type) } events = SDL_small_alloc(SDL_Event, num_events, &isstack); - if (events == NULL) { + if (!events) { return; } diff --git a/src/joystick/android/SDL_sysjoystick.c b/src/joystick/android/SDL_sysjoystick.c index bbfaf971e488d..96488f36b6ad2 100644 --- a/src/joystick/android/SDL_sysjoystick.c +++ b/src/joystick/android/SDL_sysjoystick.c @@ -381,7 +381,7 @@ int Android_AddJoystick(int device_id, const char *name, const char *desc, int v item->nhats = nhats; item->nballs = nballs; item->device_instance = SDL_GetNextJoystickInstanceID(); - if (SDL_joylist_tail == NULL) { + if (!SDL_joylist_tail) { SDL_joylist = SDL_joylist_tail = item; } else { SDL_joylist_tail->next = item; diff --git a/src/joystick/bsd/SDL_bsdjoystick.c b/src/joystick/bsd/SDL_bsdjoystick.c index 030d843ebdebf..d380f68f27d0e 100644 --- a/src/joystick/bsd/SDL_bsdjoystick.c +++ b/src/joystick/bsd/SDL_bsdjoystick.c @@ -491,13 +491,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_GetNextJoystickInstanceID(); - if (SDL_joylist_tail == NULL) { + if (!SDL_joylist_tail) { SDL_joylist = SDL_joylist_tail = item; } else { SDL_joylist_tail->next = item; diff --git a/src/joystick/hidapi/SDL_hidapi_gamecube.c b/src/joystick/hidapi/SDL_hidapi_gamecube.c index 4261a299c2fa8..228ec78f5973f 100644 --- a/src/joystick/hidapi/SDL_hidapi_gamecube.c +++ b/src/joystick/hidapi/SDL_hidapi_gamecube.c @@ -249,7 +249,7 @@ static void HIDAPI_DriverGameCube_HandleJoystickPacket(SDL_HIDAPI_Device *device } joystick = SDL_JoystickFromInstanceID(ctx->joysticks[i]); - if (joystick == NULL) { + if (!joystick) { /* Hasn't been opened yet, skip */ return; } diff --git a/src/joystick/hidapi/SDL_hidapi_xboxone.c b/src/joystick/hidapi/SDL_hidapi_xboxone.c index 1a6a179f241a8..869726396a277 100644 --- a/src/joystick/hidapi/SDL_hidapi_xboxone.c +++ b/src/joystick/hidapi/SDL_hidapi_xboxone.c @@ -1225,7 +1225,7 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) break; case 0x03: /* Controller status update */ - if (joystick == NULL) { + if (!joystick) { /* We actually want to handle this packet any time it arrives */ /*break;*/ } @@ -1238,13 +1238,13 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) /* Unknown chatty controller information, sent by both sides */ break; case 0x07: - if (joystick == NULL) { + if (!joystick) { break; } HIDAPI_DriverXboxOne_HandleModePacket(joystick, ctx, data, size); break; case 0x0C: - if (joystick == NULL) { + if (!joystick) { break; } HIDAPI_DriverXboxOne_HandleUnmappedStatePacket(joystick, ctx, data, size); @@ -1259,7 +1259,7 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) The controller sends that in response to this request: 0x1E 0x30 0x07 0x01 0x04 */ - if (joystick == NULL) { + if (!joystick) { break; } #ifdef SET_SERIAL_AFTER_OPEN @@ -1278,7 +1278,7 @@ static SDL_bool HIDAPI_DriverXboxOne_UpdateDevice(SDL_HIDAPI_Device *device) #endif break; } - if (joystick == NULL) { + if (!joystick) { break; } HIDAPI_DriverXboxOne_HandleStatePacket(joystick, ctx, data, size); diff --git a/src/joystick/linux/SDL_sysjoystick.c b/src/joystick/linux/SDL_sysjoystick.c index 745ea5ceea99a..b849dfed2020e 100644 --- a/src/joystick/linux/SDL_sysjoystick.c +++ b/src/joystick/linux/SDL_sysjoystick.c @@ -436,13 +436,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_GetNextJoystickInstanceID(); - if (SDL_joylist_tail == NULL) { + if (!SDL_joylist_tail) { SDL_joylist = SDL_joylist_tail = item; } else { SDL_joylist_tail->next = item; @@ -617,14 +617,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_GetNextJoystickInstanceID(); SDL_LockJoysticks(); - if (SDL_joylist_tail == NULL) { + if (!SDL_joylist_tail) { SDL_joylist = SDL_joylist_tail = item; } else { SDL_joylist_tail->next = item; @@ -1063,7 +1063,7 @@ static int allocate_balldata(SDL_Joystick *joystick) joystick->hwdata->balls = (struct hwdata_ball *)SDL_malloc(joystick->nballs * sizeof(struct hwdata_ball)); - if (joystick->hwdata->balls == NULL) { + if (!joystick->hwdata->balls) { return -1; } for (i = 0; i < joystick->nballs; ++i) { @@ -1486,14 +1486,14 @@ static int LINUX_JoystickOpen(SDL_Joystick *joystick, int device_index) SDL_AssertJoysticksLocked(); item = JoystickByDevIndex(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(); } diff --git a/src/joystick/os2/SDL_os2joystick.c b/src/joystick/os2/SDL_os2joystick.c index b7e0376b3355c..49cb67d018f38 100644 --- a/src/joystick/os2/SDL_os2joystick.c +++ b/src/joystick/os2/SDL_os2joystick.c @@ -731,7 +731,7 @@ static int joyGetEnv(struct _joycfg * joydata) char tempnumber[5]; /* Temporary place to put numeric texts */ joyenv = SDL_getenv("SDL_OS2_JOYSTICK"); - if (joyenv == NULL) { + if (!joyenv) { return 0; } diff --git a/src/joystick/virtual/SDL_virtualjoystick.c b/src/joystick/virtual/SDL_virtualjoystick.c index 415327b8211ac..8706bb3d3aca9 100644 --- a/src/joystick/virtual/SDL_virtualjoystick.c +++ b/src/joystick/virtual/SDL_virtualjoystick.c @@ -248,7 +248,7 @@ int SDL_JoystickDetachVirtualInner(int device_index) { SDL_JoystickID instance_id; joystick_hwdata *hwdata = VIRTUAL_HWDataForIndex(device_index); - if (hwdata == NULL) { + if (!hwdata) { return SDL_SetError("Virtual joystick data not found"); } instance_id = hwdata->instance_id; @@ -390,7 +390,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 -1; } return hwdata->instance_id; diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c index 694b8ec2d0400..03bcdb78af478 100644 --- a/src/joystick/windows/SDL_rawinputjoystick.c +++ b/src/joystick/windows/SDL_rawinputjoystick.c @@ -619,7 +619,7 @@ static void RAWINPUT_UpdateWindowsGamingInput() return; } gamepad_state = SDL_calloc(1, sizeof(*gamepad_state)); - if (gamepad_state == NULL) { + if (!gamepad_state) { SDL_OutOfMemory(); return; } diff --git a/src/joystick/windows/SDL_windowsjoystick.c b/src/joystick/windows/SDL_windowsjoystick.c index 9ba1bccfe4d7d..f49bc61acfd3b 100644 --- a/src/joystick/windows/SDL_windowsjoystick.c +++ b/src/joystick/windows/SDL_windowsjoystick.c @@ -410,18 +410,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_CreateCond(); - 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; diff --git a/src/loadso/os2/SDL_sysloadso.c b/src/loadso/os2/SDL_sysloadso.c index c5c8b3b32cac7..998ffc449f37e 100644 --- a/src/loadso/os2/SDL_sysloadso.c +++ b/src/loadso/os2/SDL_sysloadso.c @@ -90,7 +90,7 @@ void *SDL_LoadFunction(void *handle, const char *name) void SDL_UnloadObject(void *handle) { - if (handle != NULL) { + if (handle) { DosFreeModule((HMODULE)handle); } } diff --git a/src/locale/unix/SDL_syslocale.c b/src/locale/unix/SDL_syslocale.c index 720d6ecacd29d..9c0e7c06ee565 100644 --- a/src/locale/unix/SDL_syslocale.c +++ b/src/locale/unix/SDL_syslocale.c @@ -71,7 +71,7 @@ void SDL_SYS_GetPreferredLocales(char *buf, size_t buflen) SDL_assert(buflen > 0); tmp = SDL_small_alloc(char, buflen, &isstack); - if (tmp == NULL) { + if (!tmp) { SDL_OutOfMemory(); return; } diff --git a/src/locale/windows/SDL_syslocale.c b/src/locale/windows/SDL_syslocale.c index a15cb5f158da0..3a0472b47d04f 100644 --- a/src/locale/windows/SDL_syslocale.c +++ b/src/locale/windows/SDL_syslocale.c @@ -61,11 +61,11 @@ static void 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) { SDL_OutOfMemory(); return; } diff --git a/src/main/haiku/SDL_BeApp.cc b/src/main/haiku/SDL_BeApp.cc index 63af36bdb1e2b..bb99041270879 100644 --- a/src/main/haiku/SDL_BeApp.cc +++ b/src/main/haiku/SDL_BeApp.cc @@ -109,13 +109,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 */ @@ -168,7 +168,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/main/ngage/SDL_ngage_main.cpp b/src/main/ngage/SDL_ngage_main.cpp index 10d848870aa65..7439a2fd12a5d 100644 --- a/src/main/ngage/SDL_ngage_main.cpp +++ b/src/main/ngage/SDL_ngage_main.cpp @@ -58,7 +58,7 @@ TInt E32Main() newHeap = User::ChunkHeap(NULL, heapSize, heapSize, KMinHeapGrowBy); - if (newHeap == NULL) { + if (!newHeap) { ret = 3; goto cleanup; } else { diff --git a/src/main/windows/SDL_windows_main.c b/src/main/windows/SDL_windows_main.c index 189b954202d8f..bad49b0caf822 100644 --- a/src/main/windows/SDL_windows_main.c +++ b/src/main/windows/SDL_windows_main.c @@ -43,7 +43,7 @@ static int main_getcmdline(void) int i, argc, result; argvw = CommandLineToArgvW(GetCommandLineW(), &argc); - if (argvw == NULL) { + if (!argvw) { return OutOfMemory(); } @@ -54,13 +54,13 @@ static int main_getcmdline(void) /* 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/render/SDL_render.c b/src/render/SDL_render.c index 73db8c7e1485c..b67b353bf78e6 100644 --- a/src/render/SDL_render.c +++ b/src/render/SDL_render.c @@ -352,7 +352,7 @@ static int QueueCmdSetViewport(SDL_Renderer *renderer) if (!renderer->viewport_queued || (SDL_memcmp(&renderer->viewport, &renderer->last_queued_viewport, sizeof(SDL_DRect)) != 0)) { SDL_RenderCommand *cmd = AllocateRenderCommand(renderer); retval = -1; - if (cmd != NULL) { + if (cmd) { cmd->command = SDL_RENDERCMD_SETVIEWPORT; cmd->data.viewport.first = 0; /* render backend will fill this in. */ /* Convert SDL_DRect to SDL_Rect */ @@ -379,7 +379,7 @@ static int QueueCmdSetClipRect(SDL_Renderer *renderer) (renderer->clipping_enabled != renderer->last_queued_cliprect_enabled) || (SDL_memcmp(&renderer->clip_rect, &renderer->last_queued_cliprect, sizeof(SDL_DRect)) != 0)) { SDL_RenderCommand *cmd = AllocateRenderCommand(renderer); - if (cmd == NULL) { + if (!cmd) { retval = -1; } else { cmd->command = SDL_RENDERCMD_SETCLIPRECT; @@ -986,7 +986,7 @@ SDL_Renderer *SDL_CreateRenderer(SDL_Window *window, int index, Uint32 flags) } } - if (renderer == NULL) { + if (!renderer) { for (index = 0; index < n; ++index) { const SDL_RenderDriver *driver = render_drivers[index]; @@ -1000,7 +1000,7 @@ SDL_Renderer *SDL_CreateRenderer(SDL_Window *window, int index, Uint32 flags) } } } - if (renderer == NULL) { + if (!renderer) { SDL_SetError("Couldn't find matching render driver"); goto error; } @@ -1013,7 +1013,7 @@ SDL_Renderer *SDL_CreateRenderer(SDL_Window *window, int index, Uint32 flags) /* Create a new renderer instance */ renderer = render_drivers[index]->CreateRenderer(window, flags); batching = SDL_FALSE; - if (renderer == NULL) { + if (!renderer) { goto error; } } @@ -1228,7 +1228,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_ScaleModeNearest; } else if (SDL_strcasecmp(hint, "linear") == 0) { return SDL_ScaleModeLinear; @@ -1468,7 +1468,7 @@ SDL_Texture *SDL_CreateTextureFromSurface(SDL_Renderer *renderer, SDL_Surface *s /* Set up a destination surface for the texture update */ dst_fmt = SDL_AllocFormat(format); - if (dst_fmt == NULL) { + if (!dst_fmt) { SDL_DestroyTexture(texture); return NULL; } @@ -2096,7 +2096,7 @@ int SDL_LockTextureToSurface(SDL_Texture *texture, const SDL_Rect *rect, } texture->locked_surface = SDL_CreateRGBSurfaceWithFormatFrom(pixels, real_rect.w, real_rect.h, 0, pitch, texture->format); - if (texture->locked_surface == NULL) { + if (!texture->locked_surface) { SDL_UnlockTexture(texture); return -1; } @@ -2172,7 +2172,7 @@ void SDL_UnlockTexture(SDL_Texture *texture) SDL_bool SDL_RenderTargetSupported(SDL_Renderer *renderer) { - if (renderer == NULL || !renderer->SetRenderTarget) { + if (!renderer || !renderer->SetRenderTarget) { return SDL_FALSE; } return (renderer->info.flags & SDL_RENDERER_TARGETTEXTURE) != 0; @@ -2660,7 +2660,7 @@ static int RenderDrawPointsWithRects(SDL_Renderer *renderer, } frects = SDL_small_alloc(SDL_FRect, count, &isstack); - if (frects == NULL) { + if (!frects) { return SDL_OutOfMemory(); } @@ -2688,7 +2688,7 @@ int SDL_RenderDrawPoints(SDL_Renderer *renderer, CHECK_RENDERER_MAGIC(renderer, -1); - if (points == NULL) { + if (!points) { return SDL_InvalidParamError("SDL_RenderDrawPoints(): points"); } if (count < 1) { @@ -2706,7 +2706,7 @@ int SDL_RenderDrawPoints(SDL_Renderer *renderer, retval = RenderDrawPointsWithRects(renderer, points, count); } else { fpoints = SDL_small_alloc(SDL_FPoint, count, &isstack); - if (fpoints == NULL) { + if (!fpoints) { return SDL_OutOfMemory(); } for (i = 0; i < count; ++i) { @@ -2759,7 +2759,7 @@ int SDL_RenderDrawPointsF(SDL_Renderer *renderer, CHECK_RENDERER_MAGIC(renderer, -1); - if (points == NULL) { + if (!points) { return SDL_InvalidParamError("SDL_RenderDrawPointsF(): points"); } if (count < 1) { @@ -2964,7 +2964,7 @@ int SDL_RenderDrawLines(SDL_Renderer *renderer, CHECK_RENDERER_MAGIC(renderer, -1); - if (points == NULL) { + if (!points) { return SDL_InvalidParamError("SDL_RenderDrawLines(): points"); } if (count < 2) { @@ -2979,7 +2979,7 @@ int SDL_RenderDrawLines(SDL_Renderer *renderer, #endif fpoints = SDL_small_alloc(SDL_FPoint, count, &isstack); - if (fpoints == NULL) { + if (!fpoints) { return SDL_OutOfMemory(); } @@ -3002,7 +3002,7 @@ int SDL_RenderDrawLinesF(SDL_Renderer *renderer, CHECK_RENDERER_MAGIC(renderer, -1); - if (points == NULL) { + if (!points) { return SDL_InvalidParamError("SDL_RenderDrawLinesF(): points"); } if (count < 2) { @@ -3171,7 +3171,7 @@ int SDL_RenderDrawRectF(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) { RenderGetViewportSize(renderer, &frect); rect = &frect; } @@ -3196,7 +3196,7 @@ int SDL_RenderDrawRects(SDL_Renderer *renderer, CHECK_RENDERER_MAGIC(renderer, -1); - if (rects == NULL) { + if (!rects) { return SDL_InvalidParamError("SDL_RenderDrawRects(): rects"); } if (count < 1) { @@ -3225,7 +3225,7 @@ int SDL_RenderDrawRectsF(SDL_Renderer *renderer, CHECK_RENDERER_MAGIC(renderer, -1); - if (rects == NULL) { + if (!rects) { return SDL_InvalidParamError("SDL_RenderDrawRectsF(): rects"); } if (count < 1) { @@ -3272,7 +3272,7 @@ int SDL_RenderFillRectF(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) { RenderGetViewportSize(renderer, &frect); rect = &frect; } @@ -3331,7 +3331,7 @@ int SDL_RenderFillRectsF(SDL_Renderer *renderer, CHECK_RENDERER_MAGIC(renderer, -1); - if (rects == NULL) { + if (!rects) { return SDL_InvalidParamError("SDL_RenderFillRectsF(): rects"); } if (count < 1) { @@ -3346,7 +3346,7 @@ int SDL_RenderFillRectsF(SDL_Renderer *renderer, #endif frects = SDL_small_alloc(SDL_FRect, count, &isstack); - if (frects == NULL) { + if (!frects) { return SDL_OutOfMemory(); } for (i = 0; i < count; ++i) { diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c index 464bda4031f4b..03e4070302a19 100644 --- a/src/render/direct3d/SDL_render_d3d.c +++ b/src/render/direct3d/SDL_render_d3d.c @@ -1562,13 +1562,13 @@ SDL_Renderer *D3D_CreateRenderer(SDL_Window *window, Uint32 flags) int displayIndex; renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); return NULL; } 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 76bf165d38694..002b7629be75c 100644 --- a/src/render/direct3d11/SDL_render_d3d11.c +++ b/src/render/direct3d11/SDL_render_d3d11.c @@ -1408,7 +1408,7 @@ static int D3D11_UpdateTextureNV(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"); } @@ -2305,13 +2305,13 @@ 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; } 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/direct3d11/SDL_render_winrt.cpp b/src/render/direct3d11/SDL_render_winrt.cpp index 3f24d0f212c61..4633e11f70cb9 100644 --- a/src/render/direct3d11/SDL_render_winrt.cpp +++ b/src/render/direct3d11/SDL_render_winrt.cpp @@ -46,7 +46,7 @@ extern "C" void * D3D11_GetCoreWindowFromSDLRenderer(SDL_Renderer *renderer) { SDL_Window *sdlWindow = renderer->window; - if (renderer->window == NULL) { + if (!renderer->window) { return NULL; } diff --git a/src/render/direct3d12/SDL_render_d3d12.c b/src/render/direct3d12/SDL_render_d3d12.c index aa1fc160d4f5c..bfce68043532e 100644 --- a/src/render/direct3d12/SDL_render_d3d12.c +++ b/src/render/direct3d12/SDL_render_d3d12.c @@ -2965,13 +2965,13 @@ 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; } 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/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c index 962acba523cd4..0b60de8e2d200 100644 --- a/src/render/opengles/SDL_render_gles.c +++ b/src/render/opengles/SDL_render_gles.c @@ -187,7 +187,7 @@ static GLES_FBOList *GLES_GetFBO(GLES_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(GLES_FBOList)); result->w = w; result->h = h; @@ -332,7 +332,7 @@ static int GLES_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) } data = (GLES_TextureData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { return SDL_OutOfMemory(); } @@ -424,7 +424,7 @@ static int GLES_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, src = (Uint8 *)pixels; if (pitch != srcPitch) { blob = (Uint8 *)SDL_malloc(srcPitch * rect->h); - if (blob == NULL) { + if (!blob) { return SDL_OutOfMemory(); } src = blob; @@ -510,7 +510,7 @@ static int GLES_SetRenderTarget(SDL_Renderer *renderer, SDL_Texture *texture) data->drawstate.viewport_dirty = SDL_TRUE; - if (texture == NULL) { + if (!texture) { data->glBindFramebufferOES(GL_FRAMEBUFFER_OES, data->window_framebuffer); return 0; } @@ -537,7 +537,7 @@ static int GLES_QueueDrawPoints(SDL_Renderer *renderer, SDL_RenderCommand *cmd, GLfloat *verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, count * 2 * sizeof(GLfloat), 0, &cmd->data.draw.first); int i; - if (verts == NULL) { + if (!verts) { return -1; } @@ -557,7 +557,7 @@ static int GLES_QueueDrawLines(SDL_Renderer *renderer, SDL_RenderCommand *cmd, c 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; @@ -602,7 +602,7 @@ static int GLES_QueueGeometry(SDL_Renderer *renderer, SDL_RenderCommand *cmd, SD int sz = 2 + 4 + (texture ? 2 : 0); verts = (GLfloat *)SDL_AllocateRenderVertices(renderer, count * sz * sizeof(GLfloat), 0, &cmd->data.draw.first); - if (verts == NULL) { + if (!verts) { return -1; } @@ -911,7 +911,7 @@ static int GLES_RenderReadPixels(SDL_Renderer *renderer, const SDL_Rect *rect, temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format); temp_pixels = SDL_malloc(rect->h * temp_pitch); - if (temp_pixels == NULL) { + if (!temp_pixels) { return SDL_OutOfMemory(); } @@ -970,7 +970,7 @@ static void GLES_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) renderdata->drawstate.target = NULL; } - if (data == NULL) { + if (!data) { return; } if (data->texture) { @@ -1082,13 +1082,13 @@ static SDL_Renderer *GLES_CreateRenderer(SDL_Window *window, Uint32 flags) } renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(*renderer)); - if (renderer == NULL) { + if (!renderer) { SDL_OutOfMemory(); goto error; } data = (GLES_RenderData *)SDL_calloc(1, sizeof(*data)); - if (data == NULL) { + if (!data) { GLES_DestroyRenderer(renderer); SDL_OutOfMemory(); goto error; diff --git a/src/render/software/SDL_render_sw.c b/src/render/software/SDL_render_sw.c index a358e741600cb..6420b108a1cee 100644 --- a/src/render/software/SDL_render_sw.c +++ b/src/render/software/SDL_render_sw.c @@ -346,7 +346,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex src_clone = SDL_CreateRGBSurfaceFrom(src->pixels, src->w, src->h, src->format->BitsPerPixel, src->pitch, src->format->Rmask, src->format->Gmask, src->format->Bmask, src->format->Amask); - if (src_clone == NULL) { + if (!src_clone) { if (SDL_MUSTLOCK(src)) { SDL_UnlockSurface(src); } @@ -390,7 +390,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex if (blendmode == SDL_BLENDMODE_NONE && !isOpaque) { mask = SDL_CreateRGBSurface(0, final_rect->w, final_rect->h, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); - if (mask == NULL) { + if (!mask) { retval = -1; } else { SDL_SetSurfaceBlendMode(mask, SDL_BLENDMODE_MOD); @@ -404,7 +404,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex SDL_Rect scale_rect = tmp_rect; src_scaled = SDL_CreateRGBSurface(0, final_rect->w, final_rect->h, 32, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); - if (src_scaled == NULL) { + if (!src_scaled) { retval = -1; } else { SDL_SetSurfaceBlendMode(src_clone, SDL_BLENDMODE_NONE); @@ -487,7 +487,7 @@ static int SW_RenderCopyEx(SDL_Renderer *renderer, SDL_Surface *surface, SDL_Tex src_rotated->format->BitsPerPixel, src_rotated->pitch, src_rotated->format->Rmask, src_rotated->format->Gmask, src_rotated->format->Bmask, 0); - 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_FreeSurface(mask_rotated); } - if (src_rotated != NULL) { + if (src_rotated) { SDL_FreeSurface(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_FreeSurface(mask); } - if (src_clone != NULL) { + if (src_clone) { SDL_FreeSurface(src_clone); } return retval; @@ -712,7 +712,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; @@ -739,7 +739,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; @@ -766,7 +766,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; @@ -794,7 +794,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; } @@ -852,7 +852,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; } @@ -880,7 +880,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; @@ -903,7 +903,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; diff --git a/src/render/software/SDL_rotate.c b/src/render/software/SDL_rotate.c index be62e24e735c1..f1c12f7c4fc97 100644 --- a/src/render/software/SDL_rotate.c +++ b/src/render/software/SDL_rotate.c @@ -524,7 +524,7 @@ SDL_Surface *SDLgfx_rotateSurface(SDL_Surface *src, double angle, int smooth, in if (is8bit) { /* Target surface is 8 bit */ rz_dst = SDL_CreateRGBSurfaceWithFormat(0, rect_dest->w, rect_dest->h + GUARD_ROWS, 8, 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]; diff --git a/src/render/software/SDL_triangle.c b/src/render/software/SDL_triangle.c index 7dab08d5d9a98..c1b44abfc0ad0 100644 --- a/src/render/software/SDL_triangle.c +++ b/src/render/software/SDL_triangle.c @@ -272,7 +272,7 @@ int SDL_SW_FillTriangle(SDL_Surface *dst, SDL_Point *d0, SDL_Point *d1, SDL_Poin /* Use an intermediate surface */ tmp = SDL_CreateRGBSurfaceWithFormat(0, dstrect.w, dstrect.h, 0, format); - if (tmp == NULL) { + if (!tmp) { ret = -1; goto end; } diff --git a/src/sensor/SDL_sensor.c b/src/sensor/SDL_sensor.c index 095d3749fe6c2..15fb7d0d6a8d7 100644 --- a/src/sensor/SDL_sensor.c +++ b/src/sensor/SDL_sensor.c @@ -297,7 +297,7 @@ static int SDL_PrivateSensorValid(SDL_Sensor *sensor) { int valid; - if (sensor == NULL) { + if (!sensor) { SDL_SetError("Sensor hasn't been opened yet"); valid = 0; } else { diff --git a/src/sensor/android/SDL_androidsensor.c b/src/sensor/android/SDL_androidsensor.c index 3bc9647e0b972..41e117382f8ae 100644 --- a/src/sensor/android/SDL_androidsensor.c +++ b/src/sensor/android/SDL_androidsensor.c @@ -59,9 +59,9 @@ static int SDL_ANDROID_SensorInit(void) } SDL_sensor_looper = ALooper_forThread(); - if (SDL_sensor_looper == NULL) { + if (!SDL_sensor_looper) { SDL_sensor_looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS); - if (SDL_sensor_looper == NULL) { + if (!SDL_sensor_looper) { return SDL_SetError("Couldn't create sensor event loop"); } } @@ -125,7 +125,7 @@ static int SDL_ANDROID_SensorOpen(SDL_Sensor *sensor, int device_index) int delay_us, min_delay_us; hwdata = (struct sensor_hwdata *)SDL_calloc(1, sizeof(*hwdata)); - if (hwdata == NULL) { + if (!hwdata) { return SDL_OutOfMemory(); } diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c index 65f8bc9aa9e22..a7187195a7bec 100644 --- a/src/test/SDL_test_common.c +++ b/src/test/SDL_test_common.c @@ -592,7 +592,7 @@ void SDLTest_CommonLogUsage(SDLTest_CommonState *state, const char *argv0, const static const char *BuildCommonUsageString(char **pstr, const char **strlist, const int numitems, const char **strlist2, const int numitems2) { char *str = *pstr; - if (str == NULL) { + if (!str) { size_t len = SDL_strlen("[--trackmem]") + 2; int i; for (i = 0; i < numitems; i++) { @@ -604,7 +604,7 @@ static const char *BuildCommonUsageString(char **pstr, const char **strlist, con } } str = (char *)SDL_calloc(1, len); - if (str == NULL) { + if (!str) { return ""; /* oh well. */ } SDL_strlcat(str, "[--trackmem] ", len); @@ -1769,7 +1769,7 @@ static void SDLTest_ScreenShot(SDL_Renderer *renderer) 0x000000FF, 0x0000FF00, 0x00FF0000, #endif 0x00000000); - if (surface == NULL) { + if (!surface) { SDL_Log("Couldn't create surface: %s\n", SDL_GetError()); return; } @@ -1793,7 +1793,7 @@ static void FullscreenTo(int index, int windowId) Uint32 flags; struct SDL_Rect rect = { 0, 0, 0, 0 }; SDL_Window *window = SDL_GetWindowFromID(windowId); - if (window == NULL) { + if (!window) { return; } diff --git a/src/test/SDL_test_compare.c b/src/test/SDL_test_compare.c index b8408802644b1..d55d37a5abc0c 100644 --- a/src/test/SDL_test_compare.c +++ b/src/test/SDL_test_compare.c @@ -70,7 +70,7 @@ int SDLTest_CompareSurfaces(SDL_Surface *surface, SDL_Surface *referenceSurface, char referenceFilename[FILENAME_SIZE]; /* Validate input surfaces */ - if (surface == NULL || referenceSurface == NULL) { + if (!surface || !referenceSurface) { return -1; } diff --git a/src/test/SDL_test_font.c b/src/test/SDL_test_font.c index 52ec5e0118b38..57998fb200af2 100644 --- a/src/test/SDL_test_font.c +++ b/src/test/SDL_test_font.c @@ -3190,7 +3190,7 @@ int SDLTest_DrawCharacter(SDL_Renderer *renderer, int x, int y, Uint32 c) character = SDL_CreateRGBSurface(SDL_SWSURFACE, charWidth, charHeight, 32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF); - if (character == NULL) { + if (!character) { return -1; } diff --git a/src/test/SDL_test_memory.c b/src/test/SDL_test_memory.c index 420762c004a08..8f737ec12a8d7 100644 --- a/src/test/SDL_test_memory.c +++ b/src/test/SDL_test_memory.c @@ -171,7 +171,7 @@ static void *SDLCALL SDLTest_TrackedRealloc(void *ptr, size_t size) { void *mem; - SDL_assert(ptr == NULL || SDL_IsAllocationTracked(ptr)); + SDL_assert(!ptr || SDL_IsAllocationTracked(ptr)); mem = SDL_realloc_orig(ptr, size); if (mem && mem != ptr) { if (ptr) { diff --git a/src/thread/SDL_thread.c b/src/thread/SDL_thread.c index dad2f2f328c75..791035abb36ed 100644 --- a/src/thread/SDL_thread.c +++ b/src/thread/SDL_thread.c @@ -120,14 +120,14 @@ SDL_TLSData *SDL_Generic_GetTLSData(void) SDL_TLSData *storage = NULL; #if !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; } @@ -262,7 +262,7 @@ SDL_error *SDL_GetErrBuf(void) /* Mark that we're in the middle of allocating our buffer */ SDL_TLSSet(tls_errbuf, ALLOCATION_IN_PROGRESS, NULL); errbuf = (SDL_error *)realloc_func(NULL, sizeof(*errbuf)); - if (errbuf == NULL) { + if (!errbuf) { SDL_TLSSet(tls_errbuf, NULL, NULL); return SDL_GetStaticErrBuf(); } diff --git a/src/thread/generic/SDL_sysmutex.c b/src/thread/generic/SDL_sysmutex.c index daafbb607a507..0e77b3a271572 100644 --- a/src/thread/generic/SDL_sysmutex.c +++ b/src/thread/generic/SDL_sysmutex.c @@ -107,7 +107,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex) int retval = 0; SDL_threadID this_thread; - if (mutex == NULL) { + if (!mutex) { return 0; } diff --git a/src/thread/generic/SDL_syssem.c b/src/thread/generic/SDL_syssem.c index 495dad343f426..3e25a935c3404 100644 --- a/src/thread/generic/SDL_syssem.c +++ b/src/thread/generic/SDL_syssem.c @@ -78,7 +78,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) SDL_sem *sem; sem = (SDL_sem *)SDL_malloc(sizeof(*sem)); - if (sem == NULL) { + if (!sem) { SDL_OutOfMemory(); return NULL; } @@ -139,7 +139,7 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) { int retval; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } diff --git a/src/thread/n3ds/SDL_sysmutex.c b/src/thread/n3ds/SDL_sysmutex.c index 09e0e0ae3d1ad..2be6a18b3958c 100644 --- a/src/thread/n3ds/SDL_sysmutex.c +++ b/src/thread/n3ds/SDL_sysmutex.c @@ -64,7 +64,7 @@ int SDL_LockMutex(SDL_mutex *mutex) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang doesn /* try Lock the mutex */ int SDL_TryLockMutex(SDL_mutex *mutex) { - if (mutex == NULL) { + if (!mutex) { return 0; } diff --git a/src/thread/n3ds/SDL_syssem.c b/src/thread/n3ds/SDL_syssem.c index 0af8a9d5022d8..214aa7bf9f1ed 100644 --- a/src/thread/n3ds/SDL_syssem.c +++ b/src/thread/n3ds/SDL_syssem.c @@ -46,7 +46,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) } sem = (SDL_sem *)SDL_malloc(sizeof(*sem)); - if (sem == NULL) { + if (!sem) { SDL_OutOfMemory(); return NULL; } @@ -81,7 +81,7 @@ int SDL_SemTryWait(SDL_sem *sem) int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) { - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } diff --git a/src/thread/ngage/SDL_syssem.cpp b/src/thread/ngage/SDL_syssem.cpp index f623844d569ee..c09fac5a680ee 100644 --- a/src/thread/ngage/SDL_syssem.cpp +++ b/src/thread/ngage/SDL_syssem.cpp @@ -134,7 +134,7 @@ int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) int SDL_SemTryWait(SDL_sem *sem) { - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } diff --git a/src/thread/os2/SDL_syssem.c b/src/thread/os2/SDL_syssem.c index 407867d6706d3..7982ac15d6042 100644 --- a/src/thread/os2/SDL_syssem.c +++ b/src/thread/os2/SDL_syssem.c @@ -44,7 +44,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) ULONG ulRC; SDL_sem *pSDLSem = SDL_malloc(sizeof(SDL_sem)); - if (pSDLSem == NULL) { + if (!pSDLSem) { SDL_OutOfMemory(); return NULL; } @@ -85,7 +85,7 @@ int SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) ULONG ulTimeout; ULONG cPost; - if (sem == NULL) + if (!sem) return SDL_InvalidParamError("sem"); if (timeout != SEM_INDEFINITE_WAIT) @@ -140,7 +140,7 @@ Uint32 SDL_SemValue(SDL_sem * sem) { ULONG ulRC; - if (sem == NULL) { + if (!sem) { SDL_InvalidParamError("sem"); return 0; } @@ -159,7 +159,7 @@ int SDL_SemPost(SDL_sem * sem) { ULONG ulRC; - if (sem == NULL) + if (!sem) return SDL_InvalidParamError("sem"); ulRC = DosRequestMutexSem(sem->hMtx, SEM_INDEFINITE_WAIT); diff --git a/src/thread/os2/SDL_systhread.c b/src/thread/os2/SDL_systhread.c index b2555892c18b4..977f1a69b90a2 100644 --- a/src/thread/os2/SDL_systhread.c +++ b/src/thread/os2/SDL_systhread.c @@ -45,7 +45,7 @@ static void RunThread(void *data) SDL_Thread *thread = (SDL_Thread *) data; pfnSDL_CurrentEndThread pfnEndThread = (pfnSDL_CurrentEndThread) thread->endfunc; - if (ppSDLTLSData != NULL) + if (ppSDLTLSData) *ppSDLTLSData = NULL; SDL_RunThread(thread); diff --git a/src/thread/os2/SDL_systls.c b/src/thread/os2/SDL_systls.c index 563ab74b806ea..a6cefc148ec0d 100644 --- a/src/thread/os2/SDL_systls.c +++ b/src/thread/os2/SDL_systls.c @@ -41,7 +41,7 @@ void SDL_OS2TLSAlloc(void) { ULONG ulRC; - if (cTLSAlloc == 0 || ppSDLTLSData == NULL) { + if (cTLSAlloc == 0 || !ppSDLTLSData) { /* First call - allocate the thread local memory (1 DWORD) */ ulRC = DosAllocThreadLocalMemory(1, (PULONG *)&ppSDLTLSData); if (ulRC != NO_ERROR) { @@ -59,7 +59,7 @@ void SDL_OS2TLSFree(void) if (cTLSAlloc != 0) cTLSAlloc--; - if (cTLSAlloc == 0 && ppSDLTLSData != NULL) { + if (cTLSAlloc == 0 && ppSDLTLSData) { /* Last call - free the thread local memory */ ulRC = DosFreeThreadLocalMemory((PULONG)ppSDLTLSData); if (ulRC != NO_ERROR) { @@ -72,7 +72,7 @@ void SDL_OS2TLSFree(void) SDL_TLSData *SDL_SYS_GetTLSData(void) { - return (ppSDLTLSData == NULL)? NULL : *ppSDLTLSData; + return (!ppSDLTLSData)? NULL : *ppSDLTLSData; } int SDL_SYS_SetTLSData(SDL_TLSData *data) diff --git a/src/thread/ps2/SDL_syssem.c b/src/thread/ps2/SDL_syssem.c index 80613d853c432..c54fc992c0000 100644 --- a/src/thread/ps2/SDL_syssem.c +++ b/src/thread/ps2/SDL_syssem.c @@ -50,7 +50,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) ee_sema_t sema; sem = (SDL_sem *)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; diff --git a/src/thread/psp/SDL_sysmutex.c b/src/thread/psp/SDL_sysmutex.c index 3b3cf3786f35c..771be39a28bb8 100644 --- a/src/thread/psp/SDL_sysmutex.c +++ b/src/thread/psp/SDL_sysmutex.c @@ -101,7 +101,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex) #else SceInt32 res = 0; - if (mutex == NULL) { + if (!mutex) { return 0; } diff --git a/src/thread/psp/SDL_syssem.c b/src/thread/psp/SDL_syssem.c index ed367e9bd9c00..2695536168e64 100644 --- a/src/thread/psp/SDL_syssem.c +++ b/src/thread/psp/SDL_syssem.c @@ -44,7 +44,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) SDL_sem *sem; sem = (SDL_sem *)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) { diff --git a/src/thread/pthread/SDL_syscond.c b/src/thread/pthread/SDL_syscond.c index df367f76596c6..7e3384613253e 100644 --- a/src/thread/pthread/SDL_syscond.c +++ b/src/thread/pthread/SDL_syscond.c @@ -141,7 +141,7 @@ int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms) */ int SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex) { - if (cond == NULL) { + if (!cond) { return SDL_InvalidParamError("cond"); } else if (pthread_cond_wait(&cond->cond, &mutex->id) != 0) { return SDL_SetError("pthread_cond_wait() failed"); diff --git a/src/thread/pthread/SDL_sysmutex.c b/src/thread/pthread/SDL_sysmutex.c index 9b24e1605cb56..6f701974eb0e4 100644 --- a/src/thread/pthread/SDL_sysmutex.c +++ b/src/thread/pthread/SDL_sysmutex.c @@ -117,7 +117,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex) pthread_t this_thread; #endif - if (mutex == NULL) { + if (!mutex) { return 0; } diff --git a/src/thread/pthread/SDL_syssem.c b/src/thread/pthread/SDL_syssem.c index e6e23bb2c833b..7c53161fbccf8 100644 --- a/src/thread/pthread/SDL_syssem.c +++ b/src/thread/pthread/SDL_syssem.c @@ -45,7 +45,7 @@ struct SDL_semaphore SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) { SDL_sem *sem = (SDL_sem *)SDL_malloc(sizeof(SDL_sem)); - if (sem != NULL) { + if (sem) { if (sem_init(&sem->sem, 0, initial_value) < 0) { SDL_SetError("sem_init() failed"); SDL_free(sem); @@ -69,7 +69,7 @@ int SDL_SemTryWait(SDL_sem *sem) { int retval; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } retval = SDL_MUTEX_TIMEDOUT; @@ -83,7 +83,7 @@ int SDL_SemWait(SDL_sem *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 5316807058f9a..97eae57c4d2d7 100644 --- a/src/thread/pthread/SDL_systhread.c +++ b/src/thread/pthread/SDL_systhread.c @@ -127,10 +127,10 @@ void SDL_SYS_SetupThread(const char *name) sigset_t mask; #endif /* !__NACL__ */ - if (name != NULL) { + if (name) { #if (defined(__MACOSX__) || defined(__IPHONEOS__) || defined(__LINUX__)) && defined(HAVE_DLOPEN) SDL_assert(checked_setname); - if (ppthread_setname_np != NULL) { + if (ppthread_setname_np) { #if defined(__MACOSX__) || defined(__IPHONEOS__) ppthread_setname_np(name); #elif defined(__LINUX__) diff --git a/src/thread/stdcpp/SDL_sysmutex.cpp b/src/thread/stdcpp/SDL_sysmutex.cpp index bbc7352163bd0..d726461721336 100644 --- a/src/thread/stdcpp/SDL_sysmutex.cpp +++ b/src/thread/stdcpp/SDL_sysmutex.cpp @@ -77,7 +77,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex) { int retval = 0; - if (mutex == NULL) { + if (!mutex) { return 0; } diff --git a/src/thread/vita/SDL_syscond.c b/src/thread/vita/SDL_syscond.c index 5e5ddeb90e1d8..3d29e6522e2d1 100644 --- a/src/thread/vita/SDL_syscond.c +++ b/src/thread/vita/SDL_syscond.c @@ -45,7 +45,7 @@ SDL_cond *SDL_CreateCond(void) SDL_cond *cond; cond = (SDL_cond *)SDL_malloc(sizeof(SDL_cond)); - if (cond != NULL) { + if (cond) { cond->lock = SDL_CreateMutex(); cond->wait_sem = SDL_CreateSemaphore(0); cond->wait_done = SDL_CreateSemaphore(0); diff --git a/src/thread/vita/SDL_sysmutex.c b/src/thread/vita/SDL_sysmutex.c index b8df4159b024c..aaf14014e3dce 100644 --- a/src/thread/vita/SDL_sysmutex.c +++ b/src/thread/vita/SDL_sysmutex.c @@ -41,7 +41,7 @@ SDL_mutex *SDL_CreateMutex(void) /* Allocate mutex memory */ mutex = (SDL_mutex *)SDL_malloc(sizeof(*mutex)); - if (mutex != NULL) { + if (mutex) { res = sceKernelCreateLwMutex( &mutex->lock, @@ -97,7 +97,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 5a5a8323304b7..4b568feb78b2d 100644 --- a/src/thread/vita/SDL_syssem.c +++ b/src/thread/vita/SDL_syssem.c @@ -45,7 +45,7 @@ SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) SDL_sem *sem; sem = (SDL_sem *)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) { diff --git a/src/thread/windows/SDL_syscond_cv.c b/src/thread/windows/SDL_syscond_cv.c index 7251592427e2f..c96850a75923e 100644 --- a/src/thread/windows/SDL_syscond_cv.c +++ b/src/thread/windows/SDL_syscond_cv.c @@ -220,14 +220,14 @@ static const SDL_cond_impl_t SDL_cond_impl_generic = { SDL_cond *SDL_CreateCond(void) { - if (SDL_cond_impl_active.Create == NULL) { + if (!SDL_cond_impl_active.Create) { /* Default to generic implementation, works with all mutex implementations */ const SDL_cond_impl_t *impl = &SDL_cond_impl_generic; 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 7edd5238e09b2..9c377e63db1ca 100644 --- a/src/thread/windows/SDL_sysmutex.c +++ b/src/thread/windows/SDL_sysmutex.c @@ -153,7 +153,7 @@ static SDL_mutex *SDL_CreateMutex_cs(void) /* Allocate mutex memory */ 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 */ #if __WINRT__ @@ -221,7 +221,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; @@ -260,7 +260,7 @@ void SDL_DestroyMutex(SDL_mutex *mutex) int SDL_LockMutex(SDL_mutex *mutex) { - if (mutex == NULL) { + if (!mutex) { return 0; } @@ -269,7 +269,7 @@ int SDL_LockMutex(SDL_mutex *mutex) int SDL_TryLockMutex(SDL_mutex *mutex) { - if (mutex == NULL) { + if (!mutex) { return 0; } @@ -278,7 +278,7 @@ int SDL_TryLockMutex(SDL_mutex *mutex) int SDL_UnlockMutex(SDL_mutex *mutex) { - if (mutex == NULL) { + if (!mutex) { return 0; } diff --git a/src/thread/windows/SDL_syssem.c b/src/thread/windows/SDL_syssem.c index b94a3e3ba8c6d..6397f02808f2c 100644 --- a/src/thread/windows/SDL_syssem.c +++ b/src/thread/windows/SDL_syssem.c @@ -138,7 +138,7 @@ static int SDL_SemWait_atom(SDL_sem *_sem) SDL_sem_atom *sem = (SDL_sem_atom *)_sem; LONG count; - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } @@ -169,7 +169,7 @@ static int SDL_SemWaitTimeout_atom(SDL_sem *_sem, Uint32 timeout) return SDL_SemWait_atom(_sem); } - if (sem == NULL) { + if (!sem) { return SDL_InvalidParamError("sem"); } diff --git a/src/video/SDL_RLEaccel.c b/src/video/SDL_RLEaccel.c index 2dd1390238138..cfc207c050627 100644 --- a/src/video/SDL_RLEaccel.c +++ b/src/video/SDL_RLEaccel.c @@ -1492,7 +1492,7 @@ static SDL_bool UnRLEAlpha(SDL_Surface *surface) } surface->pixels = SDL_SIMDAlloc((size_t)surface->h * surface->pitch); - if (surface->pixels == NULL) { + if (!surface->pixels) { return SDL_FALSE; } surface->flags |= SDL_SIMD_ALIGNED; @@ -1558,7 +1558,7 @@ void SDL_UnRLESurface(SDL_Surface *surface, int recode) /* re-create the original surface */ surface->pixels = SDL_SIMDAlloc((size_t)surface->h * surface->pitch); - if (surface->pixels == NULL) { + if (!surface->pixels) { /* Oh crap... */ surface->flags |= SDL_RLEACCEL; return; diff --git a/src/video/SDL_bmp.c b/src/video/SDL_bmp.c index 117d4f44b04dd..24a3c2897b11e 100644 --- a/src/video/SDL_bmp.c +++ b/src/video/SDL_bmp.c @@ -238,7 +238,7 @@ SDL_Surface *SDL_LoadBMP_RW(SDL_RWops *src, int freesrc) /* Make sure we are passed a valid data source */ surface = NULL; was_error = SDL_FALSE; - if (src == NULL) { + if (!src) { SDL_InvalidParamError("src"); was_error = SDL_TRUE; goto done; @@ -424,7 +424,7 @@ SDL_Surface *SDL_LoadBMP_RW(SDL_RWops *src, int freesrc) surface = SDL_CreateRGBSurface(0, biWidth, biHeight, biBitCount, Rmask, Gmask, Bmask, Amask); - if (surface == NULL) { + if (!surface) { was_error = SDL_TRUE; goto done; } @@ -697,7 +697,7 @@ int SDL_SaveBMP_RW(SDL_Surface *surface, SDL_RWops *dst, int freedst) SDL_InitFormat(&format, SDL_PIXELFORMAT_BGR24); } intermediate_surface = SDL_ConvertSurface(surface, &format, 0); - if (intermediate_surface == NULL) { + if (!intermediate_surface) { SDL_SetError("Couldn't convert image to %d bpp", format.BitsPerPixel); } diff --git a/src/video/SDL_clipboard.c b/src/video/SDL_clipboard.c index 5913871310a9f..f1d8e90daa68c 100644 --- a/src/video/SDL_clipboard.c +++ b/src/video/SDL_clipboard.c @@ -31,7 +31,7 @@ int SDL_SetClipboardText(const char *text) return SDL_SetError("Video subsystem must be initialized to set clipboard text"); } - if (text == NULL) { + if (!text) { text = ""; } if (_this->SetClipboardText) { @@ -47,11 +47,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) { @@ -76,7 +76,7 @@ char *SDL_GetClipboardText(void) return _this->GetClipboardText(_this); } else { const char *text = _this->clipboard_text; - if (text == NULL) { + if (!text) { text = ""; } return SDL_strdup(text); @@ -87,7 +87,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(""); } @@ -96,7 +96,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); diff --git a/src/video/SDL_egl.c b/src/video/SDL_egl.c index ddcf29e354235..15bf8de852e0a 100644 --- a/src/video/SDL_egl.c +++ b/src/video/SDL_egl.c @@ -245,24 +245,24 @@ SDL_bool SDL_EGL_HasExtension(_THIS, SDL_EGL_ExtensionType type, const char *ext void *SDL_EGL_GetProcAddress(_THIS, const char *proc) { void *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); } } @@ -535,7 +535,7 @@ int SDL_EGL_LoadLibrary(_THIS, const char *egl_path, NativeDisplayType native_di } #endif /* Try the implementation-specific eglGetDisplay even if eglGetPlatformDisplay fails */ - if ((_this->egl_data->egl_display == EGL_NO_DISPLAY) && (_this->egl_data->eglGetDisplay != NULL)) { + if ((_this->egl_data->egl_display == EGL_NO_DISPLAY) && (_this->egl_data->eglGetDisplay)) { _this->egl_data->egl_display = _this->egl_data->eglGetDisplay(native_display); } if (_this->egl_data->egl_display == EGL_NO_DISPLAY) { diff --git a/src/video/SDL_fillrect.c b/src/video/SDL_fillrect.c index 7468bd5644b8e..9db592953de08 100644 --- a/src/video/SDL_fillrect.c +++ b/src/video/SDL_fillrect.c @@ -233,12 +233,12 @@ static void SDL_FillRect4(Uint8 *pixels, int pitch, Uint32 color, int w, int h) */ int SDL_FillRect(SDL_Surface *dst, const SDL_Rect *rect, Uint32 color) { - if (dst == NULL) { + if (!dst) { return SDL_InvalidParamError("SDL_FillRect(): 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)) { @@ -306,7 +306,7 @@ int SDL_FillRects(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_FillRects(): dst"); } @@ -320,7 +320,7 @@ int SDL_FillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, return SDL_SetError("SDL_FillRects(): You must lock the surface"); } - if (rects == NULL) { + if (!rects) { return SDL_InvalidParamError("SDL_FillRects(): rects"); } @@ -342,7 +342,7 @@ int SDL_FillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, } #if 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; @@ -357,7 +357,7 @@ int SDL_FillRects(SDL_Surface *dst, const SDL_Rect *rects, int count, } #endif #if 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; diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c index b935f0d4a207a..1167c22d23d5d 100644 --- a/src/video/SDL_pixels.c +++ b/src/video/SDL_pixels.c @@ -616,7 +616,7 @@ void SDL_FreeFormat(SDL_PixelFormat *format) { SDL_PixelFormat *prev; - if (format == NULL) { + if (!format) { SDL_InvalidParamError("format"); return; } @@ -734,7 +734,7 @@ int SDL_SetPaletteColors(SDL_Palette *palette, const SDL_Color *colors, void SDL_FreePalette(SDL_Palette *palette) { - if (palette == NULL) { + if (!palette) { SDL_InvalidParamError("palette"); return; } @@ -1144,7 +1144,7 @@ void SDL_CalculateGammaRamp(float gamma, Uint16 * ramp) SDL_InvalidParamError("gamma"); return; } - if (ramp == NULL) { + if (!ramp) { SDL_InvalidParamError("ramp"); return; } diff --git a/src/video/SDL_rect_impl.h b/src/video/SDL_rect_impl.h index 7e4c127b005ac..923092619c634 100644 --- a/src/video/SDL_rect_impl.h +++ b/src/video/SDL_rect_impl.h @@ -120,13 +120,13 @@ void SDL_UNIONRECT(const RECTTYPE *A, const RECTTYPE *B, RECTTYPE *result) { SCALARTYPE Amin, Amax, Bmin, Bmax; - if (A == NULL) { + if (!A) { SDL_InvalidParamError("A"); return; - } else if (B == NULL) { + } else if (!B) { SDL_InvalidParamError("B"); return; - } else if (result == NULL) { + } else if (!result) { SDL_InvalidParamError("result"); return; } else if (SDL_RECTEMPTY(A)) { /* Special cases for empty Rects */ diff --git a/src/video/SDL_shape.c b/src/video/SDL_shape.c index 23fa919b13d6a..ecd683e78c8c0 100644 --- a/src/video/SDL_shape.c +++ b/src/video/SDL_shape.c @@ -32,13 +32,13 @@ SDL_Window *SDL_CreateShapedWindow(const char *title, unsigned int x, unsigned i { SDL_Window *result = NULL; result = SDL_CreateWindow(title, -1000, -1000, w, h, (flags | SDL_WINDOW_BORDERLESS) & (~SDL_WINDOW_FULLSCREEN) & (~SDL_WINDOW_RESIZABLE) /* & (~SDL_WINDOW_SHOWN) */); - 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->userx = x; result->shaper->usery = y; result->shaper->mode.mode = ShapeModeDefault; diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index b0d89e65ba662..132cfaa30410d 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -125,7 +125,7 @@ SDL_Surface *SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, if (SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) { SDL_Palette *palette = SDL_AllocPalette((1 << surface->format->BitsPerPixel)); - if (palette == NULL) { + if (!palette) { SDL_FreeSurface(surface); return NULL; } @@ -238,7 +238,7 @@ SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels, } surface = SDL_CreateRGBSurfaceWithFormat(0, 0, 0, depth, format); - if (surface != NULL) { + if (surface) { surface->flags |= SDL_PREALLOC; surface->pixels = pixels; surface->w = width; @@ -284,7 +284,7 @@ SDL_Surface *SDL_CreateRGBSurfaceWithFormatFrom(void *pixels, } surface = SDL_CreateRGBSurfaceWithFormat(0, 0, 0, depth, format); - if (surface != NULL) { + if (surface) { surface->flags |= SDL_PREALLOC; surface->pixels = pixels; surface->w = width; @@ -297,7 +297,7 @@ SDL_Surface *SDL_CreateRGBSurfaceWithFormatFrom(void *pixels, int SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette) { - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("SDL_SetSurfacePalette(): surface"); } if (SDL_SetPixelFormatPalette(surface->format, palette) < 0) { @@ -312,7 +312,7 @@ int SDL_SetSurfaceRLE(SDL_Surface *surface, int flag) { int flags; - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("surface"); } @@ -330,7 +330,7 @@ int SDL_SetSurfaceRLE(SDL_Surface *surface, int flag) SDL_bool SDL_HasSurfaceRLE(SDL_Surface *surface) { - if (surface == NULL) { + if (!surface) { return SDL_FALSE; } @@ -345,7 +345,7 @@ int SDL_SetColorKey(SDL_Surface *surface, int flag, Uint32 key) { int flags; - if (surface == NULL) { + if (!surface) { return SDL_InvalidParamError("surface"); } @@ -373,7 +373,7 @@ int SDL_SetColorKey(SDL_Surface *surface, int flag, Uint32 key) SDL_bool SDL_HasColorKey(SDL_Surface *surface) { - if (surface == NULL) { + if (!surface) { return SDL_FALSE; } @@ -406,7 +406,7 @@ static void SDL_ConvertColorkeyToAlpha(SDL_Surface *surface, SDL_bool ignore_alp { int x, y, bpp; - if (surface == NULL) { + if (!surface) { return; } @@ -517,7 +517,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"); } @@ -612,7 +612,7 @@ int SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode) return SDL_InvalidParamError("surface"); } - if (blendMode == NULL) { + if (!blendMode) { return 0; } @@ -705,7 +705,7 @@ int SDL_UpperBlit(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_UpperBlit(): src/dst"); } if (src->locked || dst->locked) { @@ -817,14 +817,14 @@ int SDL_PrivateUpperBlitScaled(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_UpperBlitScaled(): 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 { @@ -1174,7 +1174,7 @@ SDL_Surface *SDL_ConvertSurface(SDL_Surface * surface, const SDL_PixelFormat * f format->BitsPerPixel, format->Rmask, format->Gmask, format->Bmask, format->Amask); - if (convert == NULL) { + if (!convert) { return NULL; } diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 14b0f64c0ffce..44356baec9165 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -203,12 +203,12 @@ typedef struct static Uint32 SDL_DefaultGraphicsBackends(SDL_VideoDevice *_this) { #if (SDL_VIDEO_OPENGL && __MACOSX__) || (__IPHONEOS__ && !TARGET_OS_MACCATALYST) || __ANDROID__ || __NACL__ - if (_this->GL_CreateContext != NULL) { + if (_this->GL_CreateContext) { return SDL_WINDOW_OPENGL; } #endif #if SDL_VIDEO_METAL && (TARGET_OS_MACCATALYST || __MACOSX__ || __IPHONEOS__) - if (_this->Metal_CreateView != NULL) { + if (_this->Metal_CreateView) { return SDL_WINDOW_METAL; } #endif @@ -241,7 +241,7 @@ static int SDL_CreateWindowTexture(SDL_VideoDevice *_this, SDL_Window *window, U break; } } - if (renderer == NULL || (SDL_GetRendererInfo(renderer, &info) == -1)) { + if (!renderer || (SDL_GetRendererInfo(renderer, &info) == -1)) { if (renderer) { SDL_DestroyRenderer(renderer); } @@ -346,7 +346,7 @@ static int SDL_UpdateWindowTexture(SDL_VideoDevice *unused, SDL_Window *window, SDL_GetWindowSizeInPixels(window, &w, &h); data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA); - if (data == NULL || !data->texture) { + if (!data || !data->texture) { return SDL_SetError("No window texture data"); } @@ -373,7 +373,7 @@ static void SDL_DestroyWindowTexture(SDL_VideoDevice *unused, SDL_Window *window SDL_WindowTextureData *data; data = SDL_SetWindowData(window, SDL_WINDOWTEXTUREDATA, NULL); - if (data == NULL) { + if (!data) { return; } if (data->texture) { @@ -465,14 +465,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_VIDEODRIVER); } - 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) { @@ -556,7 +556,7 @@ int SDL_VideoInit(const char *driver_name) return 0; pre_driver_error: - SDL_assert(_this == NULL); + SDL_assert(!_this); if (init_touch) { SDL_TouchQuit(); } @@ -654,7 +654,7 @@ void SDL_DelVideoDisplay(int index) int SDL_GetNumVideoDisplays(void) { - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return 0; } @@ -700,7 +700,7 @@ int SDL_GetDisplayBounds(int displayIndex, SDL_Rect *rect) CHECK_DISPLAY_INDEX(displayIndex, -1); - if (rect == NULL) { + if (!rect) { return SDL_InvalidParamError("rect"); } @@ -805,7 +805,7 @@ SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode *mo modes = SDL_realloc(modes, (display->max_display_modes + 32) * sizeof(*modes)); - if (modes == NULL) { + if (!modes) { return SDL_FALSE; } display->display_modes = modes; @@ -917,7 +917,7 @@ static SDL_DisplayMode *SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay *di int i; SDL_DisplayMode *current, *match; - if (mode == NULL || closest == NULL) { + if (!mode || !closest) { SDL_InvalidParamError("mode/closest"); return NULL; } @@ -954,7 +954,7 @@ static SDL_DisplayMode *SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay *di modes may still follow. */ continue; } - if (match == NULL || current->w < match->w || current->h < match->h) { + if (!match || current->w < match->w || current->h < match->h) { match = current; continue; } @@ -1211,7 +1211,7 @@ int SDL_GetWindowDisplayIndex(SDL_Window *window) SDL_VideoDisplay *new_display = &_this->displays[displayIndex]; /* The window was moved to a different display */ - if (new_display->fullscreen_window != NULL) { + if (new_display->fullscreen_window) { /* Uh oh, there's already a fullscreen window here */ } else { new_display->fullscreen_window = window; @@ -1271,7 +1271,7 @@ int SDL_GetWindowDisplayMode(SDL_Window *window, SDL_DisplayMode *mode) CHECK_WINDOW_MAGIC(window, -1); - if (mode == NULL) { + if (!mode) { return SDL_InvalidParamError("mode"); } @@ -1403,7 +1403,7 @@ static int SDL_UpdateFullscreenMode(SDL_Window *window, SDL_bool fullscreen) #endif display = SDL_GetDisplayForWindow(window); - if (display == NULL) { /* No display connected, nothing to do. */ + if (!display) { /* No display connected, nothing to do. */ return 0; } @@ -1804,7 +1804,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; } @@ -1840,7 +1840,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; } @@ -2004,7 +2004,7 @@ int SDL_RecreateWindow(SDL_Window *window, Uint32 flags) SDL_bool SDL_HasWindows(void) { - return _this && _this->windows != NULL; + return _this && _this->windows; } Uint32 SDL_GetWindowID(SDL_Window *window) @@ -2018,7 +2018,7 @@ SDL_Window *SDL_GetWindowFromID(Uint32 id) { SDL_Window *window; - if (_this == NULL) { + if (!_this) { return NULL; } for (window = _this->windows; window; window = window->next) { @@ -2063,7 +2063,7 @@ void SDL_SetWindowIcon(SDL_Window *window, SDL_Surface *icon) { CHECK_WINDOW_MAGIC(window, ); - if (icon == NULL) { + if (!icon) { return; } @@ -2346,16 +2346,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; } @@ -2377,11 +2377,11 @@ void SDL_GetWindowSizeInPixels(SDL_Window *window, int *w, int *h) CHECK_WINDOW_MAGIC(window, ); - if (w == NULL) { + if (!w) { w = &filter; } - if (h == NULL) { + if (!h) { h = &filter; } @@ -2637,7 +2637,7 @@ static SDL_Surface *SDL_CreateWindowFramebuffer(SDL_Window *window) #if defined(__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; @@ -2645,7 +2645,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 @@ -2853,7 +2853,7 @@ int SDL_SetWindowGammaRamp(SDL_Window * window, const Uint16 * red, if (SDL_GetWindowGammaRamp(window, NULL, NULL, NULL) < 0) { return -1; } - SDL_assert(window->gamma != NULL); + SDL_assert(window->gamma); } if (red) { @@ -3180,7 +3180,7 @@ static SDL_bool 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->flags & SDL_WINDOW_FULLSCREEN_DESKTOP) == SDL_WINDOW_FULLSCREEN_DESKTOP || DisableDisplayModeSwitching(_this) == SDL_TRUE) { return SDL_FALSE; @@ -3210,7 +3210,7 @@ SDL_Window *SDL_GetFocusWindow(void) { SDL_Window *window; - if (_this == NULL) { + if (!_this) { return NULL; } for (window = _this->windows; window; window = window->next) { @@ -3312,7 +3312,7 @@ void SDL_DestroyWindow(SDL_Window *window) SDL_bool SDL_IsScreenSaverEnabled() { - if (_this == NULL) { + if (!_this) { return SDL_TRUE; } return _this->suspend_screensaver ? SDL_FALSE : SDL_TRUE; @@ -3320,7 +3320,7 @@ SDL_bool SDL_IsScreenSaverEnabled() void SDL_EnableScreenSaver() { - if (_this == NULL) { + if (!_this) { return; } if (!_this->suspend_screensaver) { @@ -3334,7 +3334,7 @@ void SDL_EnableScreenSaver() void SDL_DisableScreenSaver() { - if (_this == NULL) { + if (!_this) { return; } if (_this->suspend_screensaver) { @@ -3350,7 +3350,7 @@ void SDL_VideoQuit(void) { int i; - if (_this == NULL) { + if (!_this) { return; } @@ -3390,7 +3390,7 @@ int SDL_GL_LoadLibrary(const char *path) { int retval; - if (_this == NULL) { + if (!_this) { return SDL_UninitializedVideo(); } if (_this->gl_config.driver_loaded) { @@ -3418,7 +3418,7 @@ void *SDL_GL_GetProcAddress(const char *proc) { void *func; - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return NULL; } @@ -3480,7 +3480,7 @@ SDL_bool SDL_GL_ExtensionSupported(const char *extension) /* Lookup the available extensions */ glGetStringFunc = SDL_GL_GetProcAddress("glGetString"); - if (glGetStringFunc == NULL) { + if (!glGetStringFunc) { return SDL_FALSE; } @@ -3492,7 +3492,7 @@ SDL_bool SDL_GL_ExtensionSupported(const char *extension) glGetStringiFunc = SDL_GL_GetProcAddress("glGetStringi"); glGetIntegervFunc = SDL_GL_GetProcAddress("glGetIntegerv"); - if ((glGetStringiFunc == NULL) || (glGetIntegervFunc == NULL)) { + if ((!glGetStringiFunc) || (!glGetIntegervFunc)) { return SDL_FALSE; } @@ -3513,7 +3513,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; } /* @@ -3525,7 +3525,7 @@ SDL_bool SDL_GL_ExtensionSupported(const char *extension) for (;;) { where = SDL_strstr(start, extension); - if (where == NULL) { + if (!where) { break; } @@ -3576,7 +3576,7 @@ void SDL_GL_DeduceMaxSupportedESProfile(int *major, int *minor) void SDL_GL_ResetAttributes() { - if (_this == NULL) { + if (!_this) { return; } @@ -3633,7 +3633,7 @@ int SDL_GL_SetAttribute(SDL_GLattr attr, int value) #if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 int retval; - if (_this == NULL) { + if (!_this) { return SDL_UninitializedVideo(); } retval = 0; @@ -3771,14 +3771,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(); } @@ -3954,7 +3954,7 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) #if SDL_VIDEO_OPENGL glGetStringFunc = SDL_GL_GetProcAddress("glGetString"); - if (glGetStringFunc == NULL) { + if (!glGetStringFunc) { return -1; } @@ -3992,7 +3992,7 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) } glGetErrorFunc = SDL_GL_GetProcAddress("glGetError"); - if (glGetErrorFunc == NULL) { + if (!glGetErrorFunc) { return -1; } @@ -4039,7 +4039,7 @@ int SDL_GL_MakeCurrent(SDL_Window *window, SDL_GLContext context) { int retval; - if (_this == NULL) { + if (!_this) { return SDL_UninitializedVideo(); } @@ -4073,7 +4073,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; } @@ -4082,7 +4082,7 @@ SDL_Window *SDL_GL_GetCurrentWindow(void) SDL_GLContext SDL_GL_GetCurrentContext(void) { - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return NULL; } @@ -4102,7 +4102,7 @@ void SDL_GL_GetDrawableSize(SDL_Window * window, int *w, int *h) 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"); @@ -4148,7 +4148,7 @@ void SDL_GL_SwapWindow(SDL_Window *window) void SDL_GL_DeleteContext(SDL_GLContext context) { - if (_this == NULL || !context) { + if (!_this || !context) { return; } @@ -4428,7 +4428,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"); @@ -4443,7 +4443,7 @@ int SDL_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid) show_cursor_prev = SDL_ShowCursor(1); SDL_ResetKeyboard(); - if (buttonid == NULL) { + if (!buttonid) { buttonid = &dummybutton; } @@ -4566,10 +4566,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({ @@ -4646,7 +4646,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_WINDOWEVENT_FOCUS_LOST, 0, 0); SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MINIMIZED, 0, 0); } @@ -4670,7 +4670,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_SendWindowEvent(window, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0); SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0); } @@ -4682,7 +4682,7 @@ void SDL_OnApplicationDidBecomeActive(void) int SDL_Vulkan_LoadLibrary(const char *path) { int retval; - if (_this == NULL) { + if (!_this) { SDL_UninitializedVideo(); return -1; } @@ -4743,7 +4743,7 @@ SDL_bool SDL_Vulkan_GetInstanceExtensions(SDL_Window *window, unsigned *count, c } } - if (count == NULL) { + if (!count) { SDL_InvalidParamError("count"); return SDL_FALSE; } diff --git a/src/video/android/SDL_androidkeyboard.c b/src/video/android/SDL_androidkeyboard.c index ba652019aa32a..1d8fbb991027d 100644 --- a/src/video/android/SDL_androidkeyboard.c +++ b/src/video/android/SDL_androidkeyboard.c @@ -361,7 +361,7 @@ void Android_SetTextInputRect(_THIS, const SDL_Rect *rect) { SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; - if (rect == NULL) { + if (!rect) { SDL_InvalidParamError("rect"); return; } diff --git a/src/video/android/SDL_androidmouse.c b/src/video/android/SDL_androidmouse.c index f2079355f8d16..ddb99eb45f8b9 100644 --- a/src/video/android/SDL_androidmouse.c +++ b/src/video/android/SDL_androidmouse.c @@ -89,7 +89,7 @@ static SDL_Cursor *Android_CreateCursor(SDL_Surface *surface, int hot_x, int hot SDL_Surface *converted; converted = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888, 0); - if (converted == NULL) { + if (!converted) { return NULL; } custom_cursor = Android_JNI_CreateCustomCursor(converted, hot_x, hot_y); @@ -118,7 +118,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_CreateRGBSurfaceWithFormat(0, 1, 1, 32, SDL_PIXELFORMAT_ARGB8888); if (empty_surface) { SDL_memset(empty_surface->pixels, 0, (size_t)empty_surface->h * empty_surface->pitch); diff --git a/src/video/android/SDL_androidwindow.c b/src/video/android/SDL_androidwindow.c index 640ac044d96b8..e38ce7e23f4d7 100644 --- a/src/video/android/SDL_androidwindow.c +++ b/src/video/android/SDL_androidwindow.c @@ -132,7 +132,7 @@ void Android_SetWindowFullscreen(_THIS, SDL_Window *window, SDL_VideoDisplay *di } data = (SDL_WindowData *)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/directfb/SDL_DirectFB_WM.c b/src/video/directfb/SDL_DirectFB_WM.c index f185cac334f94..4b3fedb74b9ae 100644 --- a/src/video/directfb/SDL_DirectFB_WM.c +++ b/src/video/directfb/SDL_DirectFB_WM.c @@ -79,13 +79,13 @@ static void LoadFont(_THIS, SDL_Window * window) SDL_DFB_DEVICEDATA(_this); SDL_DFB_WINDOWDATA(window); - if (windata->font != NULL) { + if (windata->font) { SDL_DFB_RELEASE(windata->font); windata->font = NULL; SDL_DFB_CHECK(windata->window_surface->SetFont(windata->window_surface, windata->font)); } - if (windata->theme.font != NULL) + if (windata->theme.font) { DFBFontDescription fdesc; @@ -317,7 +317,7 @@ int DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt) SDL_FALLTHROUGH; default: windata->wm_grab = pos; - if (grabbed_window != NULL) + if (grabbed_window) DirectFB_SetWindowMouseGrab(_this, grabbed_window, SDL_FALSE); DirectFB_SetWindowMouseGrab(_this, window, SDL_TRUE); windata->wm_lastx = evt->cx; @@ -350,7 +350,7 @@ int DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt) } } DirectFB_SetWindowMouseGrab(_this, window, SDL_FALSE); - if (grabbed_window != NULL) + if (grabbed_window) DirectFB_SetWindowMouseGrab(_this, grabbed_window, SDL_TRUE); windata->wm_grab = WM_POS_NONE; return 1; diff --git a/src/video/directfb/SDL_DirectFB_dyn.c b/src/video/directfb/SDL_DirectFB_dyn.c index 02ed371a998be..6131d9f92367f 100644 --- a/src/video/directfb/SDL_DirectFB_dyn.c +++ b/src/video/directfb/SDL_DirectFB_dyn.c @@ -93,7 +93,7 @@ int SDL_DirectFB_LoadLibrary(void) void SDL_DirectFB_UnLoadLibrary(void) { - if (handle != NULL) { + if (handle) { SDL_UnloadObject(handle); handle = NULL; } diff --git a/src/video/directfb/SDL_DirectFB_events.c b/src/video/directfb/SDL_DirectFB_events.c index 47a8e6206365d..16d073c1d3406 100644 --- a/src/video/directfb/SDL_DirectFB_events.c +++ b/src/video/directfb/SDL_DirectFB_events.c @@ -308,7 +308,7 @@ static void ProcessInputEvent(_THIS, DFBInputEvent * ievt) if (!devdata->use_linux_input) { if (ievt->type == DIET_AXISMOTION) { - if ((grabbed_window != NULL) && (ievt->flags & DIEF_AXISREL)) { + if ((grabbed_window) && (ievt->flags & DIEF_AXISREL)) { if (ievt->axis == DIAI_X) SDL_SendMouseMotion_ex(grabbed_window, ievt->device_id, 1, ievt->axisrel, 0, 0); @@ -405,7 +405,7 @@ void DirectFB_PumpEventsWindow(_THIS) DFBInputEvent ievt; SDL_Window *w; - for (w = devdata->firstwin; w != NULL; w = w->next) { + for (w = devdata->firstwin; w; w = w->next) { SDL_DFB_WINDOWDATA(w); DFBWindowEvent evt; diff --git a/src/video/directfb/SDL_DirectFB_opengl.c b/src/video/directfb/SDL_DirectFB_opengl.c index 1c146a0e18e25..4ec2ff272f90b 100644 --- a/src/video/directfb/SDL_DirectFB_opengl.c +++ b/src/video/directfb/SDL_DirectFB_opengl.c @@ -113,15 +113,15 @@ int DirectFB_GL_LoadLibrary(_THIS, const char *path) } - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_OPENGL_LIBRARY"); - if (path == NULL) { + if (!path) { path = "libGL.so.1"; } } handle = GL_LoadObject(path); - if (handle == NULL) { + if (!handle) { SDL_DFB_ERR("Library not found: %s\n", path); /* SDL_LoadObject() will call SDL_SetError() for us. */ return -1; @@ -210,7 +210,7 @@ int DirectFB_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) } - if (ctx != NULL) { + if (ctx) { SDL_DFB_CHECKERR(ctx->context->Lock(ctx->context)); ctx->is_locked = 1; } @@ -242,7 +242,7 @@ int DirectFB_GL_SwapWindow(_THIS, SDL_Window * window) devdata->glFlush(); #endif - for (p = _this->gl_data->firstgl; p != NULL; p = p->next) + for (p = _this->gl_data->firstgl; p; p = p->next) if (p->sdl_window == window && p->is_locked) { SDL_DFB_CHECKERR(p->context->Unlock(p->context)); @@ -278,7 +278,7 @@ void DirectFB_GL_FreeWindowContexts(_THIS, SDL_Window * window) { DirectFB_GLContext *p; - for (p = _this->gl_data->firstgl; p != NULL; p = p->next) + for (p = _this->gl_data->firstgl; p; p = p->next) if (p->sdl_window == window) { if (p->is_locked) @@ -291,7 +291,7 @@ void DirectFB_GL_ReAllocWindowContexts(_THIS, SDL_Window * window) { DirectFB_GLContext *p; - for (p = _this->gl_data->firstgl; p != NULL; p = p->next) + for (p = _this->gl_data->firstgl; p; p = p->next) if (p->sdl_window == window) { SDL_DFB_WINDOWDATA(window); @@ -306,7 +306,7 @@ void DirectFB_GL_DestroyWindowContexts(_THIS, SDL_Window * window) { DirectFB_GLContext *p; - for (p = _this->gl_data->firstgl; p != NULL; p = p->next) + for (p = _this->gl_data->firstgl; p; p = p->next) if (p->sdl_window == window) DirectFB_GL_DeleteContext(_this, p); } diff --git a/src/video/directfb/SDL_DirectFB_shape.c b/src/video/directfb/SDL_DirectFB_shape.c index a6c9aa092b8fb..f3b84831f4c82 100644 --- a/src/video/directfb/SDL_DirectFB_shape.c +++ b/src/video/directfb/SDL_DirectFB_shape.c @@ -61,7 +61,7 @@ SDL_WindowShaper *DirectFB_CreateShaper(SDL_Window* window) int DirectFB_ResizeWindowShape(SDL_Window* window) { SDL_ShapeData* data = window->shaper->driverdata; - SDL_assert(data != NULL); + SDL_assert(data); if (window->x != -1000) { @@ -76,7 +76,7 @@ int DirectFB_ResizeWindowShape(SDL_Window* window) int DirectFB_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) { - if(shaper == NULL || shape == NULL || shaper->driverdata == NULL) + if(!shaper || !shape || !shaper->driverdata) return -1; if(shape->format->Amask == 0 && SDL_SHAPEMODEALPHA(shape_mode->mode)) return -2; diff --git a/src/video/dummy/SDL_nullframebuffer.c b/src/video/dummy/SDL_nullframebuffer.c index be10dd15ceb19..341957eca0524 100644 --- a/src/video/dummy/SDL_nullframebuffer.c +++ b/src/video/dummy/SDL_nullframebuffer.c @@ -39,7 +39,7 @@ int SDL_DUMMY_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, /* Create a new one */ SDL_GetWindowSizeInPixels(window, &w, &h); surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format); - if (surface == NULL) { + if (!surface) { return -1; } @@ -57,7 +57,7 @@ int SDL_DUMMY_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect SDL_Surface *surface; surface = (SDL_Surface *)SDL_GetWindowData(window, DUMMY_SURFACE); - if (surface == NULL) { + if (!surface) { return SDL_SetError("Couldn't find dummy surface for window"); } diff --git a/src/video/emscripten/SDL_emscriptenframebuffer.c b/src/video/emscripten/SDL_emscriptenframebuffer.c index 6108e045d1419..ba445fb0705c7 100644 --- a/src/video/emscripten/SDL_emscriptenframebuffer.c +++ b/src/video/emscripten/SDL_emscriptenframebuffer.c @@ -46,7 +46,7 @@ int Emscripten_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format SDL_GetWindowSizeInPixels(window, &w, &h); surface = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask); - if (surface == NULL) { + if (!surface) { return -1; } diff --git a/src/video/haiku/SDL_bclipboard.cc b/src/video/haiku/SDL_bclipboard.cc index 0fd3753217005..6166d291e3757 100644 --- a/src/video/haiku/SDL_bclipboard.cc +++ b/src/video/haiku/SDL_bclipboard.cc @@ -65,7 +65,7 @@ char *HAIKU_GetClipboardText(_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_bmessagebox.cc b/src/video/haiku/SDL_bmessagebox.cc index 60fce00789fcf..620be96037f64 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." BApplication *application = NULL; - if (be_app == NULL) { + if (!be_app) { application = 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(); @@ -381,7 +381,7 @@ int HAIKU_ShowMessageBox(const SDL_MessageBoxData *messageboxdata, int *buttonid delete messageBox; } */ - if (application != NULL) { + if (application) { delete application; } diff --git a/src/video/haiku/SDL_bvideo.cc b/src/video/haiku/SDL_bvideo.cc index 5d06bf6d115ef..7e26c1ac0d58a 100644 --- a/src/video/haiku/SDL_bvideo.cc +++ b/src/video/haiku/SDL_bvideo.cc @@ -193,7 +193,7 @@ static SDL_Cursor * HAIKU_CreateCursor(SDL_Surface * surface, int hot_x, int hot SDL_Surface *converted; converted = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888, 0); - if (converted == NULL) { + if (!converted) { return NULL; } diff --git a/src/video/kmsdrm/SDL_kmsdrmmouse.c b/src/video/kmsdrm/SDL_kmsdrmmouse.c index 950aa5b55f559..b139abe46a89e 100644 --- a/src/video/kmsdrm/SDL_kmsdrmmouse.c +++ b/src/video/kmsdrm/SDL_kmsdrmmouse.c @@ -310,13 +310,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 diff --git a/src/video/kmsdrm/SDL_kmsdrmvideo.c b/src/video/kmsdrm/SDL_kmsdrmvideo.c index 79fdcac94122f..0067980425a1c 100644 --- a/src/video/kmsdrm/SDL_kmsdrmvideo.c +++ b/src/video/kmsdrm/SDL_kmsdrmvideo.c @@ -1580,7 +1580,7 @@ int KMSDRM_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) SDL_VideoDisplay *disp = SDL_GetDisplayForWindow(window); SDL_DisplayData* dispdata = (SDL_DisplayData*)disp->driverdata; Uint16* tempRamp = SDL_calloc(3 * sizeof(Uint16), 256); - if (tempRamp == NULL) + if (!tempRamp) { return SDL_OutOfMemory(); } diff --git a/src/video/n3ds/SDL_n3dsframebuffer.c b/src/video/n3ds/SDL_n3dsframebuffer.c index 3e3e46946af90..dd343811c1e88 100644 --- a/src/video/n3ds/SDL_n3dsframebuffer.c +++ b/src/video/n3ds/SDL_n3dsframebuffer.c @@ -84,7 +84,7 @@ int SDL_N3DS_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_Rect * u32 bufsize; surface = (SDL_Surface *)SDL_GetWindowData(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 2599ad612d8d5..09b4c0e80710b 100644 --- a/src/video/n3ds/SDL_n3dsvideo.c +++ b/src/video/n3ds/SDL_n3dsvideo.c @@ -108,7 +108,7 @@ AddN3DSDisplay(gfxScreen_t screen) SDL_DisplayMode mode; SDL_VideoDisplay display; DisplayDriverData *display_driver_data = SDL_calloc(1, sizeof(DisplayDriverData)); - if (display_driver_data == NULL) { + if (!display_driver_data) { SDL_OutOfMemory(); return; } @@ -150,7 +150,7 @@ static void N3DS_GetDisplayModes(_THIS, SDL_VideoDisplay *display) static int N3DS_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) { DisplayDriverData *driver_data = (DisplayDriverData *)display->driverdata; - if (driver_data == NULL) { + if (!driver_data) { return -1; } rect->x = 0; diff --git a/src/video/ngage/SDL_ngageframebuffer.cpp b/src/video/ngage/SDL_ngageframebuffer.cpp index a2be053b1bb7a..af170ea73d44f 100644 --- a/src/video/ngage/SDL_ngageframebuffer.cpp +++ b/src/video/ngage/SDL_ngageframebuffer.cpp @@ -57,7 +57,7 @@ int SDL_NGAGE_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *format, /* Create a new one */ SDL_GetWindowSizeInPixels(window, &w, &h); surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format); - if (surface == NULL) { + if (!surface) { return -1; } diff --git a/src/video/offscreen/SDL_offscreenframebuffer.c b/src/video/offscreen/SDL_offscreenframebuffer.c index 4e27c72501779..6fa04d6e82eb8 100644 --- a/src/video/offscreen/SDL_offscreenframebuffer.c +++ b/src/video/offscreen/SDL_offscreenframebuffer.c @@ -39,7 +39,7 @@ int SDL_OFFSCREEN_CreateWindowFramebuffer(_THIS, SDL_Window *window, Uint32 *for /* Create a new one */ SDL_GetWindowSizeInPixels(window, &w, &h); surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 0, surface_format); - if (surface == NULL) { + if (!surface) { return -1; } @@ -58,7 +58,7 @@ int SDL_OFFSCREEN_UpdateWindowFramebuffer(_THIS, SDL_Window *window, const SDL_R SDL_Surface *surface; surface = (SDL_Surface *)SDL_GetWindowData(window, OFFSCREEN_SURFACE); - if (surface == NULL) { + if (!surface) { return SDL_SetError("Couldn't find offscreen surface for window"); } diff --git a/src/video/os2/SDL_os2dive.c b/src/video/os2/SDL_os2dive.c index 1b3eb13ba49c6..4a214f968a774 100644 --- a/src/video/os2/SDL_os2dive.c +++ b/src/video/os2/SDL_os2dive.c @@ -101,7 +101,7 @@ PVODATA voOpen(void) { PVODATA pVOData = SDL_calloc(1, sizeof(VODATA)); - if (pVOData == NULL) { + if (!pVOData) { SDL_OutOfMemory(); return NULL; } @@ -277,7 +277,7 @@ static VOID voVideoBufFree(PVODATA pVOData) pVOData->ulDIVEBufNum = 0; } - if (pVOData->pBuffer != NULL) { + if (pVOData->pBuffer) { ulRC = DosFreeMem(pVOData->pBuffer); if (ulRC != NO_ERROR) { debug_os2("DosFreeMem(), rc = %u", ulRC); @@ -296,11 +296,11 @@ static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects, return FALSE; } - if (pSDLRects != NULL) { + if (pSDLRects) { PBYTE pbLineMask; pbLineMask = SDL_stack_alloc(BYTE, pVOData->ulHeight); - if (pbLineMask == NULL) { + if (!pbLineMask) { debug_os2("Not enough stack size"); return FALSE; } diff --git a/src/video/os2/SDL_os2messagebox.c b/src/video/os2/SDL_os2messagebox.c index 83ac8775e7c04..075ae8a1ddcae 100644 --- a/src/video/os2/SDL_os2messagebox.c +++ b/src/video/os2/SDL_os2messagebox.c @@ -206,9 +206,9 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata) ULONG cSDLBtnData = messageboxdata->numbuttons; PSZ pszTitle = OS2_UTF8ToSys(messageboxdata->title); - ULONG cbTitle = (pszTitle == NULL)? 1 : (SDL_strlen(pszTitle) + 1); + ULONG cbTitle = (!pszTitle)? 1 : (SDL_strlen(pszTitle) + 1); PSZ pszText = OS2_UTF8ToSys(messageboxdata->message); - ULONG cbText = (pszText == NULL)? 1 : (SDL_strlen(pszText) + 1); + ULONG cbText = (!pszText)? 1 : (SDL_strlen(pszText) + 1); PDLGTEMPLATE pTemplate; ULONG cbTemplate; @@ -219,7 +219,7 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata) ULONG cbBtnText; HWND hwnd; - const SDL_MessageBoxColor* pSDLColors = (messageboxdata->colorScheme == NULL)? + const SDL_MessageBoxColor* pSDLColors = (!messageboxdata->colorScheme)? NULL : messageboxdata->colorScheme->colors; const SDL_MessageBoxColor* pSDLColor; @@ -237,11 +237,11 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata) /* Button items datas - text for buttons. */ for (ulIdx = 0; ulIdx < cSDLBtnData; ulIdx++) { pszBtnText = (PSZ)pSDLBtnData[ulIdx].text; - cbTemplate += (pszBtnText == NULL)? 1 : (SDL_strlen(pszBtnText) + 1); + cbTemplate += (!pszBtnText)? 1 : (SDL_strlen(pszBtnText) + 1); } /* Presentation parameter space. */ - if (pSDLColors != NULL) { + if (pSDLColors) { cbTemplate += 26 /* PP for frame. */ + 26 /* PP for static text. */ + (48 * cSDLBtnData); /* PP for buttons. */ @@ -291,7 +291,7 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata) pDlgItem->cx = 175; pDlgItem->cy = 65; pDlgItem->id = DID_OK; /* An ID value? */ - if (pSDLColors == NULL) + if (!pSDLColors) pDlgItem->offPresParams = 0; else { /* Presentation parameter for the frame - dialog colors. */ @@ -346,7 +346,7 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata) pDlgItem->cy = 62; /* It will be used. */ pDlgItem->id = IDD_TEXT_MESSAGE; /* an ID value */ - if (pSDLColors == NULL) + if (!pSDLColors) pDlgItem->offPresParams = 0; else { /* Presentation parameter for the static text - dialog colors. */ @@ -407,7 +407,7 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata) pDlgItem->offClassName = (USHORT)WC_BUTTON; pszBtnText = OS2_UTF8ToSys(pSDLBtnData[ulIdx].text); - cbBtnText = (pszBtnText == NULL)? 1 : (SDL_strlen(pszBtnText) + 1); + cbBtnText = (!pszBtnText)? 1 : (SDL_strlen(pszBtnText) + 1); pDlgItem->cchText = cbBtnText; pDlgItem->offText = pcDlgData - (PCHAR)pTemplate; /* Offset to the text. */ /* Copy text for the button into the dialog template. */ @@ -435,7 +435,7 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata) pDlgItem->cy = 15; pDlgItem->id = IDD_PB_FIRST + ulIdx; /* an ID value */ - if (pSDLColors == NULL) + if (!pSDLColors) pDlgItem->offPresParams = 0; else { /* Presentation parameter for the button - dialog colors. */ @@ -473,7 +473,7 @@ static HWND _makeDlg(const SDL_MessageBoxData *messageboxdata) /* Create the dialog from template. */ stDlgData.cb = sizeof(MSGBOXDLGDATA); - stDlgData.hwndUnder = (messageboxdata->window != NULL && messageboxdata->window->driverdata != NULL)? + stDlgData.hwndUnder = (messageboxdata->window && messageboxdata->window->driverdata)? ((WINDATA *)messageboxdata->window->driverdata)->hwnd : HWND_DESKTOP; hwnd = WinCreateDlg(HWND_DESKTOP, /* Parent is desktop. */ diff --git a/src/video/os2/SDL_os2mouse.c b/src/video/os2/SDL_os2mouse.c index 3ffdef917cdde..18468801d4ae2 100644 --- a/src/video/os2/SDL_os2mouse.c +++ b/src/video/os2/SDL_os2mouse.c @@ -46,7 +46,7 @@ static SDL_Cursor* OS2_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y) return NULL; pSDLCursor = SDL_calloc(1, sizeof(SDL_Cursor)); - if (pSDLCursor == NULL) { + if (!pSDLCursor) { WinDestroyPointer(hptr); SDL_OutOfMemory(); return NULL; @@ -91,7 +91,7 @@ static SDL_Cursor* OS2_CreateSystemCursor(SDL_SystemCursor id) } pSDLCursor = SDL_calloc(1, sizeof(SDL_Cursor)); - if (pSDLCursor == NULL) { + if (!pSDLCursor) { WinDestroyPointer(hptr); SDL_OutOfMemory(); return NULL; @@ -111,7 +111,7 @@ static void OS2_FreeCursor(SDL_Cursor *cursor) static int OS2_ShowCursor(SDL_Cursor *cursor) { - hptrCursor = (cursor != NULL)? (HPOINTER)cursor->driverdata : NULLHANDLE; + hptrCursor = (cursor)? (HPOINTER)cursor->driverdata : NULLHANDLE; return ((SDL_GetMouseFocus() == NULL) || WinSetPointer(HWND_DESKTOP, hptrCursor))? 0 : -1; } @@ -137,7 +137,7 @@ static int OS2_WarpMouseGlobal(int x, int y) static int OS2_CaptureMouse(SDL_Window *window) { - return WinSetCapture(HWND_DESKTOP, (window == NULL)? NULLHANDLE : + return WinSetCapture(HWND_DESKTOP, (!window)? NULLHANDLE : ((WINDATA *)window->driverdata)->hwnd)? 0 : -1; } @@ -182,7 +182,7 @@ void OS2_QuitMouse(_THIS) { SDL_Mouse *pSDLMouse = SDL_GetMouse(); - if (pSDLMouse->def_cursor != NULL) { + if (pSDLMouse->def_cursor) { SDL_free(pSDLMouse->def_cursor); pSDLMouse->def_cursor = NULL; pSDLMouse->cur_cursor = NULL; diff --git a/src/video/os2/SDL_os2util.c b/src/video/os2/SDL_os2util.c index e6a306fbf501f..86541c5cf11f9 100644 --- a/src/video/os2/SDL_os2util.c +++ b/src/video/os2/SDL_os2util.c @@ -41,7 +41,7 @@ HPOINTER utilCreatePointer(SDL_Surface *surface, ULONG ulHotX, ULONG ulHotY) } pulBitmap = (PULONG) SDL_malloc(surface->h * surface->w * 2 * sizeof(ULONG)); - if (pulBitmap == NULL) { + if (!pulBitmap) { SDL_OutOfMemory(); return NULLHANDLE; } diff --git a/src/video/os2/SDL_os2video.c b/src/video/os2/SDL_os2video.c index 1fdd2c64f746e..7c8462005aabc 100644 --- a/src/video/os2/SDL_os2video.c +++ b/src/video/os2/SDL_os2video.c @@ -171,7 +171,7 @@ static SDL_DisplayMode *_getDisplayModeForSDLWindow(SDL_Window *window) { SDL_VideoDisplay *pSDLDisplay = SDL_GetDisplayForWindow(window); - if (pSDLDisplay == NULL) { + if (!pSDLDisplay) { debug_os2("No display for the window"); return FALSE; } @@ -201,19 +201,19 @@ static VOID _setVisibleRegion(WINDATA *pWinData, BOOL fVisible) { SDL_VideoDisplay *pSDLDisplay; - if (! pWinData->pVOData) + if (!pWinData->pVOData) return; pSDLDisplay = (fVisible)? SDL_GetDisplayForWindow(pWinData->window) : NULL; pWinData->pOutput->SetVisibleRegion(pWinData->pVOData, pWinData->hwnd, - (pSDLDisplay == NULL) ? - NULL : &pSDLDisplay->current_mode, + (!pSDLDisplay) ? + NULL : &pSDLDisplay->current_mode, pWinData->hrgnShape, fVisible); } static VOID _wmPaint(WINDATA *pWinData, HWND hwnd) { - if (pWinData->pVOData == NULL || + if (!pWinData->pVOData || !pWinData->pOutput->Update(pWinData->pVOData, hwnd, NULL, 0)) { RECTL rectl; HPS hps; @@ -438,7 +438,7 @@ static MRESULT EXPENTRY wndFrameProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp HWND hwndClient = WinQueryWindow(hwnd, QW_BOTTOM); WINDATA * pWinData = (WINDATA *)WinQueryWindowULong(hwndClient, 0); - if (pWinData == NULL) + if (!pWinData) return WinDefWindowProc(hwnd, msg, mp1, mp2); /* Send a SDL_SYSWMEVENT if the application wants them */ @@ -544,7 +544,7 @@ static MRESULT EXPENTRY wndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { WINDATA *pWinData = (WINDATA *)WinQueryWindowULong(hwnd, 0); - if (pWinData == NULL) + if (!pWinData) return WinDefWindowProc(hwnd, msg, mp1, mp2); /* Send a SDL_SYSWMEVENT if the application wants them */ @@ -565,7 +565,7 @@ static MRESULT EXPENTRY wndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) case WM_CLOSE: case WM_QUIT: SDL_SendWindowEvent(pWinData->window, SDL_WINDOWEVENT_CLOSE, 0, 0); - if (pWinData->fnUserWndProc == NULL) + if (!pWinData->fnUserWndProc) return (MRESULT)FALSE; break; @@ -642,7 +642,7 @@ static MRESULT EXPENTRY wndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) case WM_TRANSLATEACCEL: /* ALT and acceleration keys not allowed (must be processed in WM_CHAR) */ - if (mp1 == NULL || ((PQMSG)mp1)->msg != WM_CHAR) + if (!mp1 || ((PQMSG)mp1)->msg != WM_CHAR) break; return (MRESULT)FALSE; @@ -690,7 +690,7 @@ static MRESULT EXPENTRY wndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) return _wmDrop(pWinData, (PDRAGINFO)PVOIDFROMMP(mp1)); } - return (pWinData->fnUserWndProc != NULL)? + return (pWinData->fnUserWndProc)? pWinData->fnUserWndProc(hwnd, msg, mp1, mp2) : WinDefWindowProc(hwnd, msg, mp1, mp2); } @@ -715,7 +715,7 @@ static WINDATA *_setupWindow(_THIS, SDL_Window *window, HWND hwndFrame, SDL_VideoData *pVData = (SDL_VideoData *)_this->driverdata; WINDATA *pWinData = SDL_calloc(1, sizeof(WINDATA)); - if (pWinData == NULL) { + if (!pWinData) { SDL_OutOfMemory(); return NULL; } @@ -745,7 +745,7 @@ static int OS2_CreateWindow(_THIS, SDL_Window *window) ULONG ulSWPFlags = SWP_SIZE | SWP_SHOW | SWP_ZORDER | SWP_ACTIVATE; WINDATA *pWinData; - if (pSDLDisplayMode == NULL) + if (!pSDLDisplayMode) return -1; /* Create a PM window */ @@ -766,7 +766,7 @@ static int OS2_CreateWindow(_THIS, SDL_Window *window) /* Setup window data and frame window procedure */ pWinData = _setupWindow(_this, window, hwndFrame, hwnd); - if (pWinData == NULL) { + if (!pWinData) { WinDestroyWindow(hwndFrame); return -1; } @@ -809,7 +809,7 @@ static int OS2_CreateWindowFrom(_THIS, SDL_Window *window, const void *data) POINTL pointl; debug_os2("Enter"); - if (pSDLDisplayMode == NULL) + if (!pSDLDisplayMode) return -1; /* User can accept client OR frame window handle. @@ -892,7 +892,7 @@ static int OS2_CreateWindowFrom(_THIS, SDL_Window *window, const void *data) /* Setup window data and frame window procedure */ pWinData = _setupWindow(_this, window, hwndFrame, hwnd); - if (pWinData == NULL) { + if (!pWinData) { SDL_free(window->title); window->title = NULL; return -1; @@ -911,7 +911,7 @@ static void OS2_DestroyWindow(_THIS, SDL_Window * window) WINDATA *pWinData = (WINDATA *)window->driverdata; debug_os2("Enter"); - if (pWinData == NULL) + if (!pWinData) return; if (pWinData->hrgnShape != NULLHANDLE) { @@ -925,7 +925,7 @@ static void OS2_DestroyWindow(_THIS, SDL_Window * window) window->shaper = NULL; } - if (pWinData->fnUserWndProc == NULL) { + if (!pWinData->fnUserWndProc) { /* Window was created by SDL (OS2_CreateWindow()), * not by user (OS2_CreateWindowFrom()) */ WinDestroyWindow(pWinData->hwndFrame); @@ -933,7 +933,7 @@ static void OS2_DestroyWindow(_THIS, SDL_Window * window) WinSetWindowULong(pWinData->hwnd, 0, 0); } - if ((pVData != NULL) && (pWinData->pVOData != NULL)) { + if ((pVData) && (pWinData->pVOData)) { pVData->pOutput->Close(pWinData->pVOData); pWinData->pVOData = NULL; } @@ -949,7 +949,7 @@ static void OS2_DestroyWindow(_THIS, SDL_Window * window) static void OS2_SetWindowTitle(_THIS, SDL_Window *window) { - PSZ pszTitle = (window->title == NULL)? NULL : OS2_UTF8ToSys(window->title); + PSZ pszTitle = (!window->title)? NULL : OS2_UTF8ToSys(window->title); WinSetWindowText(((WINDATA *)window->driverdata)->hwndFrame, pszTitle); SDL_free(pszTitle); @@ -982,7 +982,7 @@ static void OS2_SetWindowPosition(_THIS, SDL_Window *window) SDL_DisplayMode *pSDLDisplayMode = _getDisplayModeForSDLWindow(window); debug_os2("Enter"); - if (pSDLDisplayMode == NULL) + if (!pSDLDisplayMode) return; rectl.xLeft = 0; @@ -1102,7 +1102,7 @@ static void OS2_SetWindowFullscreen(_THIS, SDL_Window *window, debug_os2("Enter, fullscreen: %u", fullscreen); - if (pSDLDisplayMode == NULL) + if (!pSDLDisplayMode) return; if (SDL_ShouldAllowTopmost() && @@ -1189,7 +1189,7 @@ static void _combineRectRegions(SDL_ShapeTree *node, void *closure) /* Expand rectangles list */ if ((pShapeRects->cRects & 0x0F) == 0) { pRect = SDL_realloc(pShapeRects->pRects, (pShapeRects->cRects + 0x10) * sizeof(RECTL)); - if (pRect == NULL) + if (!pRect) return; pShapeRects->pRects = pRect; } @@ -1235,13 +1235,13 @@ static int OS2_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, HPS hps; debug_os2("Enter"); - if (shaper == NULL || shape == NULL || + if (!shaper || !shape || (shape->format->Amask == 0 && shape_mode->mode != ShapeModeColorKey) || shape->w != shaper->window->w || shape->h != shaper->window->h) { return SDL_INVALID_SHAPE_ARGUMENT; } - if (shaper->driverdata != NULL) + if (shaper->driverdata) SDL_FreeShapeTree((SDL_ShapeTree **)&shaper->driverdata); pShapeTree = SDL_CalculateShapeTree(*shape_mode, shape); @@ -1257,7 +1257,7 @@ static int OS2_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, if (pWinData->hrgnShape != NULLHANDLE) GpiDestroyRegion(hps, pWinData->hrgnShape); - pWinData->hrgnShape = (stShapeRects.pRects == NULL) ? NULLHANDLE : + pWinData->hrgnShape = (!stShapeRects.pRects) ? NULLHANDLE : GpiCreateRegion(hps, stShapeRects.cRects, stShapeRects.pRects); WinReleasePS(hps); @@ -1270,11 +1270,11 @@ static int OS2_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, static int OS2_ResizeWindowShape(SDL_Window *window) { debug_os2("Enter"); - if (window == NULL) + if (!window) return -1; if (window->x != -1000) { - if (window->shaper->driverdata != NULL) + if (window->shaper->driverdata) SDL_FreeShapeTree((SDL_ShapeTree **)window->shaper->driverdata); if (window->shaper->hasshape == SDL_TRUE) { @@ -1295,7 +1295,7 @@ static void OS2_DestroyWindowFramebuffer(_THIS, SDL_Window *window) WINDATA *pWinData = (WINDATA *)window->driverdata; debug_os2("Enter"); - if (pWinData != NULL && pWinData->pVOData != NULL) + if (pWinData && pWinData->pVOData) pWinData->pOutput->VideoBufFree(pWinData->pVOData); } @@ -1310,14 +1310,14 @@ static int OS2_CreateWindowFramebuffer(_THIS, SDL_Window *window, ULONG ulWidth, ulHeight; debug_os2("Enter"); - if (pSDLDisplay == NULL) { + if (!pSDLDisplay) { debug_os2("No display for the window"); return -1; } pSDLDisplayMode = &pSDLDisplay->current_mode; pModeData = (MODEDATA *)pSDLDisplayMode->driverdata; - if (pModeData == NULL) + if (!pModeData) return SDL_SetError("No mode data for the display"); SDL_GetWindowSize(window, (int *)&ulWidth, (int *)&ulHeight); @@ -1326,7 +1326,7 @@ static int OS2_CreateWindowFramebuffer(_THIS, SDL_Window *window, *pixels = pWinData->pOutput->VideoBufAlloc( pWinData->pVOData, ulWidth, ulHeight, pModeData->ulDepth, pModeData->fccColorEncoding, (PULONG)pitch); - if (*pixels == NULL) + if (!*pixels) return -1; *format = pSDLDisplayMode->format; @@ -1353,13 +1353,13 @@ static int OS2_SetClipboardText(_THIS, const char *text) { SDL_VideoData *pVData = (SDL_VideoData *)_this->driverdata; PSZ pszClipboard; - PSZ pszText = (text == NULL)? NULL : OS2_UTF8ToSys(text); + PSZ pszText = (!text)? NULL : OS2_UTF8ToSys(text); ULONG cbText; ULONG ulRC; BOOL fSuccess; debug_os2("Enter"); - if (pszText == NULL) + if (!pszText) return -1; cbText = SDL_strlen(pszText) + 1; @@ -1408,7 +1408,7 @@ static char *OS2_GetClipboardText(_THIS) WinCloseClipbrd(pVData->hab); } - return (pszClipboard == NULL) ? SDL_strdup("") : pszClipboard; + return (!pszClipboard) ? SDL_strdup("") : pszClipboard; } static SDL_bool OS2_HasClipboardText(_THIS) @@ -1438,7 +1438,7 @@ static int OS2_VideoInit(_THIS) /* Create SDL video driver private data */ pVData = SDL_calloc(1, sizeof(SDL_VideoData)); - if (pVData == NULL) + if (!pVData) return SDL_OutOfMemory(); /* Change process type code for use Win* API from VIO session */ @@ -1493,7 +1493,7 @@ static int OS2_VideoInit(_THIS) stSDLDisplayMode.driverdata = NULL; pModeData = SDL_malloc(sizeof(MODEDATA)); - if (pModeData != NULL) { + if (pModeData) { pModeData->ulDepth = stVOInfo.ulBPP; pModeData->fccColorEncoding = stVOInfo.fccColorEncoding; pModeData->ulScanLineBytes = stVOInfo.ulScanLineSize; @@ -1507,7 +1507,7 @@ static int OS2_VideoInit(_THIS) stSDLDisplay.num_display_modes = 0; pDisplayData = SDL_malloc(sizeof(DISPLAYDATA)); - if (pDisplayData != NULL) { + if (pDisplayData) { HPS hps = WinGetPS(HWND_DESKTOP); HDC hdc = GpiQueryDevice(hps); @@ -1566,14 +1566,14 @@ static int OS2_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi, DISPLAYDATA *pDisplayData = (DISPLAYDATA *)display->driverdata; debug_os2("Enter"); - if (pDisplayData == NULL) + if (!pDisplayData) return -1; - if (ddpi != NULL) + if (ddpi) *hdpi = pDisplayData->ulDPIDiag; - if (hdpi != NULL) + if (hdpi) *hdpi = pDisplayData->ulDPIHor; - if (vdpi != NULL) + if (vdpi) *vdpi = pDisplayData->ulDPIVer; return 0; diff --git a/src/video/os2/SDL_os2vman.c b/src/video/os2/SDL_os2vman.c index 00ae4bca2cd68..ee0b5087bc499 100644 --- a/src/video/os2/SDL_os2vman.c +++ b/src/video/os2/SDL_os2vman.c @@ -143,7 +143,7 @@ static PRECTL _getRectlArray(PVODATA pVOData, ULONG cRects) return pVOData->pRectl; pRectl = SDL_realloc(pVOData->pRectl, cRects * sizeof(RECTL)); - if (pRectl == NULL) + if (!pRectl) return NULL; pVOData->pRectl = pRectl; @@ -159,7 +159,7 @@ static PBLTRECT _getBltRectArray(PVODATA pVOData, ULONG cRects) return pVOData->pBltRect; pBltRect = SDL_realloc(pVOData->pBltRect, cRects * sizeof(BLTRECT)); - if (pBltRect == NULL) + if (!pBltRect) return NULL; pVOData->pBltRect = pBltRect; @@ -200,7 +200,7 @@ static PVODATA voOpen(void) return NULL; pVOData = SDL_calloc(1, sizeof(VODATA)); - if (pVOData == NULL) { + if (!pVOData) { SDL_OutOfMemory(); return NULL; } @@ -210,10 +210,10 @@ static PVODATA voOpen(void) static VOID voClose(PVODATA pVOData) { - if (pVOData->pRectl != NULL) + if (pVOData->pRectl) SDL_free(pVOData->pRectl); - if (pVOData->pBltRect != NULL) + if (pVOData->pBltRect) SDL_free(pVOData->pBltRect); voVideoBufFree(pVOData); @@ -253,7 +253,7 @@ static BOOL voSetVisibleRegion(PVODATA pVOData, HWND hwnd, WinQueryWindowRect(hwnd, &pVOData->rectlWin); WinMapWindowPoints(hwnd, HWND_DESKTOP, (PPOINTL)&pVOData->rectlWin, 2); - if (pSDLDisplayMode != NULL) { + if (pSDLDisplayMode) { pVOData->ulScreenHeight = pSDLDisplayMode->h; pVOData->ulScreenBytesPerLine = ((MODEDATA *)pSDLDisplayMode->driverdata)->ulScanLineBytes; @@ -302,7 +302,7 @@ static VOID voVideoBufFree(PVODATA pVOData) { ULONG ulRC; - if (pVOData->pBuffer == NULL) + if (!pVOData->pBuffer) return; ulRC = DosFreeMem(pVOData->pBuffer); @@ -329,7 +329,7 @@ static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects, BITBLTINFO sBitbltInfo; ULONG ulIdx; - if (pVOData->pBuffer == NULL) + if (!pVOData->pBuffer) return FALSE; if (pVOData->hrgnVisible == NULLHANDLE) @@ -366,7 +366,7 @@ static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects, /* Make list of destination rectangles (prectlDst) list from the source * list (prectl). */ prectlDst = _getRectlArray(pVOData, cSDLRects); - if (prectlDst == NULL) { + if (!prectlDst) { debug_os2("Not enough memory"); return FALSE; } @@ -400,7 +400,7 @@ static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects, } /* We don't need prectlDst, use it again to store update regions */ prectlDst = _getRectlArray(pVOData, rgnCtl.crcReturned); - if (prectlDst == NULL) { + if (!prectlDst) { debug_os2("Not enough memory"); GpiDestroyRegion(hps, hrgnUpdate); WinReleasePS(hps); @@ -418,7 +418,7 @@ static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects, /* Make lists for blitting from update regions */ pbrDst = _getBltRectArray(pVOData, cSDLRects); - if (pbrDst == NULL) { + if (!pbrDst) { debug_os2("Not enough memory"); return FALSE; } diff --git a/src/video/pandora/SDL_pandora.c b/src/video/pandora/SDL_pandora.c index 16debcb13b563..5b1498aa1f2a0 100644 --- a/src/video/pandora/SDL_pandora.c +++ b/src/video/pandora/SDL_pandora.c @@ -48,7 +48,7 @@ static int PND_available(void) static void PND_destroy(SDL_VideoDevice * device) { - if (device->driverdata != NULL) { + if (device->driverdata) { SDL_free(device->driverdata); device->driverdata = NULL; } @@ -70,14 +70,14 @@ static SDL_VideoDevice *PND_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 Pandora specific data */ phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); - if (phdata == NULL) { + if (!phdata) { SDL_OutOfMemory(); SDL_free(device); return NULL; @@ -196,7 +196,7 @@ int PND_createwindow(_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(); } @@ -297,15 +297,15 @@ SDL_bool PND_getwindowwminfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *i int PND_gl_loadlibrary(_THIS, const char *path) { /* Check if OpenGL ES library is specified for GF driver */ - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_OPENGL_LIBRARY"); - if (path == NULL) { + if (!path) { path = SDL_getenv("SDL_OPENGLES_LIBRARY"); } } /* Check if default library loading requested */ - if (path == NULL) { + if (!path) { /* Already linked with GF library which provides egl* subset of */ /* functions, use Common profile of OpenGL ES library by default */ #ifdef WIZ_GLES_LITE @@ -336,7 +336,7 @@ void *PND_gl_getprocaddres(_THIS, const char *proc) /* Try to get function address through the egl interface */ function_address = eglGetProcAddress(proc); - if (function_address != NULL) { + if (function_address) { return function_address; } @@ -344,7 +344,7 @@ void *PND_gl_getprocaddres(_THIS, const char *proc) if (_this->gl_config.dll_handle) { function_address = SDL_LoadFunction(_this->gl_config.dll_handle, proc); - if (function_address != NULL) { + if (function_address) { return function_address; } } @@ -586,7 +586,7 @@ SDL_GLContext PND_gl_createcontext(_THIS, SDL_Window * window) } #ifdef WIZ_GLES_LITE - if( !hNativeWnd ) { + if(!hNativeWnd) { hNativeWnd = (NativeWindowType)SDL_malloc(16*1024); if(!hNativeWnd) @@ -683,7 +683,7 @@ int PND_gl_makecurrent(_THIS, SDL_Window * window, SDL_GLContext context) return SDL_SetError("PND: GF initialization failed, no OpenGL ES support"); } - if ((window == NULL) && (context == NULL)) { + if ((!window) && (!context)) { status = eglMakeCurrent(phdata->egl_display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); diff --git a/src/video/psp/SDL_pspvideo.c b/src/video/psp/SDL_pspvideo.c index ffca3f82b753d..110ca76757e69 100644 --- a/src/video/psp/SDL_pspvideo.c +++ b/src/video/psp/SDL_pspvideo.c @@ -46,7 +46,7 @@ static void PSP_Destroy(SDL_VideoDevice *device) { /* SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; */ - if (device->driverdata != NULL) { + if (device->driverdata) { device->driverdata = NULL; } } diff --git a/src/video/qnx/gl.c b/src/video/qnx/gl.c index cf487ed464809..e6e999a60712b 100644 --- a/src/video/qnx/gl.c +++ b/src/video/qnx/gl.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/video.c b/src/video/qnx/video.c index cecd717d5b4d8..621236b9e55c4 100644 --- a/src/video/qnx/video.c +++ b/src/video/qnx/video.c @@ -74,7 +74,7 @@ static int createWindow(_THIS, SDL_Window *window) int usage; impl = SDL_calloc(1, sizeof(*impl)); - if (impl == NULL) { + if (!impl) { return -1; } @@ -311,7 +311,7 @@ static SDL_VideoDevice *createDevice(int devindex) 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 b0a884bc9941e..b14235d0dd368 100644 --- a/src/video/raspberry/SDL_rpimouse.c +++ b/src/video/raspberry/SDL_rpimouse.c @@ -139,26 +139,26 @@ 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; } display = SDL_GetDisplayForWindow(mouse->focus); - if (display == NULL) { + if (!display) { return -1; } data = (SDL_DisplayData *)display->driverdata; - if (data == NULL) { + if (!data) { return -1; } diff --git a/src/video/riscos/SDL_riscosmodes.c b/src/video/riscos/SDL_riscosmodes.c index 7e70611d0c953..2a6d6b3f6213f 100644 --- a/src/video/riscos/SDL_riscosmodes.c +++ b/src/video/riscos/SDL_riscosmodes.c @@ -237,13 +237,13 @@ void RISCOS_GetDisplayModes(_THIS, SDL_VideoDisplay *display) regs.r[6] = 0; regs.r[7] = 0; error = _kernel_swi(OS_ScreenMode, ®s, ®s); - if (error != NULL) { + if (error) { SDL_SetError("Unable to enumerate screen modes: %s (%i)", error->errmess, error->errnum); return; } block = SDL_malloc(-regs.r[7]); - if (block == NULL) { + if (!block) { SDL_OutOfMemory(); return; } @@ -251,7 +251,7 @@ void RISCOS_GetDisplayModes(_THIS, SDL_VideoDisplay *display) 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); SDL_SetError("Unable to enumerate screen modes: %s (%i)", error->errmess, error->errnum); return; diff --git a/src/video/vivante/SDL_vivantevideo.c b/src/video/vivante/SDL_vivantevideo.c index c253143f7bb92..b1e6127bab525 100644 --- a/src/video/vivante/SDL_vivantevideo.c +++ b/src/video/vivante/SDL_vivantevideo.c @@ -41,7 +41,7 @@ static void VIVANTE_Destroy(SDL_VideoDevice *device) { - if (device->driverdata != NULL) { + if (device->driverdata) { SDL_free(device->driverdata); device->driverdata = NULL; } diff --git a/src/video/wayland/SDL_waylandclipboard.c b/src/video/wayland/SDL_waylandclipboard.c index bf4dca44a0f0d..d643a51efca5e 100644 --- a/src/video/wayland/SDL_waylandclipboard.c +++ b/src/video/wayland/SDL_waylandclipboard.c @@ -33,11 +33,11 @@ int Wayland_SetClipboardText(_THIS, const char *text) int status = 0; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { status = SDL_SetError("Video driver uninitialized"); } else { video_data = _this->driverdata; - 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 (text[0] != '\0') { SDL_WaylandDataSource *source = Wayland_data_source_create(_this); @@ -64,11 +64,11 @@ int Wayland_SetPrimarySelectionText(_THIS, const char *text) int status = 0; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { status = SDL_SetError("Video driver uninitialized"); } else { video_data = _this->driverdata; - 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); @@ -97,11 +97,11 @@ char *Wayland_GetClipboardText(_THIS) char *text = NULL; size_t length = 0; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { SDL_SetError("Video driver uninitialized"); } else { video_data = _this->driverdata; - 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; /* Prefer own selection, if not canceled */ if (Wayland_data_source_has_mime( @@ -116,7 +116,7 @@ char *Wayland_GetClipboardText(_THIS) } } - if (text == NULL) { + if (!text) { text = SDL_strdup(""); } @@ -131,11 +131,11 @@ char *Wayland_GetPrimarySelectionText(_THIS) char *text = NULL; size_t length = 0; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { SDL_SetError("Video driver uninitialized"); } else { video_data = _this->driverdata; - 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; /* Prefer own selection, if not canceled */ if (Wayland_primary_selection_source_has_mime( @@ -150,7 +150,7 @@ char *Wayland_GetPrimarySelectionText(_THIS) } } - if (text == NULL) { + if (!text) { text = SDL_strdup(""); } @@ -163,11 +163,11 @@ SDL_bool Wayland_HasClipboardText(_THIS) SDL_WaylandDataDevice *data_device = NULL; SDL_bool result = SDL_FALSE; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { SDL_SetError("Video driver uninitialized"); } else { video_data = _this->driverdata; - 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; result = result || Wayland_data_source_has_mime(data_device->selection_source, TEXT_MIME) || @@ -183,11 +183,11 @@ SDL_bool Wayland_HasPrimarySelectionText(_THIS) SDL_WaylandPrimarySelectionDevice *primary_selection_device = NULL; SDL_bool result = SDL_FALSE; - if (_this == NULL || _this->driverdata == NULL) { + if (!_this || !_this->driverdata) { SDL_SetError("Video driver uninitialized"); } else { video_data = _this->driverdata; - 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; result = result || Wayland_primary_selection_source_has_mime( diff --git a/src/video/wayland/SDL_waylanddatamanager.c b/src/video/wayland/SDL_waylanddatamanager.c index 8985873250719..d430bdbced06e 100644 --- a/src/video/wayland/SDL_waylanddatamanager.c +++ b/src/video/wayland/SDL_waylanddatamanager.c @@ -248,7 +248,7 @@ static ssize_t Wayland_source_send(SDL_MimeDataList *mime_data, const char *mime size_t written_bytes = 0; ssize_t status = 0; - if (mime_data == NULL || mime_data->data == NULL) { + if (!mime_data || !mime_data->data) { status = SDL_SetError("Invalid mime type"); close(fd); } else { @@ -306,7 +306,7 @@ SDL_bool Wayland_data_source_has_mime(SDL_WaylandDataSource *source, { SDL_bool found = SDL_FALSE; - if (source != NULL) { + if (source) { found = mime_data_list_find(&source->mimes, mime_type) != NULL; } return found; @@ -317,7 +317,7 @@ SDL_bool Wayland_primary_selection_source_has_mime(SDL_WaylandPrimarySelectionSo { SDL_bool found = SDL_FALSE; - if (source != NULL) { + if (source) { found = mime_data_list_find(&source->mimes, mime_type) != NULL; } return found; @@ -329,14 +329,14 @@ static void *Wayland_source_get_data(SDL_MimeDataList *mime_data, { void *buffer = NULL; - if (mime_data != NULL && mime_data->length > 0) { + if (mime_data && mime_data->length > 0) { size_t buffer_length = mime_data->length; if (null_terminate == SDL_TRUE) { ++buffer_length; } buffer = SDL_malloc(buffer_length); - if (buffer == NULL) { + if (!buffer) { *length = SDL_OutOfMemory(); } else { *length = mime_data->length; @@ -358,7 +358,7 @@ void *Wayland_data_source_get_data(SDL_WaylandDataSource *source, void *buffer = NULL; *length = 0; - if (source == NULL) { + if (!source) { SDL_SetError("Invalid data source"); } else { mime_data = mime_data_list_find(&source->mimes, mime_type); diff --git a/src/video/wayland/SDL_waylandevents.c b/src/video/wayland/SDL_waylandevents.c index 1bdebb6d6ac46..276963837a9ae 100644 --- a/src/video/wayland/SDL_waylandevents.c +++ b/src/video/wayland/SDL_waylandevents.c @@ -269,7 +269,7 @@ int Wayland_WaitEventTimeout(_THIS, int timeout) WAYLAND_wl_display_flush(d->display); #ifdef SDL_USE_IME - if (d->text_input_manager == NULL && SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) { + if (!d->text_input_manager && SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) { SDL_IME_PumpEvents(); } #endif @@ -338,7 +338,7 @@ void Wayland_PumpEvents(_THIS) int err; #ifdef SDL_USE_IME - if (d->text_input_manager == NULL && SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) { + if (!d->text_input_manager && SDL_GetEventState(SDL_TEXTINPUT) == SDL_ENABLE) { SDL_IME_PumpEvents(); } #endif @@ -1728,7 +1728,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) { + if (data_device->drag_offer) { /* TODO: SDL Support more mime types */ size_t length; SDL_bool drop_handled = SDL_FALSE; @@ -1761,13 +1761,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, &length, FILE_MIME, SDL_TRUE); if (buffer) { char *saveptr = NULL; char *token = SDL_strtokr((char *)buffer, "\r\n", &saveptr); - while (token != NULL) { + while (token) { char *fn = Wayland_URIToLocal(token); if (fn) { SDL_SendDropFile(data_device->dnd_window, fn); @@ -2146,7 +2146,7 @@ static void tablet_tool_handle_down(void *data, struct zwp_tablet_tool_v2 *tool, struct SDL_WaylandTabletInput *input = data; SDL_WindowData *window = input->tool_focus; input->is_down = SDL_TRUE; - 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. @@ -2427,28 +2427,28 @@ void Wayland_display_destroy_input(SDL_VideoData *d) return; } - 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) { wl_data_device_release(input->data_device->data_device); } 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); } 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); } diff --git a/src/video/wayland/SDL_waylandkeyboard.c b/src/video/wayland/SDL_waylandkeyboard.c index 13664970a0827..999f87e29851d 100644 --- a/src/video/wayland/SDL_waylandkeyboard.c +++ b/src/video/wayland/SDL_waylandkeyboard.c @@ -116,14 +116,14 @@ void Wayland_SetTextInputRect(_THIS, const SDL_Rect *rect) { SDL_VideoData *driverdata = _this->driverdata; - if (rect == NULL) { + if (!rect) { SDL_InvalidParamError("rect"); return; } if (driverdata->text_input_manager) { struct SDL_WaylandInput *input = driverdata->input; - if (input != NULL && input->text_input) { + if (input && input->text_input) { if (!SDL_RectEquals(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_waylandmouse.c b/src/video/wayland/SDL_waylandmouse.c index e7ba64fdd8935..2833c948bbe90 100644 --- a/src/video/wayland/SDL_waylandmouse.c +++ b/src/video/wayland/SDL_waylandmouse.c @@ -115,7 +115,7 @@ static SDL_bool wayland_dbus_read_cursor_size(int *size) DBusMessage *reply; SDL_DBusContext *dbus = SDL_DBus_GetContext(); - if (dbus == NULL || size == NULL) { + if (!dbus || !size) { return SDL_FALSE; } @@ -137,7 +137,7 @@ static SDL_bool wayland_dbus_read_cursor_theme(char **theme) DBusMessage *reply; SDL_DBusContext *dbus = SDL_DBus_GetContext(); - if (dbus == NULL || theme == NULL) { + if (!dbus || !theme) { return SDL_FALSE; } @@ -204,19 +204,19 @@ static SDL_bool wayland_get_system_cursor(SDL_VideoData *vdata, Wayland_CursorDa break; } } - if (theme == NULL) { + if (!theme) { char *xcursor_theme = NULL; SDL_bool free_theme_str = SDL_FALSE; 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; } xcursor_theme = SDL_getenv("XCURSOR_THEME"); #if SDL_USE_LIBDBUS - if (xcursor_theme == NULL) { + if (!xcursor_theme) { /* Allocates the string with SDL_strdup, which must be freed. */ free_theme_str = wayland_dbus_read_cursor_theme(&xcursor_theme); } diff --git a/src/video/wayland/SDL_waylandtouch.c b/src/video/wayland/SDL_waylandtouch.c index 7c7a300d72214..f4762cfc69293 100644 --- a/src/video/wayland/SDL_waylandtouch.c +++ b/src/video/wayland/SDL_waylandtouch.c @@ -99,7 +99,7 @@ static void touch_handle_touch(void *data, /* FIXME: This should be the window the given wayland surface is associated * with, but how do we get the wayland surface? */ window = SDL_GetMouseFocus(); - if (window == NULL) { + if (!window) { window = SDL_GetKeyboardFocus(); } diff --git a/src/video/wayland/SDL_waylandtouch.h b/src/video/wayland/SDL_waylandtouch.h index 5a542e2dd815f..652f81019943b 100644 --- a/src/video/wayland/SDL_waylandtouch.h +++ b/src/video/wayland/SDL_waylandtouch.h @@ -94,7 +94,7 @@ static inline struct qt_extended_surface *qt_surface_extension_get_extended_surf id = wl_proxy_create((struct wl_proxy *)qt_surface_extension, &qt_extended_surface_interface); - if (id == NULL) + if (!id) return NULL; WAYLAND_wl_proxy_marshal((struct wl_proxy *)qt_surface_extension, diff --git a/src/video/wayland/SDL_waylandvideo.c b/src/video/wayland/SDL_waylandvideo.c index 1c193d229122a..d8c7aabf7542e 100644 --- a/src/video/wayland/SDL_waylandvideo.c +++ b/src/video/wayland/SDL_waylandvideo.c @@ -356,7 +356,7 @@ static void xdg_output_handle_description(void *data, struct zxdg_output_v1 *xdg if (driverdata->index == -1) { /* xdg-output descriptions, if available, supersede wl-output model names. */ - if (driverdata->placeholder.name != NULL) { + if (driverdata->placeholder.name) { SDL_free(driverdata->placeholder.name); } @@ -485,7 +485,7 @@ static void display_handle_geometry(void *data, driverdata->physical_height = physical_height; /* The output name is only set if xdg-output hasn't provided a description. */ - if (driverdata->index == -1 && driverdata->placeholder.name == NULL) { + if (driverdata->index == -1 && !driverdata->placeholder.name) { driverdata->placeholder.name = SDL_strdup(model); } @@ -609,7 +609,7 @@ static void display_handle_done(void *data, * The native display mode is only exposed separately from the desktop size if the * desktop is scaled and the wp_viewporter protocol is supported. */ - if (driverdata->scale_factor > 1.0f && video->viewporter != NULL) { + if (driverdata->scale_factor > 1.0f && video->viewporter) { if (driverdata->index > -1) { SDL_AddDisplayMode(SDL_GetDisplay(driverdata->index), &native_mode); } else { @@ -685,7 +685,7 @@ static void Wayland_add_display(SDL_VideoData *d, uint32_t id) SDL_WaylandOutputData *data; output = wl_registry_bind(d->registry, id, &wl_output_interface, 2); - if (output == NULL) { + if (!output) { SDL_SetError("Failed to retrieve output."); return; } @@ -701,10 +701,10 @@ static void Wayland_add_display(SDL_VideoData *d, uint32_t id) SDL_WAYLAND_register_output(output); /* Keep a list of outputs for deferred xdg-output initialization. */ - if (d->output_list != NULL) { + if (d->output_list) { SDL_WaylandOutputData *node = d->output_list; - while (node->next != NULL) { + while (node->next) { node = node->next; } @@ -730,15 +730,15 @@ static void Wayland_free_display(SDL_VideoData *d, uint32_t id) display = SDL_GetDisplay(i); data = (SDL_WaylandOutputData *)display->driverdata; if (data->registry_id == id) { - if (d->output_list != NULL) { + if (d->output_list) { SDL_WaylandOutputData *node = d->output_list; if (node == data) { d->output_list = node->next; } else { - while (node->next != data && node->next != NULL) { + while (node->next != data && node->next) { node = node->next; } - if (node->next != NULL) { + if (node->next) { node->next = node->next->next; } } @@ -766,7 +766,7 @@ static void Wayland_free_display(SDL_VideoData *d, uint32_t id) static void Wayland_init_xdg_output(SDL_VideoData *d) { SDL_WaylandOutputData *node; - for (node = d->output_list; node != NULL; node = node->next) { + for (node = d->output_list; node; node = node->next) { node->xdg_output = zxdg_output_manager_v1_get_xdg_output(node->videodata->xdg_output_manager, node->output); zxdg_output_v1_add_listener(node->xdg_output, &xdg_output_listener, node); } diff --git a/src/video/wayland/SDL_waylandwindow.c b/src/video/wayland/SDL_waylandwindow.c index bf9671bcc33e9..6a773de567259 100644 --- a/src/video/wayland/SDL_waylandwindow.c +++ b/src/video/wayland/SDL_waylandwindow.c @@ -145,7 +145,7 @@ static SDL_bool NeedViewport(SDL_Window *window) * - A fullscreen mode is being emulated and the mode does not match the logical desktop dimensions. * - The desktop uses fractional scaling and the high-DPI flag is set. */ - if (video->viewporter != NULL) { + if (video->viewporter) { if (FullscreenModeEmulation(window)) { GetFullScreenDimensions(window, &fs_width, &fs_height, NULL, NULL); if (fs_width != output_width || fs_height != output_height) { @@ -295,7 +295,7 @@ static void ConfigureWindowGeometry(SDL_Window *window) if (window_size_changed) { /* 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->window_width, data->window_height); } @@ -360,7 +360,7 @@ static void SetMinMaxDimensions(SDL_Window *window, SDL_bool commit) #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_min_content_size(wind->shell_surface.libdecor.frame, @@ -781,7 +781,7 @@ static const struct zxdg_toplevel_decoration_v1_listener decoration_listener = { static void OverrideLibdecorLimits(SDL_Window *window) { #if defined(SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR) - if (libdecor_frame_get_min_content_size == NULL) { + if (!libdecor_frame_get_min_content_size) { SetMinMaxDimensions(window, SDL_FALSE); } #elif !defined(SDL_HAVE_LIBDECOR_GET_MIN_MAX) @@ -1208,7 +1208,7 @@ SDL_bool Wayland_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * inf #ifdef HAVE_LIBDECOR_H if (data->shell_surface_type == WAYLAND_SURFACE_LIBDECOR) { - if (data->shell_surface.libdecor.frame != NULL) { + if (data->shell_surface.libdecor.frame) { info->info.wl.xdg_surface = libdecor_frame_get_xdg_surface(data->shell_surface.libdecor.frame); if (version >= SDL_VERSIONNUM(2, 0, 17)) { info->info.wl.xdg_toplevel = libdecor_frame_get_xdg_toplevel(data->shell_surface.libdecor.frame); @@ -1223,7 +1223,7 @@ SDL_bool Wayland_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * inf } } else #endif - if (viddata->shell.xdg && data->shell_surface.xdg.surface != NULL) { + if (viddata->shell.xdg && data->shell_surface.xdg.surface) { info->info.wl.xdg_surface = data->shell_surface.xdg.surface; if (version >= SDL_VERSIONNUM(2, 0, 17)) { SDL_bool popup = data->shell_surface_type == WAYLAND_SURFACE_XDG_POPUP; @@ -1601,7 +1601,7 @@ static void Wayland_activate_window(SDL_VideoData *data, SDL_WindowData *wind, uint32_t serial, struct wl_seat *seat) { if (data->activation_manager) { - if (wind->activation_token != NULL) { + if (wind->activation_token) { /* We're about to overwrite this with a new request */ xdg_activation_token_v1_destroy(wind->activation_token); } @@ -1618,10 +1618,10 @@ static void Wayland_activate_window(SDL_VideoData *data, SDL_WindowData *wind, * * -flibit */ - if (surface != NULL) { + if (surface) { xdg_activation_token_v1_set_surface(wind->activation_token, surface); } - if (seat != NULL) { + if (seat) { xdg_activation_token_v1_set_serial(wind->activation_token, serial, seat); } xdg_activation_token_v1_commit(wind->activation_token); @@ -1695,20 +1695,20 @@ static void SDLCALL QtExtendedSurface_OnHintChanged(void *userdata, const char * { "inverted-landscape", QT_EXTENDED_SURFACE_ORIENTATION_INVERTEDLANDSCAPEORIENTATION } }; - if (name == NULL) { + if (!name) { return; } if (SDL_strcmp(name, SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION) == 0) { int32_t orientation = QT_EXTENDED_SURFACE_ORIENTATION_PRIMARYORIENTATION; - if (newValue != NULL) { + if (newValue) { const char *value_attempt = newValue; orientation = 0; - while (value_attempt != NULL && *value_attempt != 0) { + while (value_attempt && *value_attempt != 0) { const char *value_attempt_end = SDL_strchr(value_attempt, ','); - size_t value_attempt_len = (value_attempt_end != NULL) ? (value_attempt_end - value_attempt) + size_t value_attempt_len = (value_attempt_end) ? (value_attempt_end - value_attempt) : SDL_strlen(value_attempt); for (i = 0; i < SDL_arraysize(orientations); i += 1) { @@ -1719,7 +1719,7 @@ static void SDLCALL QtExtendedSurface_OnHintChanged(void *userdata, const char * } } - value_attempt = (value_attempt_end != NULL) ? (value_attempt_end + 1) : NULL; + value_attempt = (value_attempt_end) ? (value_attempt_end + 1) : NULL; } } @@ -1727,7 +1727,7 @@ static void SDLCALL QtExtendedSurface_OnHintChanged(void *userdata, const char * } else if (SDL_strcmp(name, SDL_HINT_QTWAYLAND_WINDOW_FLAGS) == 0) { uint32_t flags = 0; - if (newValue != NULL) { + if (newValue) { char *tmp = SDL_strdup(newValue); char *saveptr = NULL; @@ -2322,7 +2322,7 @@ static void EGLTransparencyChangedCallback(void *userdata, const char *name, con viddata->egl_transparency_enabled = newval; /* Iterate over all windows and update the surface opaque regions */ - for (window = dev->windows; window != NULL; window = window->next) { + for (window = dev->windows; window; window = window->next) { SDL_WindowData *wind = (SDL_WindowData *)window->driverdata; if (!newval) { diff --git a/src/video/windows/SDL_windowsclipboard.c b/src/video/windows/SDL_windowsclipboard.c index df8a404a7645a..49e852e5e6d27 100644 --- a/src/video/windows/SDL_windowsclipboard.c +++ b/src/video/windows/SDL_windowsclipboard.c @@ -129,7 +129,7 @@ char *WIN_GetClipboardText(_THIS) SDL_Delay(10); } } - if (text == NULL) { + if (!text) { text = SDL_strdup(""); } return text; diff --git a/src/video/windows/SDL_windowskeyboard.c b/src/video/windows/SDL_windowskeyboard.c index 881639fa04116..01a9977f154a7 100644 --- a/src/video/windows/SDL_windowskeyboard.c +++ b/src/video/windows/SDL_windowskeyboard.c @@ -239,7 +239,7 @@ void WIN_SetTextInputRect(_THIS, const SDL_Rect *rect) SDL_VideoData *videodata = (SDL_VideoData *)_this->driverdata; HIMC himc = 0; - if (rect == NULL) { + if (!rect) { SDL_InvalidParamError("rect"); return; } diff --git a/src/video/windows/SDL_windowsmodes.c b/src/video/windows/SDL_windowsmodes.c index e26397eee1845..f0e3d34efefb4 100644 --- a/src/video/windows/SDL_windowsmodes.c +++ b/src/video/windows/SDL_windowsmodes.c @@ -521,7 +521,7 @@ int WIN_GetDisplayDPI(_THIS, SDL_VideoDisplay *display, float *ddpi_out, float * float hinches, vinches; hdc = GetDC(NULL); - if (hdc == NULL) { + if (!hdc) { return SDL_SetError("GetDC failed"); } hdpi_int = GetDeviceCaps(hdc, LOGPIXELSX); @@ -603,7 +603,7 @@ void WIN_ScreenPointFromSDL(int *x, int *y, int *dpiOut) *dpiOut = 96; } - if (videodevice == NULL || !videodevice->driverdata) { + if (!videodevice || !videodevice->driverdata) { return; } @@ -656,7 +656,7 @@ void WIN_ScreenPointToSDL(int *x, int *y) float ddpi, hdpi, vdpi; int x_pixels, y_pixels; - if (videodevice == NULL || !videodevice->driverdata) { + if (!videodevice || !videodevice->driverdata) { return; } diff --git a/src/video/windows/SDL_windowsopengles.c b/src/video/windows/SDL_windowsopengles.c index ab16c46c6d9bf..cad4479f4ef06 100644 --- a/src/video/windows/SDL_windowsopengles.c +++ b/src/video/windows/SDL_windowsopengles.c @@ -51,7 +51,7 @@ int WIN_GLES_LoadLibrary(_THIS, const char *path) #endif } - if (_this->egl_data == NULL) { + if (!_this->egl_data) { return SDL_EGL_LoadLibrary(_this, NULL, EGL_DEFAULT_DISPLAY, 0); } diff --git a/src/video/windows/SDL_windowsshape.c b/src/video/windows/SDL_windowsshape.c index 56b6683128f67..b00e44760e9b0 100644 --- a/src/video/windows/SDL_windowsshape.c +++ b/src/video/windows/SDL_windowsshape.c @@ -77,8 +77,8 @@ 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)) || (shape->w != shaper->window->w) || (shape->h != shaper->window->h)) { @@ -86,7 +86,7 @@ int Win32_SetWindowShape(SDL_WindowShaper *shaper, SDL_Surface *shape, SDL_Windo } 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); @@ -103,15 +103,15 @@ int Win32_ResizeWindowShape(SDL_Window *window) { SDL_ShapeData *data; - if (window == NULL) { + if (!window) { return -1; } data = (SDL_ShapeData *)window->shaper->driverdata; - if (data == NULL) { + if (!data) { return -1; } - if (data->mask_tree != NULL) { + if (data->mask_tree) { SDL_FreeShapeTree(&data->mask_tree); } if (window->shaper->hasshape == SDL_TRUE) { diff --git a/src/video/windows/SDL_windowsvideo.c b/src/video/windows/SDL_windowsvideo.c index ea1dab090fffb..6ff6fd43c8e9d 100644 --- a/src/video/windows/SDL_windowsvideo.c +++ b/src/video/windows/SDL_windowsvideo.c @@ -385,7 +385,7 @@ static void WIN_InitDPIAwareness(_THIS) { const char *hint = SDL_GetHint(SDL_HINT_WINDOWS_DPI_AWARENESS); - if (hint != NULL) { + if (hint) { if (SDL_strcmp(hint, "permonitorv2") == 0) { WIN_DeclareDPIAwarePerMonitorV2(_this); } else if (SDL_strcmp(hint, "permonitor") == 0) { diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c index fc31cf229428e..ea11132ec9d95 100644 --- a/src/video/windows/SDL_windowswindow.c +++ b/src/video/windows/SDL_windowswindow.c @@ -179,7 +179,7 @@ static void WIN_AdjustWindowRectWithStyle(SDL_Window *window, DWORD style, BOOL mon = MonitorFromRect(&screen_rect, MONITOR_DEFAULTTONEAREST); - if (videodata != NULL) { + if (videodata) { /* GetDpiForMonitor docs promise to return the same hdpi / vdpi */ if (videodata->GetDpiForMonitor(mon, MDT_EFFECTIVE_DPI, &frame_dpi, &unused) != S_OK) { frame_dpi = 96; diff --git a/src/video/x11/SDL_x11clipboard.c b/src/video/x11/SDL_x11clipboard.c index 5d28eecca4b3b..39198e74d138a 100644 --- a/src/video/x11/SDL_x11clipboard.c +++ b/src/video/x11/SDL_x11clipboard.c @@ -206,7 +206,7 @@ static char *GetSlectionText(_THIS, Atom selection_type) X11_XFree(src); } - if (text == NULL) { + if (!text) { text = SDL_strdup(""); } diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index a33ef61f15cb3..ec5433dfabf09 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -1570,7 +1570,7 @@ static void X11_DispatchEvent(_THIS, XEvent *xevent) char *name = X11_XGetAtomName(display, target); if (name) { char *token = SDL_strtokr((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_x11keyboard.c b/src/video/x11/SDL_x11keyboard.c index 12818ed69cd1c..8d0c6c8c8b262 100644 --- a/src/video/x11/SDL_x11keyboard.c +++ b/src/video/x11/SDL_x11keyboard.c @@ -451,7 +451,7 @@ void X11_StopTextInput(_THIS) void X11_SetTextInputRect(_THIS, const SDL_Rect *rect) { - if (rect == NULL) { + if (!rect) { SDL_InvalidParamError("rect"); return; } diff --git a/src/video/x11/SDL_x11modes.c b/src/video/x11/SDL_x11modes.c index a41438370dd98..ae4a4b24d4a49 100644 --- a/src/video/x11/SDL_x11modes.c +++ b/src/video/x11/SDL_x11modes.c @@ -410,14 +410,14 @@ static void X11_HandleXRandROutputChange(_THIS, const XRROutputChangeNotifyEvent } } - SDL_assert((displayidx == -1) == (display == NULL)); + SDL_assert((displayidx == -1) == (!display)); if (ev->connection == RR_Disconnected) { /* output is going away */ - if (display != NULL) { + if (display) { SDL_DelVideoDisplay(displayidx); } } 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; @@ -525,7 +525,7 @@ static int GetXftDPI(Display *dpy) xdefault_resource = X11_XGetDefault(dpy, "Xft", "dpi"); - if (xdefault_resource == NULL) { + if (!xdefault_resource) { return 0; } diff --git a/src/video/x11/SDL_x11mouse.c b/src/video/x11/SDL_x11mouse.c index 81171898cf238..c3ed9cc210db9 100644 --- a/src/video/x11/SDL_x11mouse.c +++ b/src/video/x11/SDL_x11mouse.c @@ -419,7 +419,7 @@ static Uint32 X11_GetGlobalMouseState(int *x, int *y) if (videodata->global_mouse_changed) { for (i = 0; i < num_screens; i++) { SDL_DisplayData *data = (SDL_DisplayData *)SDL_GetDisplayDriverData(i); - if (data != NULL) { + if (data) { Window root, child; int rootx, rooty, winx, winy; unsigned int mask; diff --git a/src/video/x11/SDL_x11shape.c b/src/video/x11/SDL_x11shape.c index 771d31d95ccce..3d4dd493083ca 100644 --- a/src/video/x11/SDL_x11shape.c +++ b/src/video/x11/SDL_x11shape.c @@ -69,17 +69,17 @@ int X11_ResizeWindowShape(SDL_Window *window) { SDL_ShapeData *data = window->shaper->driverdata; unsigned int bitmapsize = window->w / 8; - SDL_assert(data != NULL); + SDL_assert(data); if (window->w % 8 > 0) { bitmapsize += 1; } bitmapsize *= window->h; - if (data->bitmapsize != bitmapsize || data->bitmap == NULL) { + if (data->bitmapsize != bitmapsize || !data->bitmap) { data->bitmapsize = bitmapsize; SDL_free(data->bitmap); data->bitmap = SDL_malloc(data->bitmapsize); - if (data->bitmap == NULL) { + if (!data->bitmap) { return SDL_OutOfMemory(); } } diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 8462d6d86c39f..5cdf73dae8b4c 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -284,7 +284,7 @@ static int SetupWindowData(_THIS, SDL_Window *window, Window w, BOOL created) (numwindows + 1) * sizeof(*windowlist)); - if (windowlist == NULL) { + if (!windowlist) { SDL_free(data); return SDL_OutOfMemory(); } @@ -416,7 +416,7 @@ int X11_CreateWindow(_THIS, SDL_Window *window) if (((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) || SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_FORCE_EGL, SDL_FALSE)) #if SDL_VIDEO_OPENGL_GLX - && ( !_this->gl_data || X11_GL_UseEGL(_this) ) + && (!_this->gl_data || X11_GL_UseEGL(_this) ) #endif ) { vinfo = X11_GLES_GetVisual(_this, display, screen); @@ -639,7 +639,7 @@ int X11_CreateWindow(_THIS, SDL_Window *window) ((_this->gl_config.profile_mask == SDL_GL_CONTEXT_PROFILE_ES) || SDL_GetHintBoolean(SDL_HINT_VIDEO_X11_FORCE_EGL, SDL_FALSE)) #if SDL_VIDEO_OPENGL_GLX - && ( !_this->gl_data || X11_GL_UseEGL(_this) ) + && (!_this->gl_data || X11_GL_UseEGL(_this) ) #endif ) { #if SDL_VIDEO_OPENGL_EGL @@ -1813,7 +1813,7 @@ SDL_bool X11_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Display *display; - if (data == NULL) { + if (!data) { /* This sometimes happens in SDL_IBus_UpdateTextRect() while creating the window */ SDL_SetError("Window not initialized"); return SDL_FALSE; diff --git a/src/video/x11/SDL_x11xfixes.c b/src/video/x11/SDL_x11xfixes.c index 2189f231d57ce..3c988bc3dde6c 100644 --- a/src/video/x11/SDL_x11xfixes.c +++ b/src/video/x11/SDL_x11xfixes.c @@ -120,7 +120,7 @@ int X11_ConfineCursorWithFlags(_THIS, SDL_Window *window, const SDL_Rect *rect, X11_DestroyPointerBarrier(_this, data->active_cursor_confined_window); } - SDL_assert(window != NULL); + SDL_assert(window); wdata = (SDL_WindowData *)window->driverdata; /* If user did not specify an area to confine, destroy the barrier that was/is assigned to diff --git a/test/checkkeys.c b/test/checkkeys.c index 4efdc721e1a09..d4e15846d41f3 100644 --- a/test/checkkeys.c +++ b/test/checkkeys.c @@ -269,14 +269,14 @@ int main(int argc, char *argv[]) window = SDL_CreateWindow("CheckKeys Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 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); } renderer = SDL_CreateRenderer(window, -1, 0); - if (renderer == NULL) { + if (!renderer) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); quit(2); diff --git a/test/checkkeysthreads.c b/test/checkkeysthreads.c index 3db5dd2dc7a2b..22983b15756a3 100644 --- a/test/checkkeysthreads.c +++ b/test/checkkeysthreads.c @@ -254,7 +254,7 @@ int main(int argc, char *argv[]) window = SDL_CreateWindow("CheckKeys Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 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/controllermap.c b/test/controllermap.c index cfb0effaced81..4f91588b22800 100644 --- a/test/controllermap.c +++ b/test/controllermap.c @@ -288,7 +288,8 @@ ConfigureBinding(const SDL_GameControllerExtendedBind *pBinding) SDL_Log("Configuring button binding for button %d\n", pBinding->value.button); break; case SDL_CONTROLLER_BINDTYPE_AXIS: - SDL_Log("Configuring axis binding for axis %d %d/%d committed = %s\n", pBinding->value.axis.axis, pBinding->value.axis.axis_min, pBinding->value.axis.axis_max, pBinding->committed ? "true" : "false"); + SDL_Log("Configuring axis binding for axis %d %d/%d committed = %s\n", pBinding->value.axis.axis, pBinding->value.axis.axis_min, pBinding->value.axis.axis_max, + pBinding->committed ? "true" : "false"); break; case SDL_CONTROLLER_BINDTYPE_HAT: SDL_Log("Configuring hat binding for hat %d %d\n", pBinding->value.hat.hat, pBinding->value.hat.hat_mask); @@ -729,13 +730,13 @@ int main(int argc, char *argv[]) window = SDL_CreateWindow("Game Controller Map", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 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, -1, 0); - if (screen == NULL) { + if (!screen) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); return 2; } @@ -766,7 +767,7 @@ int main(int argc, char *argv[]) name = SDL_JoystickNameForIndex(i); SDL_Log("Joystick %d: %s\n", i, name ? name : "Unknown Joystick"); joystick = SDL_JoystickOpen(i); - if (joystick == NULL) { + if (!joystick) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "SDL_JoystickOpen(%d) failed: %s\n", i, SDL_GetError()); } else { @@ -792,7 +793,7 @@ int main(int argc, char *argv[]) } } joystick = SDL_JoystickOpen(joystick_index); - if (joystick == NULL) { + if (!joystick) { SDL_Log("Couldn't open joystick %d: %s\n", joystick_index, SDL_GetError()); } else { WatchJoystick(joystick); diff --git a/test/loopwavequeue.c b/test/loopwavequeue.c index 70dd072d29ec2..d7e7d408a6c0a 100644 --- a/test/loopwavequeue.c +++ b/test/loopwavequeue.c @@ -84,7 +84,7 @@ int main(int argc, char *argv[]) filename = GetResourceFilename(argc > 1 ? argv[1] : NULL, "sample.wav"); - if (filename == NULL) { + if (!filename) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError()); quit(1); } diff --git a/test/testaudiohotplug.c b/test/testaudiohotplug.c index 9d088b15be585..35e65a99c9516 100644 --- a/test/testaudiohotplug.c +++ b/test/testaudiohotplug.c @@ -96,7 +96,7 @@ iteration() int index = e.adevice.which; int iscapture = e.adevice.iscapture; const char *name = SDL_GetAudioDeviceName(index, iscapture); - if (name != NULL) { + if (name) { SDL_Log("New %s audio device at index %u: %s\n", devtypestr(iscapture), (unsigned int)index, name); } else { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Got new %s device at index %u, but failed to get the name: %s\n", diff --git a/test/testaudioinfo.c b/test/testaudioinfo.c index ae59cbcc86113..2e0f09048bc73 100644 --- a/test/testaudioinfo.c +++ b/test/testaudioinfo.c @@ -29,7 +29,7 @@ print_devices(int iscapture) int i; for (i = 0; i < n; i++) { const char *name = SDL_GetAudioDeviceName(i, iscapture); - if (name != NULL) { + if (name) { SDL_Log(" %d: %s\n", i, name); } else { SDL_Log(" %d Error: %s\n", i, SDL_GetError()); @@ -81,7 +81,7 @@ int main(int argc, char **argv) if (SDL_GetDefaultAudioInfo(&deviceName, &spec, 0) < 0) { SDL_Log("Error when calling SDL_GetDefaultAudioInfo: %s\n", SDL_GetError()); } else { - SDL_Log("Default Output Name: %s\n", deviceName != NULL ? deviceName : "unknown"); + SDL_Log("Default Output Name: %s\n", deviceName ? deviceName : "unknown"); SDL_free(deviceName); SDL_Log("Sample Rate: %d\n", spec.freq); SDL_Log("Channels: %d\n", spec.channels); @@ -91,7 +91,7 @@ int main(int argc, char **argv) if (SDL_GetDefaultAudioInfo(&deviceName, &spec, 1) < 0) { SDL_Log("Error when calling SDL_GetDefaultAudioInfo: %s\n", SDL_GetError()); } else { - SDL_Log("Default Capture Name: %s\n", deviceName != NULL ? deviceName : "unknown"); + SDL_Log("Default Capture Name: %s\n", deviceName ? deviceName : "unknown"); SDL_free(deviceName); SDL_Log("Sample Rate: %d\n", spec.freq); SDL_Log("Channels: %d\n", spec.channels); diff --git a/test/testautomation.c b/test/testautomation.c index 2150ed246be13..6f3448aa6237f 100644 --- a/test/testautomation.c +++ b/test/testautomation.c @@ -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/testautomation_mouse.c b/test/testautomation_mouse.c index 281ca1b549b1b..19b1a9f58ca74 100644 --- a/test/testautomation_mouse.c +++ b/test/testautomation_mouse.c @@ -458,7 +458,7 @@ int mouse_warpMouseInWindow(void *arg) yPositions[5] = h + 1; /* Create test window */ window = _createMouseSuiteTestWindow(); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } @@ -511,7 +511,7 @@ 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 471abd6a571c5..9cf48effe2bb3 100644 --- a/test/testautomation_render.c +++ b/test/testautomation_render.c @@ -970,7 +970,7 @@ _hasTexColor(void) /* Get test face. */ tface = _loadTestFace(); - if (tface == NULL) { + if (!tface) { return 0; } @@ -1014,7 +1014,7 @@ _hasTexAlpha(void) /* Get test face. */ tface = _loadTestFace(); - if (tface == NULL) { + if (!tface) { return 0; } diff --git a/test/testautomation_surface.c b/test/testautomation_surface.c index 41aa24142c0c6..e241d8b0d6640 100644 --- a/test/testautomation_surface.c +++ b/test/testautomation_surface.c @@ -369,21 +369,21 @@ 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_AllocFormat(pixel_formats[i]); - SDL_assert(fmt1 != NULL); + SDL_assert(fmt1); cvt1 = SDL_ConvertSurface(face, fmt1, 0); - SDL_assert(cvt1 != NULL); + SDL_assert(cvt1); fmt2 = SDL_AllocFormat(pixel_formats[j]); - SDL_assert(fmt1 != NULL); + SDL_assert(fmt1); cvt2 = SDL_ConvertSurface(cvt1, fmt2, 0); - 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, 0 ); - 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 fb81cff2ed47e..f340edcd864e6 100644 --- a/test/testautomation_video.c +++ b/test/testautomation_video.c @@ -78,7 +78,7 @@ SDL_Window *_createVideoSuiteTestWindow(const char *title) */ void _destroyVideoSuiteTestWindow(SDL_Window *window) { - if (window != NULL) { + if (window) { SDL_DestroyWindow(window); window = NULL; SDLTest_AssertPass("Call to SDL_DestroyWindow()"); @@ -608,7 +608,7 @@ int video_getWindowDisplayMode(void *arg) /* Call against new test window */ window = _createVideoSuiteTestWindow(title); - if (window != NULL) { + if (window) { result = SDL_GetWindowDisplayMode(window, &mode); SDLTest_AssertPass("Call to SDL_GetWindowDisplayMode()"); SDLTest_AssertCheck(result == 0, "Validate result value; expected: 0, got: %d", result); @@ -702,7 +702,7 @@ video_getWindowGammaRamp(void *arg) /* Call against new test window */ window = _createVideoSuiteTestWindow(title); - if (window == NULL) return TEST_ABORTED; + if (!window) return TEST_ABORTED; /* Retrieve no channel */ result = SDL_GetWindowGammaRamp(window, NULL, NULL, NULL); @@ -856,7 +856,7 @@ int video_getSetWindowGrab(void *arg) /* Call against new test window */ window = _createVideoSuiteTestWindow(title); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } @@ -1019,7 +1019,7 @@ int video_getWindowId(void *arg) /* Call against new test window */ window = _createVideoSuiteTestWindow(title); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } @@ -1074,7 +1074,7 @@ int video_getWindowPixelFormat(void *arg) /* Call against new test window */ window = _createVideoSuiteTestWindow(title); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } @@ -1144,7 +1144,7 @@ int video_getSetWindowPosition(void *arg) /* Call against new test window */ window = _createVideoSuiteTestWindow(title); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } @@ -1316,7 +1316,7 @@ int video_getSetWindowSize(void *arg) /* Call against new test window */ window = _createVideoSuiteTestWindow(title); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } @@ -1499,7 +1499,7 @@ int video_getSetWindowMinimumSize(void *arg) /* Call against new test window */ window = _createVideoSuiteTestWindow(title); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } @@ -1641,7 +1641,7 @@ int video_getSetWindowMaximumSize(void *arg) /* Call against new test window */ window = _createVideoSuiteTestWindow(title); - if (window == NULL) { + if (!window) { return TEST_ABORTED; } @@ -1779,30 +1779,30 @@ 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/testdraw2.c b/test/testdraw2.c index f660c284584a1..1bff58fbcba5a 100644 --- a/test/testdraw2.c +++ b/test/testdraw2.c @@ -227,7 +227,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 8ff21a4c4ee5e..b46c913116eab 100644 --- a/test/testdrawchessboard.c +++ b/test/testdrawchessboard.c @@ -106,13 +106,13 @@ int main(int argc, char *argv[]) /* Create window and renderer for given surface */ window = SDL_CreateWindow("Chess Board", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 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/testfile.c b/test/testfile.c index f2918ada8b161..8f68b1b8d24e7 100644 --- a/test/testfile.c +++ b/test/testfile.c @@ -107,25 +107,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); } rwops->close(rwops); unlink(FBASENAME2); rwops = SDL_RWFromFile(FBASENAME2, "wb+"); - if (rwops == NULL) { + if (!rwops) { RWOP_ERR_QUIT(rwops); } rwops->close(rwops); unlink(FBASENAME2); rwops = SDL_RWFromFile(FBASENAME2, "ab"); - if (rwops == NULL) { + if (!rwops) { RWOP_ERR_QUIT(rwops); } rwops->close(rwops); unlink(FBASENAME2); rwops = SDL_RWFromFile(FBASENAME2, "ab+"); - if (rwops == NULL) { + if (!rwops) { RWOP_ERR_QUIT(rwops); } rwops->close(rwops); @@ -158,7 +158,7 @@ int main(int argc, char *argv[]) rwops->close(rwops); rwops = SDL_RWFromFile(FBASENAME1, "rb"); /* read mode, file must exists */ - if (rwops == NULL) { + if (!rwops) { RWOP_ERR_QUIT(rwops); } if (0 != rwops->seek(rwops, 0L, RW_SEEK_SET)) { diff --git a/test/testgamecontroller.c b/test/testgamecontroller.c index e2bdebdec5fda..19edb28e2f2b4 100644 --- a/test/testgamecontroller.c +++ b/test/testgamecontroller.c @@ -109,7 +109,7 @@ static SDL_GameControllerButton virtual_button_active = SDL_CONTROLLER_BUTTON_IN static void UpdateWindowTitle() { - if (window == NULL) { + if (!window) { return; } @@ -201,13 +201,13 @@ static void AddController(int device_index, SDL_bool verbose) } controller = SDL_GameControllerOpen(device_index); - if (controller == NULL) { + if (!controller) { SDL_Log("Couldn't open controller: %s\n", SDL_GetError()); return; } controllers = (SDL_GameController **)SDL_realloc(gamecontrollers, (num_controllers + 1) * sizeof(*controllers)); - if (controllers == NULL) { + if (!controllers) { SDL_GameControllerClose(controller); return; } @@ -413,7 +413,7 @@ static void OpenVirtualController() SDL_Log("Couldn't open virtual device: %s\n", SDL_GetError()); } else { virtual_joystick = SDL_JoystickOpen(virtual_index); - if (virtual_joystick == NULL) { + if (!virtual_joystick) { SDL_Log("Couldn't open virtual device: %s\n", SDL_GetError()); } } @@ -624,7 +624,8 @@ void loop(void *arg) if (event.type == SDL_CONTROLLERBUTTONDOWN) { SetController(event.cbutton.which); } - SDL_Log("Controller %" SDL_PRIs32 " button %s %s\n", event.cbutton.which, SDL_GameControllerGetStringForButton((SDL_GameControllerButton)event.cbutton.button), event.cbutton.state ? "pressed" : "released"); + SDL_Log("Controller %" SDL_PRIs32 " button %s %s\n", event.cbutton.which, SDL_GameControllerGetStringForButton((SDL_GameControllerButton)event.cbutton.button), + event.cbutton.state ? "pressed" : "released"); /* Cycle PS5 trigger effects when the microphone button is pressed */ if (event.type == SDL_CONTROLLERBUTTONDOWN && @@ -896,13 +897,13 @@ int main(int argc, char *argv[]) window = SDL_CreateWindow("Game Controller Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 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, -1, 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; @@ -920,7 +921,7 @@ int main(int argc, char *argv[]) button_texture = LoadTexture(screen, "button.bmp", SDL_TRUE, NULL, NULL); axis_texture = LoadTexture(screen, "axis.bmp", SDL_TRUE, NULL, NULL); - if (background_front == NULL || background_back == NULL || button_texture == NULL || axis_texture == NULL) { + if (!background_front || !background_back || !button_texture || !axis_texture) { SDL_DestroyRenderer(screen); SDL_DestroyWindow(window); return 2; diff --git a/test/testgesture.c b/test/testgesture.c index f37635f3319d3..f1510c065df03 100644 --- a/test/testgesture.c +++ b/test/testgesture.c @@ -131,7 +131,7 @@ DrawScreen(SDL_Window *window) SDL_Surface *screen = SDL_GetWindowSurface(window); int i; - if (screen == NULL) { + if (!screen) { return; } @@ -272,7 +272,7 @@ loop(void) int main(int argc, char *argv[]) { state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } diff --git a/test/testgl2.c b/test/testgl2.c index b58798c32295e..1d34d4c1c0dc6 100644 --- a/test/testgl2.c +++ b/test/testgl2.c @@ -226,7 +226,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/testhotplug.c b/test/testhotplug.c index 1ac73a7fbb682..462667d95c861 100644 --- a/test/testhotplug.c +++ b/test/testhotplug.c @@ -68,7 +68,7 @@ int main(int argc, char *argv[]) keepGoing = SDL_FALSE; break; case SDL_JOYDEVICEADDED: - if (joystick != NULL) { + if (joystick) { SDL_Log("Only one joystick supported by this test\n"); } else { joystick = SDL_JoystickOpen(event.jdevice.which); diff --git a/test/testjoystick.c b/test/testjoystick.c index adb31dc14fe0e..12bd16e09b863 100644 --- a/test/testjoystick.c +++ b/test/testjoystick.c @@ -117,7 +117,7 @@ void loop(void *arg) case SDL_JOYDEVICEADDED: SDL_Log("Joystick device %d added.\n", (int)event.jdevice.which); - if (joystick == NULL) { + if (!joystick) { joystick = SDL_JoystickOpen(event.jdevice.which); if (joystick) { PrintJoystick(joystick); @@ -296,13 +296,13 @@ int main(int argc, char *argv[]) window = SDL_CreateWindow("Joystick Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 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 SDL_FALSE; } screen = SDL_CreateRenderer(window, -1, 0); - if (screen == NULL) { + if (!screen) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); SDL_DestroyWindow(window); return SDL_FALSE; diff --git a/test/testmouse.c b/test/testmouse.c index c58fe78f03288..d871266a1fd32 100644 --- a/test/testmouse.c +++ b/test/testmouse.c @@ -130,7 +130,7 @@ void loop(void *arg) break; case SDL_MOUSEMOTION: - if (active == NULL) { + if (!active) { break; } @@ -139,7 +139,7 @@ void loop(void *arg) break; case SDL_MOUSEBUTTONDOWN: - 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; @@ -173,7 +173,7 @@ void loop(void *arg) break; case SDL_MOUSEBUTTONUP: - if (active == NULL) { + if (!active) { break; } @@ -266,13 +266,13 @@ int main(int argc, char *argv[]) window = SDL_CreateWindow("Mouse Test", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 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 SDL_FALSE; } renderer = SDL_CreateRenderer(window, -1, 0); - if (renderer == NULL) { + if (!renderer) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); SDL_DestroyWindow(window); return SDL_FALSE; diff --git a/test/testnative.c b/test/testnative.c index 1cf4ac041d033..5ff197bf2ccb3 100644 --- a/test/testnative.c +++ b/test/testnative.c @@ -47,7 +47,7 @@ static void quit(int rc) { SDL_VideoQuit(); - if (native_window != NULL && factory != NULL) { + if (native_window && factory) { factory->DestroyNativeWindow(native_window); } exit(rc); @@ -139,7 +139,7 @@ int main(int argc, char *argv[]) /* Create the renderer */ renderer = SDL_CreateRenderer(window, -1, 0); - if (renderer == NULL) { + if (!renderer) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); quit(5); } @@ -158,7 +158,7 @@ int main(int argc, char *argv[]) SDL_QueryTexture(sprite, NULL, NULL, &sprite_w, &sprite_h); positions = (SDL_Rect *)SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect)); velocities = (SDL_Rect *)SDL_malloc(NUM_SPRITES * sizeof(SDL_Rect)); - if (positions == NULL || velocities == NULL) { + if (!positions || !velocities) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); quit(2); } diff --git a/test/testoffscreen.c b/test/testoffscreen.c index fa511e8cef688..113c41fed59b8 100644 --- a/test/testoffscreen.c +++ b/test/testoffscreen.c @@ -115,14 +115,14 @@ int main(int argc, char *argv[]) SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 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, -1, 0); - if (renderer == NULL) { + if (!renderer) { SDL_Log("Couldn't create renderer: %s\n", SDL_GetError()); return SDL_FALSE; diff --git a/test/testoverlay2.c b/test/testoverlay2.c index a5dba68633b76..9653394682239 100644 --- a/test/testoverlay2.c +++ b/test/testoverlay2.c @@ -311,21 +311,21 @@ 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"); SDL_free(RawMooseData); 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"); SDL_free(RawMooseData); quit(2); @@ -343,21 +343,21 @@ int main(int argc, char **argv) SDL_WINDOWPOS_UNDEFINED, window_w, window_h, SDL_WINDOW_RESIZABLE); - if (window == NULL) { + if (!window) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError()); SDL_free(RawMooseData); quit(4); } renderer = SDL_CreateRenderer(window, -1, 0); - if (renderer == NULL) { + if (!renderer) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError()); SDL_free(RawMooseData); quit(4); } MooseTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_YV12, 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()); SDL_free(RawMooseData); quit(5); diff --git a/test/testresample.c b/test/testresample.c index 8bb603ac20671..cf8e8e734aa1e 100644 --- a/test/testresample.c +++ b/test/testresample.c @@ -57,7 +57,7 @@ int main(int argc, char **argv) cvt.len = len; cvt.buf = (Uint8 *)SDL_malloc((size_t)len * cvt.len_mult); - if (cvt.buf == NULL) { + if (!cvt.buf) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory.\n"); SDL_FreeWAV(data); SDL_Quit(); @@ -75,7 +75,7 @@ int main(int argc, char **argv) /* write out a WAV header... */ io = SDL_RWFromFile(argv[2], "wb"); - if (io == NULL) { + if (!io) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "fopen('%s') failed: %s\n", argv[2], SDL_GetError()); SDL_free(cvt.buf); SDL_FreeWAV(data); diff --git a/test/testsensor.c b/test/testsensor.c index 3da7e015e7f82..a122149acd2a9 100644 --- a/test/testsensor.c +++ b/test/testsensor.c @@ -36,7 +36,7 @@ static const char *GetSensorTypeString(SDL_SensorType type) static void HandleSensorEvent(SDL_SensorEvent *event) { SDL_Sensor *sensor = SDL_SensorFromInstanceID(event->which); - if (sensor == NULL) { + if (!sensor) { SDL_Log("Couldn't get sensor for sensor event\n"); return; } @@ -78,7 +78,7 @@ int main(int argc, char **argv) if (SDL_SensorGetDeviceType(i) != SDL_SENSOR_UNKNOWN) { SDL_Sensor *sensor = SDL_SensorOpen(i); - if (sensor == NULL) { + if (!sensor) { SDL_Log("Couldn't open sensor %" SDL_PRIs32 ": %s\n", SDL_SensorGetDeviceInstanceID(i), SDL_GetError()); } else { ++num_opened; diff --git a/test/testshader.c b/test/testshader.c index db0dcfef85452..47bce205cfaaa 100644 --- a/test/testshader.c +++ b/test/testshader.c @@ -329,7 +329,7 @@ SDL_GL_LoadTexture(SDL_Surface *surface, GLfloat *texcoord) 0x00FF0000, 0x0000FF00, 0x000000FF #endif ); - if (image == NULL) { + if (!image) { return 0; } @@ -462,7 +462,7 @@ int main(int argc, char **argv) /* Create a 640x480 OpenGL screen */ window = SDL_CreateWindow("Shader Demo", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, 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); @@ -475,7 +475,7 @@ int main(int argc, char **argv) } surface = SDL_LoadBMP("icon.bmp"); - 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 4e3c12cdddaff..06f277817f5c2 100644 --- a/test/testshape.c +++ b/test/testshape.c @@ -71,7 +71,7 @@ int main(int argc, char **argv) num_pictures = argc - 1; pictures = (LoadedPicture *)SDL_malloc(sizeof(LoadedPicture) * num_pictures); - if (pictures == NULL) { + if (!pictures) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Could not allocate memory."); exit(1); } @@ -106,7 +106,7 @@ int main(int argc, char **argv) SHAPED_WINDOW_DIMENSION, SHAPED_WINDOW_DIMENSION, 0); SDL_SetWindowPosition(window, SHAPED_WINDOW_X, SHAPED_WINDOW_Y); - if (window == NULL) { + if (!window) { for (i = 0; i < num_pictures; i++) { SDL_FreeSurface(pictures[i].surface); } @@ -116,7 +116,7 @@ int main(int argc, char **argv) exit(-4); } renderer = SDL_CreateRenderer(window, -1, 0); - if (renderer == NULL) { + if (!renderer) { SDL_DestroyWindow(window); for (i = 0; i < num_pictures; i++) { SDL_FreeSurface(pictures[i].surface); diff --git a/test/testsprite2.c b/test/testsprite2.c index 01c6148834359..ba1ff1d3625c2 100644 --- a/test/testsprite2.c +++ b/test/testsprite2.c @@ -453,7 +453,7 @@ int main(int argc, char *argv[]) /* Initialize test framework */ state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO); - if (state == NULL) { + if (!state) { return 1; } @@ -541,7 +541,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); } @@ -557,7 +557,7 @@ int main(int argc, char *argv[]) /* Allocate memory for the sprite info */ positions = (SDL_Rect *)SDL_malloc(num_sprites * sizeof(SDL_Rect)); velocities = (SDL_Rect *)SDL_malloc(num_sprites * sizeof(SDL_Rect)); - if (positions == NULL || velocities == NULL) { + if (!positions || !velocities) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n"); quit(2); } diff --git a/test/testspriteminimal.c b/test/testspriteminimal.c index 16b4fa4a36851..a255ebef98717 100644 --- a/test/testspriteminimal.c +++ b/test/testspriteminimal.c @@ -109,7 +109,7 @@ int main(int argc, char *argv[]) sprite = LoadTexture(renderer, "icon.bmp", SDL_TRUE, &sprite_w, &sprite_h); - if (sprite == NULL) { + if (!sprite) { quit(2); } diff --git a/test/teststreaming.c b/test/teststreaming.c index 63bb63a74a494..a233e11a2b1cf 100644 --- a/test/teststreaming.c +++ b/test/teststreaming.c @@ -160,19 +160,19 @@ int main(int argc, char **argv) SDL_WINDOWPOS_UNDEFINED, 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, -1, 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/testvulkan.c b/test/testvulkan.c index 74ab08e331c85..2c93e18f3d48a 100644 --- a/test/testvulkan.c +++ b/test/testvulkan.c @@ -236,7 +236,7 @@ static void createInstance(void) quit(2); } extensions = (const char **)SDL_malloc(sizeof(const char *) * extensionCount); - if (extensions == NULL) { + if (!extensions) { SDL_OutOfMemory(); quit(2); } diff --git a/test/testwm2.c b/test/testwm2.c index 7fc189bd75357..aafa8883053bc 100644 --- a/test/testwm2.c +++ b/test/testwm2.c @@ -208,7 +208,7 @@ void loop() } if (event.type == SDL_MOUSEBUTTONUP) { SDL_Window *window = SDL_GetMouseFocus(); - if (highlighted_mode != -1 && window != NULL) { + if (highlighted_mode != -1 && window) { const int display_index = SDL_GetWindowDisplayIndex(window); SDL_DisplayMode mode; if (0 != SDL_GetDisplayMode(display_index, highlighted_mode, &mode)) { @@ -223,7 +223,7 @@ void loop() 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) { int y = 0; SDL_Rect viewport, menurect; @@ -262,7 +262,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 828272c431835..5c2ff7fbe862b 100644 --- a/test/testyuv.c +++ b/test/testyuv.c @@ -327,7 +327,7 @@ int main(int argc, char **argv) filename = "testyuv.bmp"; } original = SDL_ConvertSurfaceFormat(SDL_LoadBMP(filename), SDL_PIXELFORMAT_RGB24, 0); - if (original == NULL) { + if (!original) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError()); return 3; } @@ -339,7 +339,7 @@ int main(int argc, char **argv) pitch = CalculateYUVPitch(yuv_format, original->w); converted = SDL_CreateRGBSurfaceWithFormat(0, original->w, original->h, 0, rgb_format); - if (converted == NULL) { + if (!converted) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create converted surface: %s\n", SDL_GetError()); return 3; } @@ -356,13 +356,13 @@ int main(int argc, char **argv) SDL_WINDOWPOS_UNDEFINED, 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, -1, 0); - if (renderer == NULL) { + if (!renderer) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError()); return 4; }