From 189be035d2e1093a80eaec826d62dd996e315901 Mon Sep 17 00:00:00 2001 From: rilysh Date: Sun, 21 Jul 2024 12:49:06 +0530 Subject: [PATCH] Mark plat_vidapi() argument as const and remove the NULL * plat_vidapi() accepts char pointer, which never gets modifed later on. Mark it as const. * In src/config.c, va_name is initialized as NULL, however, plat_vidapi_name() never returns a NULL pointer, nor it was initialized under a condition branch. Removing NULL, might save one instruction, which requires zeroing the register before setting its initial value. --- src/config.c | 2 +- src/include/86box/plat.h | 2 +- src/qt/qt.c | 2 +- src/unix/unix_sdl.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/config.c b/src/config.c index 23b78f117..2c0781028 100644 --- a/src/config.c +++ b/src/config.c @@ -1720,7 +1720,7 @@ save_general(void) char temp[512]; char buffer[512] = { 0 }; - const char *va_name = NULL; + const char *va_name; ini_section_set_int(cat, "vid_resize", vid_resize); if (vid_resize == 0) diff --git a/src/include/86box/plat.h b/src/include/86box/plat.h index 26f5d5cc8..4a310ab44 100644 --- a/src/include/86box/plat.h +++ b/src/include/86box/plat.h @@ -153,7 +153,7 @@ extern uint32_t plat_get_ticks(void); extern void plat_delay_ms(uint32_t count); extern void plat_pause(int p); extern void plat_mouse_capture(int on); -extern int plat_vidapi(char *name); +extern int plat_vidapi(const char *name); extern char *plat_vidapi_name(int api); extern void plat_resize(int x, int y, int monitor_index); extern void plat_resize_request(int x, int y, int monitor_index); diff --git a/src/qt/qt.c b/src/qt/qt.c index 47f5b9410..a9a6460eb 100644 --- a/src/qt/qt.c +++ b/src/qt/qt.c @@ -38,7 +38,7 @@ qt_nvr_save(void) char icon_set[256] = ""; /* name of the iconset to be used */ int -plat_vidapi(char *api) +plat_vidapi(const char *api) { if (!strcasecmp(api, "default") || !strcasecmp(api, "system")) { return 0; diff --git a/src/unix/unix_sdl.c b/src/unix/unix_sdl.c index c7cc898be..002e33fd6 100644 --- a/src/unix/unix_sdl.c +++ b/src/unix/unix_sdl.c @@ -392,7 +392,7 @@ sdl_reload(void) } int -plat_vidapi(char *api) +plat_vidapi(UNUSED(const char *api)) { return 0; }