fixed several -Wzero-as-null-pointer-constant warnings from gcc-15

This commit is contained in:
Ozkan Sezer
2025-11-17 17:55:10 +03:00
parent f1145186ea
commit a882afafe5
17 changed files with 124 additions and 128 deletions
@@ -265,7 +265,7 @@ static void draw(SDL_Renderer *renderer, const float (*edges)[6], const Player p
SDL_RenderLine(renderer, hor_origin-10, ver_origin, hor_origin+10, ver_origin);
}
}
SDL_SetRenderClipRect(renderer, 0);
SDL_SetRenderClipRect(renderer, NULL);
SDL_SetRenderDrawColor(renderer, 255, 255, 255, 255);
SDL_RenderDebugText(renderer, 0, 0, debug_string);
SDL_RenderPresent(renderer);
+1 -2
View File
@@ -60,7 +60,6 @@ static const char *GetAppName(void)
if (exe_name) {
return exe_name;
}
return "SDL_App";
}
@@ -244,7 +243,7 @@ static bool FcitxCreateInputContext(SDL_DBusContext *dbus, const char *appname,
DBusMessageIter args, array, sub;
dbus->message_iter_init_append(msg, &args);
dbus->message_iter_open_container(&args, DBUS_TYPE_ARRAY, "(ss)", &array);
dbus->message_iter_open_container(&array, DBUS_TYPE_STRUCT, 0, &sub);
dbus->message_iter_open_container(&array, DBUS_TYPE_STRUCT, NULL, &sub);
dbus->message_iter_append_basic(&sub, DBUS_TYPE_STRING, &program);
dbus->message_iter_append_basic(&sub, DBUS_TYPE_STRING, &appname);
dbus->message_iter_close_container(&array, &sub);
+1 -1
View File
@@ -148,7 +148,7 @@ static bool InitGtk(void)
gtk.g.signal_connect = signal_connect;
if (gtk.gtk.init_check(0, NULL) == GTK_FALSE) {
if (gtk.gtk.init_check(NULL, NULL) == GTK_FALSE) {
QuitGtk();
return SDL_SetError("Could not init GTK");
}
+1 -2
View File
@@ -192,7 +192,6 @@ static SDL_TimerID SDLTest_SetTestTimeout(int timeout, SDL_TimerCallback callbac
SDLTest_LogError("Timeout callback can't be NULL");
return 0;
}
if (timeout < 0) {
SDLTest_LogError("Timeout value must be bigger than zero.");
return 0;
@@ -200,7 +199,7 @@ static SDL_TimerID SDLTest_SetTestTimeout(int timeout, SDL_TimerCallback callbac
/* Set timer */
timeoutInMilliseconds = timeout * 1000;
timerID = SDL_AddTimer(timeoutInMilliseconds, callback, 0x0);
timerID = SDL_AddTimer(timeoutInMilliseconds, callback, NULL);
if (timerID == 0) {
SDLTest_LogError("Creation of SDL timer failed: %s", SDL_GetError());
return 0;
+2 -4
View File
@@ -20,9 +20,7 @@
*/
/*
Used by the test framework and test cases.
*/
/* quiet windows compiler warnings */
@@ -89,7 +87,7 @@ void SDLTest_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
va_end(list);
/* Log with timestamp and newline */
SDL_LogMessage(SDL_LOG_CATEGORY_TEST, SDL_LOG_PRIORITY_INFO, " %s: %s", SDLTest_TimestampToString(time(0)), logMessage);
SDL_LogMessage(SDL_LOG_CATEGORY_TEST, SDL_LOG_PRIORITY_INFO, " %s: %s", SDLTest_TimestampToString(time(NULL)), logMessage);
}
/*
@@ -107,7 +105,7 @@ void SDLTest_LogError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
va_end(list);
/* Log with timestamp and newline */
SDL_LogMessage(SDL_LOG_CATEGORY_TEST, SDL_LOG_PRIORITY_ERROR, "%s: %s", SDLTest_TimestampToString(time(0)), logMessage);
SDL_LogMessage(SDL_LOG_CATEGORY_TEST, SDL_LOG_PRIORITY_ERROR, "%s: %s", SDLTest_TimestampToString(time(NULL)), logMessage);
}
static char nibble_to_char(Uint8 nibble)
+2 -2
View File
@@ -166,7 +166,7 @@ void SDL_SYS_SetupThread(const char *name)
for (i = 0; sig_list[i]; ++i) {
sigaddset(&mask, sig_list[i]);
}
pthread_sigmask(SIG_BLOCK, &mask, 0);
pthread_sigmask(SIG_BLOCK, &mask, NULL);
#endif
#ifdef PTHREAD_CANCEL_ASYNCHRONOUS
@@ -284,7 +284,7 @@ bool SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
void SDL_SYS_WaitThread(SDL_Thread *thread)
{
pthread_join(thread->handle, 0);
pthread_join(thread->handle, NULL);
}
void SDL_SYS_DetachThread(SDL_Thread *thread)
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -90,7 +90,7 @@ void SDL_Blit_Slow(SDL_BlitInfo *info)
posy = incy / 2; // start at the middle of pixel
while (info->dst_h--) {
Uint8 *src = 0;
Uint8 *src = NULL;
Uint8 *dst = info->dst;
int n = info->dst_w;
posx = incx / 2; // start at the middle of pixel
@@ -897,7 +897,7 @@ void SDL_Blit_Slow_Float(SDL_BlitInfo *info)
posy = incy / 2; // start at the middle of pixel
while (info->dst_h--) {
Uint8 *src = 0;
Uint8 *src = NULL;
Uint8 *dst = info->dst;
int n = info->dst_w;
posx = incx / 2; // start at the middle of pixel
+1 -1
View File
@@ -1727,7 +1727,7 @@ SDL_VideoDisplay *SDL_GetVideoDisplayForFullscreenWindow(SDL_Window *window)
{
SDL_DisplayID displayID = 0;
CHECK_WINDOW_MAGIC(window, 0);
CHECK_WINDOW_MAGIC(window, NULL);
// An explicit fullscreen display overrides all
if (window->current_fullscreen_mode.displayID) {
+1 -1
View File
@@ -593,7 +593,7 @@ __EOF__
posy = incy / 2;
while (info->dst_h--) {
$format_type{$src} *src = 0;
$format_type{$src} *src = NULL;
$format_type{$dst} *dst = ($format_type{$dst} *)info->dst;
int n = info->dst_w;
posx = incx / 2;
+4 -4
View File
@@ -3408,8 +3408,8 @@ static int stbi__free_jpeg_components(stbi__jpeg *z, int ncomp, int why)
}
if (z->img_comp[i].raw_coeff) {
STBI_FREE(z->img_comp[i].raw_coeff);
z->img_comp[i].raw_coeff = 0;
z->img_comp[i].coeff = 0;
z->img_comp[i].raw_coeff = NULL;
z->img_comp[i].coeff = NULL;
}
if (z->img_comp[i].linebuf) {
STBI_FREE(z->img_comp[i].linebuf);
@@ -3489,8 +3489,8 @@ static int stbi__process_frame_header(stbi__jpeg *z, int scan)
// so these muls can't overflow with 32-bit ints (which we require)
z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8;
z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8;
z->img_comp[i].coeff = 0;
z->img_comp[i].raw_coeff = 0;
z->img_comp[i].coeff = NULL;
z->img_comp[i].raw_coeff = NULL;
z->img_comp[i].linebuf = NULL;
z->img_comp[i].raw_data = stbi__malloc_mad2(z->img_comp[i].w2, z->img_comp[i].h2, 15);
if (z->img_comp[i].raw_data == NULL)
+2 -2
View File
@@ -52,7 +52,7 @@ Window GetWindow(SDL_VideoDevice *_this)
XSetWindowAttributes xattr;
data->clipboard_window = X11_XCreateWindow(dpy, parent, -10, -10, 1, 1, 0,
CopyFromParent, InputOnly,
CopyFromParent, 0, &xattr);
NULL, 0, &xattr);
X11_XSelectInput(dpy, data->clipboard_window, PropertyChangeMask);
X11_XFlush(data->display);
@@ -248,7 +248,7 @@ static void *GetSelectionData(SDL_VideoDevice *_this, Atom selection_type,
if (incr_success == false) {
SDL_free(data);
data = 0;
data = NULL;
*length = 0;
}
}
+1 -1
View File
@@ -89,7 +89,7 @@ bool X11_CreateWindowFramebuffer(SDL_VideoDevice *_this, SDL_Window *window, SDL
shminfo->shmid = shmget(IPC_PRIVATE, (size_t)h * (*pitch), IPC_CREAT | 0777);
if (shminfo->shmid >= 0) {
shminfo->shmaddr = (char *)shmat(shminfo->shmid, 0, 0);
shminfo->shmaddr = (char *)shmat(shminfo->shmid, NULL, 0);
shminfo->readOnly = False;
if (shminfo->shmaddr != (char *)-1) {
shm_error = False;
+2 -2
View File
@@ -342,9 +342,9 @@ static void X11_GL_InitExtensions(SDL_VideoDevice *_this)
const int screen = DefaultScreen(display);
XVisualInfo *vinfo = NULL;
Window w = 0;
GLXContext prev_ctx = 0;
GLXContext prev_ctx = NULL;
GLXDrawable prev_drawable = 0;
GLXContext context = 0;
GLXContext context = NULL;
const char *(*glXQueryExtensionsStringFunc)(Display *, int);
const char *extensions;
+2 -2
View File
@@ -202,9 +202,9 @@ static X11_PenHandle *X11_MaybeAddPen(SDL_VideoDevice *_this, const XIDeviceInfo
if ((dev->use != XISlavePointer && (dev->use != XIFloatingSlave)) || dev->enabled == 0 || !X11_XInput2DeviceIsPen(_this, dev)) {
return NULL; // Only track physical devices that are enabled and look like pens
} else if ((handle = X11_FindPenByDeviceID(dev->deviceid)) != 0) {
} else if ((handle = X11_FindPenByDeviceID(dev->deviceid)) != NULL) {
return handle; // already have this pen, skip it.
} else if ((handle = SDL_calloc(1, sizeof (*handle))) == NULL) {
} else if ((handle = SDL_calloc(1, sizeof(*handle))) == NULL) {
return NULL; // oh well.
}
+3 -3
View File
@@ -216,7 +216,7 @@ static void X11Toolkit_InitWindowPixmap(SDL_ToolkitWindowX11 *data) {
}
data->shm_info.readOnly = False;
data->shm_info.shmaddr = data->image->data = (char *)shmat(data->shm_info.shmid, 0, 0);
data->shm_info.shmaddr = data->image->data = (char *)shmat(data->shm_info.shmid, NULL, 0);
if (((signed char *)data->shm_info.shmaddr) == (signed char *)-1) {
XDestroyImage(data->image);
data->shm = false;
@@ -232,7 +232,7 @@ static void X11Toolkit_InitWindowPixmap(SDL_ToolkitWindowX11 *data) {
if (g_shm_error) {
XDestroyImage(data->image);
shmdt(data->shm_info.shmaddr);
shmctl(data->shm_info.shmid, IPC_RMID, 0);
shmctl(data->shm_info.shmid, IPC_RMID, NULL);
data->image = NULL;
data->shm = false;
return;
@@ -248,7 +248,7 @@ static void X11Toolkit_InitWindowPixmap(SDL_ToolkitWindowX11 *data) {
}
}
shmctl(data->shm_info.shmid, IPC_RMID, 0);
shmctl(data->shm_info.shmid, IPC_RMID, NULL);
} else {
data->shm = false;
}
+2 -2
View File
@@ -880,13 +880,13 @@ int main(int argc, char *argv[])
GL_CHECK(ctx.glGenBuffers(1, &data->position_buffer));
GL_CHECK(ctx.glBindBuffer(GL_ARRAY_BUFFER, data->position_buffer));
GL_CHECK(ctx.glBufferData(GL_ARRAY_BUFFER, sizeof(g_vertices), g_vertices, GL_STATIC_DRAW));
GL_CHECK(ctx.glVertexAttribPointer(data->attr_position, 3, GL_FLOAT, GL_FALSE, 0, 0));
GL_CHECK(ctx.glVertexAttribPointer(data->attr_position, 3, GL_FLOAT, GL_FALSE, 0, NULL));
GL_CHECK(ctx.glBindBuffer(GL_ARRAY_BUFFER, 0));
GL_CHECK(ctx.glGenBuffers(1, &data->color_buffer));
GL_CHECK(ctx.glBindBuffer(GL_ARRAY_BUFFER, data->color_buffer));
GL_CHECK(ctx.glBufferData(GL_ARRAY_BUFFER, sizeof(g_colors), g_colors, GL_STATIC_DRAW));
GL_CHECK(ctx.glVertexAttribPointer(data->attr_color, 3, GL_FLOAT, GL_FALSE, 0, 0));
GL_CHECK(ctx.glVertexAttribPointer(data->attr_color, 3, GL_FLOAT, GL_FALSE, 0, NULL));
GL_CHECK(ctx.glBindBuffer(GL_ARRAY_BUFFER, 0));
GL_CHECK(ctx.glEnable(GL_CULL_FACE));