From ce5da5d579dd4a27dd7eb19ce4edb07d49bc058f Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 16 Nov 2022 21:47:43 +0100 Subject: [PATCH] Don't compare pointer against '0', but NULL --- Xcode-iOS/Demos/src/accelerometer.c | 4 ++-- Xcode-iOS/Demos/src/happy.c | 2 +- Xcode-iOS/Demos/src/keyboard.c | 2 +- Xcode-iOS/Demos/src/rectangles.c | 2 +- Xcode-iOS/Demos/src/touch.c | 2 +- src/audio/arts/SDL_artsaudio.c | 2 +- src/render/ps2/SDL_render_ps2.c | 4 ++-- src/render/psp/SDL_render_psp.c | 4 ++-- src/render/vitagxm/SDL_render_vita_gxm.c | 6 +++--- src/stdlib/SDL_qsort.c | 6 +++--- src/video/os2/SDL_os2dive.c | 2 +- src/video/x11/SDL_x11events.c | 2 +- src/video/x11/SDL_x11window.c | 2 +- test/testautomation_render.c | 2 +- 14 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Xcode-iOS/Demos/src/accelerometer.c b/Xcode-iOS/Demos/src/accelerometer.c index 925aee4e3..0af153676 100644 --- a/Xcode-iOS/Demos/src/accelerometer.c +++ b/Xcode-iOS/Demos/src/accelerometer.c @@ -127,7 +127,7 @@ initializeTextures(SDL_Renderer *renderer) /* create ship texture from surface */ ship = SDL_CreateTextureFromSurface(renderer, bmp_surface); - if (ship == 0) { + if (!ship) { fatalError("could not create ship texture"); } SDL_SetTextureBlendMode(ship, SDL_BLENDMODE_BLEND); @@ -145,7 +145,7 @@ initializeTextures(SDL_Renderer *renderer) } /* create space texture from surface */ space = SDL_CreateTextureFromSurface(renderer, bmp_surface); - if (space == 0) { + if (!space) { fatalError("could not create space texture"); } SDL_FreeSurface(bmp_surface); diff --git a/Xcode-iOS/Demos/src/happy.c b/Xcode-iOS/Demos/src/happy.c index 658a65f01..73d4d4feb 100644 --- a/Xcode-iOS/Demos/src/happy.c +++ b/Xcode-iOS/Demos/src/happy.c @@ -117,7 +117,7 @@ initializeTexture(SDL_Renderer *renderer) /* convert RGBA surface to texture */ texture = SDL_CreateTextureFromSurface(renderer, bmp_surface); - if (texture == 0) { + 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 cfbe4e66b..4d630bae5 100644 --- a/Xcode-iOS/Demos/src/keyboard.c +++ b/Xcode-iOS/Demos/src/keyboard.c @@ -183,7 +183,7 @@ loadFont(void) SDL_BlitSurface(surface, NULL, converted, NULL); /* create our texture */ texture = SDL_CreateTextureFromSurface(renderer, converted); - if (texture == 0) { + 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 10f9f851b..a08f99790 100644 --- a/Xcode-iOS/Demos/src/rectangles.c +++ b/Xcode-iOS/Demos/src/rectangles.c @@ -58,7 +58,7 @@ main(int argc, char *argv[]) /* create window and renderer */ window = SDL_CreateWindow(NULL, 0, 0, 320, 480, SDL_WINDOW_ALLOW_HIGHDPI); - if (window == 0) { + if (!window) { fatalError("Could not initialize Window"); } renderer = SDL_CreateRenderer(window, -1, 0); diff --git a/Xcode-iOS/Demos/src/touch.c b/Xcode-iOS/Demos/src/touch.c index 918240b82..6c184630d 100644 --- a/Xcode-iOS/Demos/src/touch.c +++ b/Xcode-iOS/Demos/src/touch.c @@ -63,7 +63,7 @@ initializeTexture(SDL_Renderer *renderer) brush = SDL_CreateTextureFromSurface(renderer, bmp_surface); SDL_FreeSurface(bmp_surface); - if (brush == 0) { + if (!brush) { fatalError("could not create brush texture"); } /* additive blending -- laying strokes on top of eachother makes them brighter */ diff --git a/src/audio/arts/SDL_artsaudio.c b/src/audio/arts/SDL_artsaudio.c index ce74b7d4d..82d84e320 100644 --- a/src/audio/arts/SDL_artsaudio.c +++ b/src/audio/arts/SDL_artsaudio.c @@ -318,7 +318,7 @@ ARTS_Init(SDL_AudioDriverImpl * impl) if (LoadARTSLibrary() < 0) { return SDL_FALSE; } else { - if (SDL_NAME(arts_init) () != 0) { + if (SDL_NAME(arts_init) () != NULL) { UnloadARTSLibrary(); SDL_SetError("ARTS: arts_init failed (no audio server?)"); return SDL_FALSE; diff --git a/src/render/ps2/SDL_render_ps2.c b/src/render/ps2/SDL_render_ps2.c index 54ace06f3..f385f5354 100644 --- a/src/render/ps2/SDL_render_ps2.c +++ b/src/render/ps2/SDL_render_ps2.c @@ -546,10 +546,10 @@ PS2_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) GSTEXTURE *ps2_texture = (GSTEXTURE *) texture->driverdata; PS2_RenderData *data = (PS2_RenderData *)renderer->driverdata; - if (data == 0) + if (data == NULL) return; - if(ps2_texture == 0) + if(ps2_texture == NULL) return; // Free from vram diff --git a/src/render/psp/SDL_render_psp.c b/src/render/psp/SDL_render_psp.c index 6644230ec..9a4e5c7bb 100644 --- a/src/render/psp/SDL_render_psp.c +++ b/src/render/psp/SDL_render_psp.c @@ -1280,10 +1280,10 @@ PSP_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) PSP_RenderData *renderdata = (PSP_RenderData *) renderer->driverdata; PSP_TextureData *psp_texture = (PSP_TextureData *) texture->driverdata; - if (renderdata == 0) + if (renderdata == NULL) return; - if(psp_texture == 0) + if(psp_texture == NULL) return; LRUTargetRemove(renderdata, psp_texture); diff --git a/src/render/vitagxm/SDL_render_vita_gxm.c b/src/render/vitagxm/SDL_render_vita_gxm.c index 55ffe0cde..1391b19a4 100644 --- a/src/render/vitagxm/SDL_render_vita_gxm.c +++ b/src/render/vitagxm/SDL_render_vita_gxm.c @@ -1236,13 +1236,13 @@ VITA_GXM_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) VITA_GXM_RenderData *data = (VITA_GXM_RenderData *) renderer->driverdata; VITA_GXM_TextureData *vita_texture = (VITA_GXM_TextureData *) texture->driverdata; - if (data == 0) + if (data == NULL) return; - if(vita_texture == 0) + if(vita_texture == NULL) return; - if(vita_texture->tex == 0) + if(vita_texture->tex == NULL) return; sceGxmFinish(data->gxm_context); diff --git a/src/stdlib/SDL_qsort.c b/src/stdlib/SDL_qsort.c index 26e97c908..b0f92fde8 100644 --- a/src/stdlib/SDL_qsort.c +++ b/src/stdlib/SDL_qsort.c @@ -414,7 +414,7 @@ static void qsort_nonaligned(void *base, size_t nmemb, size_t size, char *first,*last; char *pivot=malloc(size); size_t trunc=TRUNC_nonaligned*size; - assert(pivot!=0); + assert(pivot); first=(char*)base; last=first+(nmemb-1)*size; @@ -445,7 +445,7 @@ static void qsort_aligned(void *base, size_t nmemb, size_t size, char *first,*last; char *pivot=malloc(size); size_t trunc=TRUNC_aligned*size; - assert(pivot!=0); + assert(pivot); first=(char*)base; last=first+(nmemb-1)*size; @@ -475,7 +475,7 @@ static void qsort_words(void *base, size_t nmemb, int stacktop=0; char *first,*last; char *pivot=malloc(WORD_BYTES); - assert(pivot!=0); + assert(pivot); first=(char*)base; last=first+(nmemb-1)*WORD_BYTES; diff --git a/src/video/os2/SDL_os2dive.c b/src/video/os2/SDL_os2dive.c index 95aae6f05..56cfde1b3 100644 --- a/src/video/os2/SDL_os2dive.c +++ b/src/video/os2/SDL_os2dive.c @@ -296,7 +296,7 @@ static BOOL voUpdate(PVODATA pVOData, HWND hwnd, SDL_Rect *pSDLRects, return FALSE; } - if (pSDLRects != 0) { + if (pSDLRects != NULL) { PBYTE pbLineMask; pbLineMask = SDL_stack_alloc(BYTE, pVOData->ulHeight); diff --git a/src/video/x11/SDL_x11events.c b/src/video/x11/SDL_x11events.c index 38e1a7965..6b6b834b4 100644 --- a/src/video/x11/SDL_x11events.c +++ b/src/video/x11/SDL_x11events.c @@ -100,7 +100,7 @@ static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop) int bytes_fetch = 0; do { - if (ret != 0) X11_XFree(ret); + if (ret != NULL) X11_XFree(ret); X11_XGetWindowProperty(disp, w, prop, 0, bytes_fetch, False, AnyPropertyType, &type, &fmt, &count, &bytes_left, &ret); bytes_fetch += bytes_left; } while (bytes_left != 0); diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c index 9b007e79d..6d4e53f20 100644 --- a/src/video/x11/SDL_x11window.c +++ b/src/video/x11/SDL_x11window.c @@ -1562,7 +1562,7 @@ static void X11_ReadProperty(SDL_x11Prop *p, Display *disp, Window w, Atom prop) int bytes_fetch = 0; do { - if (ret != 0) X11_XFree(ret); + if (ret != NULL) X11_XFree(ret); X11_XGetWindowProperty(disp, w, prop, 0, bytes_fetch, False, AnyPropertyType, &type, &fmt, &count, &bytes_left, &ret); bytes_fetch += bytes_left; } while (bytes_left != 0); diff --git a/test/testautomation_render.c b/test/testautomation_render.c index 0117334a2..50142f26b 100644 --- a/test/testautomation_render.c +++ b/test/testautomation_render.c @@ -53,7 +53,7 @@ void InitCreateRenderer(void *arg) renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED); SDLTest_AssertPass("SDL_CreateRenderer()"); - SDLTest_AssertCheck(renderer != 0, "Check SDL_CreateRenderer result"); + SDLTest_AssertCheck(renderer, "Check SDL_CreateRenderer result"); if (renderer == NULL) { SDL_DestroyWindow(window); return;