static variables are initialized to '0' automatically as per C rules

This commit is contained in:
libretroadmin 2024-11-18 15:33:34 +01:00
parent 62fd7e105d
commit 2a0984b6e4
23 changed files with 544 additions and 544 deletions

View File

@ -172,7 +172,7 @@ audio_driver_t *audio_drivers[] = {
NULL, NULL,
}; };
static audio_driver_state_t audio_driver_st = {0}; /* double alignment */ static audio_driver_state_t audio_driver_st; /* double alignment */
/**************************************/ /**************************************/
@ -1872,7 +1872,7 @@ bool audio_compute_buffer_statistics(audio_statistics_t *stats)
#ifdef HAVE_MENU #ifdef HAVE_MENU
void audio_driver_menu_sample(void) void audio_driver_menu_sample(void)
{ {
static int16_t samples_buf[1024] = {0}; static int16_t samples_buf[1024];
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
video_driver_state_t *video_st = video_state_get_ptr(); video_driver_state_t *video_st = video_state_get_ptr();
uint32_t runloop_flags = runloop_get_flags(); uint32_t runloop_flags = runloop_get_flags();

View File

@ -85,7 +85,7 @@ static uint8_t g_plat_win32_flags = PLAT_WIN32_FLAG_USE_POWERSHELL;
VOID (WINAPI *DragAcceptFiles_func)(HWND, BOOL); VOID (WINAPI *DragAcceptFiles_func)(HWND, BOOL);
/* TODO/FIXME - static global variables */ /* TODO/FIXME - static global variables */
static char win32_cpu_model_name[64] = {0}; static char win32_cpu_model_name[64];
#ifdef HAVE_DYLIB #ifdef HAVE_DYLIB
/* We only load this library once, so we let it be /* We only load this library once, so we let it be
* unloaded at application shutdown, since unloading * unloaded at application shutdown, since unloading

View File

@ -43,10 +43,10 @@ static void android_display_server_set_screen_orientation(void *data,
static void android_display_dpi_get_density(char *s, size_t len) static void android_display_dpi_get_density(char *s, size_t len)
{ {
static char string[PROP_VALUE_MAX];
static char string2[PROP_VALUE_MAX];
static bool inited_once = false; static bool inited_once = false;
static bool inited2_once = false; static bool inited2_once = false;
static char string[PROP_VALUE_MAX] = {0};
static char string2[PROP_VALUE_MAX] = {0};
if (!inited_once) if (!inited_once)
{ {
system_property_get("getprop", "ro.sf.lcd_density", string); system_property_get("getprop", "ro.sf.lcd_density", string);

View File

@ -85,7 +85,7 @@ typedef struct omapfb_data
static const char *omapfb_get_fb_device(void) static const char *omapfb_get_fb_device(void)
{ {
static char fbname[12] = {0}; static char fbname[12];
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
const int fbidx = settings->uints.video_monitor_index; const int fbidx = settings->uints.video_monitor_index;

View File

@ -35,7 +35,7 @@
static uintptr_t gfx_white_texture; static uintptr_t gfx_white_texture;
/* ptr alignment */ /* ptr alignment */
static gfx_display_t dispgfx_st = {0}; static gfx_display_t dispgfx_st;
gfx_display_t *disp_get_ptr(void) gfx_display_t *disp_get_ptr(void)
{ {

View File

@ -46,7 +46,7 @@ typedef struct
gfx_thumbnail_t *thumbnail; gfx_thumbnail_t *thumbnail;
} gfx_thumbnail_tag_t; } gfx_thumbnail_tag_t;
static gfx_thumbnail_state_t gfx_thumb_st = {0}; /* uint64_t alignment */ static gfx_thumbnail_state_t gfx_thumb_st; /* uint64_t alignment */
gfx_thumbnail_state_t *gfx_thumb_get_ptr(void) gfx_thumbnail_state_t *gfx_thumb_get_ptr(void)
{ {
@ -289,10 +289,10 @@ void gfx_thumbnail_request(
/* Handle on demand thumbnail downloads */ /* Handle on demand thumbnail downloads */
else if (network_on_demand_thumbnails) else if (network_on_demand_thumbnails)
{ {
static char last_img_name[NAME_MAX_LENGTH];
enum playlist_thumbnail_name_flags curr_flag; enum playlist_thumbnail_name_flags curr_flag;
const char *system = NULL; const char *system = NULL;
const char *img_name = NULL; const char *img_name = NULL;
static char last_img_name[NAME_MAX_LENGTH] = {0};
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
if (!playlist) if (!playlist)
goto end; goto end;

View File

@ -65,7 +65,7 @@ static const char
"menu_achievements.png" "menu_achievements.png"
}; };
static dispgfx_widget_t dispwidget_st = {0}; /* uint64_t alignment */ static dispgfx_widget_t dispwidget_st; /* uint64_t alignment */
static void INLINE gfx_widgets_font_free(gfx_widget_font_data_t *font_data) static void INLINE gfx_widgets_font_free(gfx_widget_font_data_t *font_data)
{ {

View File

@ -515,12 +515,12 @@ static void crt_rpi_switch(videocrt_switch_t *p_switch,
{ {
int w; int w;
char buffer[1024]; char buffer[1024];
static char output1[250];
static char output2[250];
static char set_hdmi[250];
static char set_hdmi_timing[250];
VCHI_INSTANCE_T vchi_instance; VCHI_INSTANCE_T vchi_instance;
VCHI_CONNECTION_T *vchi_connection = NULL; VCHI_CONNECTION_T *vchi_connection = NULL;
static char output1[250] = {0};
static char output2[250] = {0};
static char set_hdmi[250] = {0};
static char set_hdmi_timing[250] = {0};
int i = 0; int i = 0;
int hfp = 0; int hfp = 0;
int hsp = 0; int hsp = 0;

View File

@ -3229,10 +3229,10 @@ const char* video_driver_get_gpu_api_version_string(void)
bool video_driver_init_internal(bool *video_is_threaded, bool verbosity_enabled) bool video_driver_init_internal(bool *video_is_threaded, bool verbosity_enabled)
{ {
video_info_t video; video_info_t video;
static uint16_t dummy_pixels[32];
unsigned max_dim, scale, width, height; unsigned max_dim, scale, width, height;
video_viewport_t *custom_vp = NULL; video_viewport_t *custom_vp = NULL;
input_driver_t *tmp = NULL; input_driver_t *tmp = NULL;
static uint16_t dummy_pixels[32] = {0};
runloop_state_t *runloop_st = runloop_state_get_ptr(); runloop_state_t *runloop_st = runloop_state_get_ptr();
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
input_driver_state_t *input_st = input_state_get_ptr(); input_driver_state_t *input_st = input_state_get_ptr();

View File

@ -63,7 +63,7 @@ enum sdl_webos_special_key
sdl_webos_spkey_size, sdl_webos_spkey_size,
}; };
static uint8_t sdl_webos_special_keymap[sdl_webos_spkey_size] = {0}; static uint8_t sdl_webos_special_keymap[sdl_webos_spkey_size];
#endif #endif
static void *sdl_input_init(const char *joypad_driver) static void *sdl_input_init(const char *joypad_driver)
@ -249,7 +249,7 @@ static int16_t sdl_input_state(
if (idx == 0) if (idx == 0)
{ {
struct video_viewport vp; struct video_viewport vp;
bool screen = device == bool screen = device ==
RARCH_DEVICE_POINTER_SCREEN; RARCH_DEVICE_POINTER_SCREEN;
const int edge_detect = 32700; const int edge_detect = 32700;
bool inside = false; bool inside = false;
@ -275,7 +275,7 @@ static int16_t sdl_input_state(
res_y = res_screen_y; res_y = res_screen_y;
} }
inside = (res_x >= -edge_detect) inside = (res_x >= -edge_detect)
&& (res_y >= -edge_detect) && (res_y >= -edge_detect)
&& (res_x <= edge_detect) && (res_x <= edge_detect)
&& (res_y <= edge_detect); && (res_y <= edge_detect);
@ -397,7 +397,7 @@ static void sdl_input_poll(void *data)
switch ((int) event.key.keysym.scancode) switch ((int) event.key.keysym.scancode)
{ {
case SDL_WEBOS_SCANCODE_BACK: case SDL_WEBOS_SCANCODE_BACK:
/* Because webOS is sending DOWN/UP at the same time, /* Because webOS is sending DOWN/UP at the same time,
we save this flag for later */ we save this flag for later */
sdl_webos_special_keymap[sdl_webos_spkey_back] |= event.type == SDL_KEYDOWN; sdl_webos_special_keymap[sdl_webos_spkey_back] |= event.type == SDL_KEYDOWN;
code = RETROK_BACKSPACE; code = RETROK_BACKSPACE;

View File

@ -396,7 +396,7 @@ hid_driver_t *hid_drivers[] = {
}; };
#endif #endif
static input_driver_state_t input_driver_st = {0}; /* double alignment */ static input_driver_state_t input_driver_st; /* double alignment */
/**************************************/ /**************************************/

View File

@ -518,7 +518,7 @@ static const char *menu_hash_to_str_us_label_enum(enum msg_hash_enums msg)
if ( msg <= MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_END if ( msg <= MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_END
&& msg >= MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_BEGIN) && msg >= MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_BEGIN)
{ {
static char hotkey_lbl[128] = {0}; static char hotkey_lbl[128];
unsigned idx = msg - MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_BEGIN; unsigned idx = msg - MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_BEGIN;
snprintf(hotkey_lbl, sizeof(hotkey_lbl), "input_hotkey_binds_%d", idx); snprintf(hotkey_lbl, sizeof(hotkey_lbl), "input_hotkey_binds_%d", idx);
return hotkey_lbl; return hotkey_lbl;

View File

@ -97,7 +97,7 @@ static bool rzipstream_read_file_header(rzipstream_t *stream)
/* Check 'magic numbers' - first 8 bytes /* Check 'magic numbers' - first 8 bytes
* of header */ * of header */
if ( if (
(length < RZIP_HEADER_SIZE) || (length < RZIP_HEADER_SIZE) ||
(header_bytes[0] != 35) || /* # */ (header_bytes[0] != 35) || /* # */
(header_bytes[1] != 82) || /* R */ (header_bytes[1] != 82) || /* R */
(header_bytes[2] != 90) || /* Z */ (header_bytes[2] != 90) || /* Z */
@ -270,7 +270,7 @@ static bool rzipstream_init_stream(
stream->in_buf_size = stream->chunk_size; stream->in_buf_size = stream->chunk_size;
stream->out_buf_size = stream->chunk_size * 2; stream->out_buf_size = stream->chunk_size * 2;
/* > Account for minimum zlib overhead /* > Account for minimum zlib overhead
* of 11 bytes... */ * of 11 bytes... */
stream->out_buf_size = stream->out_buf_size =
(stream->out_buf_size < (stream->in_buf_size + 11)) ? (stream->out_buf_size < (stream->in_buf_size + 11)) ?
stream->out_buf_size + 11 : stream->out_buf_size + 11 :
@ -846,7 +846,7 @@ int rzipstream_putc(rzipstream_t *stream, int c)
* in the event of an error */ * in the event of an error */
int rzipstream_vprintf(rzipstream_t *stream, const char* format, va_list args) int rzipstream_vprintf(rzipstream_t *stream, const char* format, va_list args)
{ {
static char buffer[8 * 1024] = {0}; static char buffer[8 * 1024];
int64_t num_chars = vsnprintf(buffer, int64_t num_chars = vsnprintf(buffer,
sizeof(buffer), format, args); sizeof(buffer), format, args);

View File

@ -211,10 +211,10 @@ static struct rmsgpack_dom_value query_func_between(
if (argc != 2) if (argc != 2)
return res; return res;
if ( argv[0].type != AT_VALUE if ( argv[0].type != AT_VALUE
|| argv[1].type != AT_VALUE) || argv[1].type != AT_VALUE)
return res; return res;
if ( argv[0].a.value.type != RDT_INT if ( argv[0].a.value.type != RDT_INT
|| argv[1].a.value.type != RDT_INT) || argv[1].a.value.type != RDT_INT)
return res; return res;
@ -301,7 +301,7 @@ static void query_argument_free(struct argument *arg)
} }
static struct buffer query_parse_integer( static struct buffer query_parse_integer(
char *s, size_t len, char *s, size_t len,
struct buffer buff, struct buffer buff,
struct rmsgpack_dom_value *value, struct rmsgpack_dom_value *value,
const char **error) const char **error)
@ -495,7 +495,7 @@ static struct buffer query_parse_value(
} }
else if ( else if (
query_peek(buff, "b", STRLEN_CONST("b")) query_peek(buff, "b", STRLEN_CONST("b"))
|| query_peek(buff, "\"", STRLEN_CONST("\"")) || query_peek(buff, "\"", STRLEN_CONST("\""))
|| query_peek(buff, "'", STRLEN_CONST("'"))) || query_peek(buff, "'", STRLEN_CONST("'")))
buff = query_parse_string(s, len, buff = query_parse_string(s, len,
buff, value, error); buff, value, error);
@ -921,7 +921,7 @@ void *libretrodb_query_compile(libretrodb_t *db,
{ {
struct buffer buff; struct buffer buff;
/* TODO/FIXME - static local variable */ /* TODO/FIXME - static local variable */
static char tmp_error_buff [MAX_ERROR_LEN] = {0}; static char tmp_error_buff [MAX_ERROR_LEN];
struct query *q = (struct query*)malloc(sizeof(*q)); struct query *q = (struct query*)malloc(sizeof(*q));
size_t error_buff_len = sizeof(tmp_error_buff); size_t error_buff_len = sizeof(tmp_error_buff);

View File

@ -5212,7 +5212,7 @@ void cb_generic_download(retro_task_t *task,
case MENU_ENUM_LABEL_CB_UPDATE_SHADERS_SLANG: case MENU_ENUM_LABEL_CB_UPDATE_SHADERS_SLANG:
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL) #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
{ {
static char shaderdir[DIR_MAX_LENGTH] = {0}; static char shaderdir[DIR_MAX_LENGTH];
const char *dirname = NULL; const char *dirname = NULL;
const char *dir_video_shader = settings->paths.directory_video_shader; const char *dir_video_shader = settings->paths.directory_video_shader;

View File

@ -1,245 +1,245 @@
/* RetroArch - A frontend for libretro. /* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2021 - Daniel De Matteis * Copyright (C) 2011-2021 - Daniel De Matteis
* *
* RetroArch is free software: you can redistribute it and/or modify it under the terms * RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found- * of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version. * ation, either version 3 of the License, or (at your option) any later version.
* *
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details. * PURPOSE. See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License along with RetroArch. * You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <stdint.h> #include <stdint.h>
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "../config.h" #include "../config.h"
#endif #endif
#include "../driver.h" #include "../driver.h"
#include "../list_special.h" #include "../list_special.h"
#include "../retroarch.h" #include "../retroarch.h"
#include "../runloop.h" #include "../runloop.h"
#include "../verbosity.h" #include "../verbosity.h"
#include "wifi_driver.h" #include "wifi_driver.h"
wifi_driver_t wifi_null = { wifi_driver_t wifi_null = {
NULL, /* init */ NULL, /* init */
NULL, /* free */ NULL, /* free */
NULL, /* start */ NULL, /* start */
NULL, /* stop */ NULL, /* stop */
NULL, /* enable */ NULL, /* enable */
NULL, /* connection_info */ NULL, /* connection_info */
NULL, /* scan */ NULL, /* scan */
NULL, /* get_ssids */ NULL, /* get_ssids */
NULL, /* ssid_is_online */ NULL, /* ssid_is_online */
NULL, /* connect_ssid */ NULL, /* connect_ssid */
NULL, /* disconnect_ssid */ NULL, /* disconnect_ssid */
NULL, /* tether_start_stop */ NULL, /* tether_start_stop */
"null", "null",
}; };
const wifi_driver_t *wifi_drivers[] = { const wifi_driver_t *wifi_drivers[] = {
#ifdef HAVE_LAKKA #ifdef HAVE_LAKKA
&wifi_connmanctl, &wifi_connmanctl,
#endif #endif
#ifdef HAVE_WIFI #ifdef HAVE_WIFI
&wifi_nmcli, &wifi_nmcli,
#endif #endif
&wifi_null, &wifi_null,
NULL, NULL,
}; };
static wifi_driver_state_t wifi_driver_st = {0}; /* double alignment */ static wifi_driver_state_t wifi_driver_st; /* double alignment */
wifi_driver_state_t *wifi_state_get_ptr(void) wifi_driver_state_t *wifi_state_get_ptr(void)
{ {
return &wifi_driver_st; return &wifi_driver_st;
} }
/** /**
* config_get_wifi_driver_options: * config_get_wifi_driver_options:
* *
* Get an enumerated list of all wifi driver names, * Get an enumerated list of all wifi driver names,
* separated by '|'. * separated by '|'.
* *
* Returns: string listing of all wifi driver names, * Returns: string listing of all wifi driver names,
* separated by '|'. * separated by '|'.
**/ **/
const char* config_get_wifi_driver_options(void) const char* config_get_wifi_driver_options(void)
{ {
return char_list_new_special(STRING_LIST_WIFI_DRIVERS, NULL); return char_list_new_special(STRING_LIST_WIFI_DRIVERS, NULL);
} }
void driver_wifi_scan(void) void driver_wifi_scan(void)
{ {
wifi_driver_state_t *wifi_st = &wifi_driver_st; wifi_driver_state_t *wifi_st = &wifi_driver_st;
if (wifi_st && wifi_st->drv) if (wifi_st && wifi_st->drv)
wifi_st->drv->scan(wifi_st->data); wifi_st->drv->scan(wifi_st->data);
} }
bool driver_wifi_enable(bool enabled) bool driver_wifi_enable(bool enabled)
{ {
wifi_driver_state_t *wifi_st = &wifi_driver_st; wifi_driver_state_t *wifi_st = &wifi_driver_st;
if (wifi_st && wifi_st->drv) if (wifi_st && wifi_st->drv)
return wifi_st->drv->enable(wifi_st->data, enabled); return wifi_st->drv->enable(wifi_st->data, enabled);
return false; return false;
} }
bool driver_wifi_connection_info(wifi_network_info_t *netinfo) bool driver_wifi_connection_info(wifi_network_info_t *netinfo)
{ {
wifi_driver_state_t *wifi_st = &wifi_driver_st; wifi_driver_state_t *wifi_st = &wifi_driver_st;
if (wifi_st && wifi_st->drv) if (wifi_st && wifi_st->drv)
return wifi_st->drv->connection_info(wifi_st->data, netinfo); return wifi_st->drv->connection_info(wifi_st->data, netinfo);
return false; return false;
} }
wifi_network_scan_t* driver_wifi_get_ssids(void) wifi_network_scan_t* driver_wifi_get_ssids(void)
{ {
wifi_driver_state_t *wifi_st = &wifi_driver_st; wifi_driver_state_t *wifi_st = &wifi_driver_st;
if (wifi_st && wifi_st->drv) if (wifi_st && wifi_st->drv)
return wifi_st->drv->get_ssids(wifi_st->data); return wifi_st->drv->get_ssids(wifi_st->data);
return NULL; return NULL;
} }
bool driver_wifi_ssid_is_online(unsigned i) bool driver_wifi_ssid_is_online(unsigned i)
{ {
wifi_driver_state_t *wifi_st = &wifi_driver_st; wifi_driver_state_t *wifi_st = &wifi_driver_st;
if (wifi_st && wifi_st->drv) if (wifi_st && wifi_st->drv)
return wifi_st->drv->ssid_is_online(wifi_st->data, i); return wifi_st->drv->ssid_is_online(wifi_st->data, i);
return false; return false;
} }
bool driver_wifi_connect_ssid(const wifi_network_info_t* net) bool driver_wifi_connect_ssid(const wifi_network_info_t* net)
{ {
wifi_driver_state_t *wifi_st = &wifi_driver_st; wifi_driver_state_t *wifi_st = &wifi_driver_st;
if (wifi_st && wifi_st->drv) if (wifi_st && wifi_st->drv)
return wifi_st->drv->connect_ssid(wifi_st->data, net); return wifi_st->drv->connect_ssid(wifi_st->data, net);
return false; return false;
} }
bool driver_wifi_disconnect_ssid(const wifi_network_info_t* net) bool driver_wifi_disconnect_ssid(const wifi_network_info_t* net)
{ {
wifi_driver_state_t *wifi_st = &wifi_driver_st; wifi_driver_state_t *wifi_st = &wifi_driver_st;
if (wifi_st && wifi_st->drv) if (wifi_st && wifi_st->drv)
return wifi_st->drv->disconnect_ssid(wifi_st->data, net); return wifi_st->drv->disconnect_ssid(wifi_st->data, net);
return false; return false;
} }
void driver_wifi_tether_start_stop(bool start, char* configfile) void driver_wifi_tether_start_stop(bool start, char* configfile)
{ {
wifi_driver_state_t *wifi_st = &wifi_driver_st; wifi_driver_state_t *wifi_st = &wifi_driver_st;
if (wifi_st && wifi_st->drv) if (wifi_st && wifi_st->drv)
wifi_st->drv->tether_start_stop(wifi_st->data, start, configfile); wifi_st->drv->tether_start_stop(wifi_st->data, start, configfile);
} }
bool wifi_driver_ctl(enum rarch_wifi_ctl_state state, void *data) bool wifi_driver_ctl(enum rarch_wifi_ctl_state state, void *data)
{ {
wifi_driver_state_t *wifi_st = &wifi_driver_st; wifi_driver_state_t *wifi_st = &wifi_driver_st;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
switch (state) switch (state)
{ {
case RARCH_WIFI_CTL_DESTROY: case RARCH_WIFI_CTL_DESTROY:
wifi_st->active = false; wifi_st->active = false;
wifi_st->drv = NULL; wifi_st->drv = NULL;
wifi_st->data = NULL; wifi_st->data = NULL;
break; break;
case RARCH_WIFI_CTL_SET_ACTIVE: case RARCH_WIFI_CTL_SET_ACTIVE:
wifi_st->active = true; wifi_st->active = true;
break; break;
case RARCH_WIFI_CTL_FIND_DRIVER: case RARCH_WIFI_CTL_FIND_DRIVER:
{ {
const char *prefix = "wifi driver"; const char *prefix = "wifi driver";
int i = (int)driver_find_index( int i = (int)driver_find_index(
"wifi_driver", "wifi_driver",
settings->arrays.wifi_driver); settings->arrays.wifi_driver);
if (i >= 0) if (i >= 0)
wifi_st->drv = (const wifi_driver_t*)wifi_drivers[i]; wifi_st->drv = (const wifi_driver_t*)wifi_drivers[i];
else else
{ {
if (verbosity_is_enabled()) if (verbosity_is_enabled())
{ {
unsigned d; unsigned d;
RARCH_ERR("Couldn't find any %s named \"%s\"\n", prefix, RARCH_ERR("Couldn't find any %s named \"%s\"\n", prefix,
settings->arrays.wifi_driver); settings->arrays.wifi_driver);
RARCH_LOG_OUTPUT("Available %ss are:\n", prefix); RARCH_LOG_OUTPUT("Available %ss are:\n", prefix);
for (d = 0; wifi_drivers[d]; d++) for (d = 0; wifi_drivers[d]; d++)
RARCH_LOG_OUTPUT("\t%s\n", wifi_drivers[d]->ident); RARCH_LOG_OUTPUT("\t%s\n", wifi_drivers[d]->ident);
RARCH_WARN("Going to default to first %s...\n", prefix); RARCH_WARN("Going to default to first %s...\n", prefix);
} }
wifi_st->drv = (const wifi_driver_t*)wifi_drivers[0]; wifi_st->drv = (const wifi_driver_t*)wifi_drivers[0];
if (!wifi_st->drv) if (!wifi_st->drv)
retroarch_fail(1, "find_wifi_driver()"); retroarch_fail(1, "find_wifi_driver()");
} }
} }
break; break;
case RARCH_WIFI_CTL_UNSET_ACTIVE: case RARCH_WIFI_CTL_UNSET_ACTIVE:
wifi_st->active = false; wifi_st->active = false;
break; break;
case RARCH_WIFI_CTL_IS_ACTIVE: case RARCH_WIFI_CTL_IS_ACTIVE:
return wifi_st->active; return wifi_st->active;
case RARCH_WIFI_CTL_DEINIT: case RARCH_WIFI_CTL_DEINIT:
if (wifi_st->data && wifi_st->drv) if (wifi_st->data && wifi_st->drv)
{ {
if (wifi_st->drv->free) if (wifi_st->drv->free)
wifi_st->drv->free(wifi_st->data); wifi_st->drv->free(wifi_st->data);
} }
wifi_st->data = NULL; wifi_st->data = NULL;
break; break;
case RARCH_WIFI_CTL_STOP: case RARCH_WIFI_CTL_STOP:
if ( wifi_st->drv if ( wifi_st->drv
&& wifi_st->drv->stop && wifi_st->drv->stop
&& wifi_st->data) && wifi_st->data)
wifi_st->drv->stop(wifi_st->data); wifi_st->drv->stop(wifi_st->data);
break; break;
case RARCH_WIFI_CTL_START: case RARCH_WIFI_CTL_START:
if ( wifi_st->drv if ( wifi_st->drv
&& wifi_st->data && wifi_st->data
&& wifi_st->drv->start) && wifi_st->drv->start)
{ {
bool wifi_allow = settings->bools.wifi_allow; bool wifi_allow = settings->bools.wifi_allow;
if (wifi_allow) if (wifi_allow)
return wifi_st->drv->start(wifi_st->data); return wifi_st->drv->start(wifi_st->data);
} }
return false; return false;
case RARCH_WIFI_CTL_INIT: case RARCH_WIFI_CTL_INIT:
/* Resource leaks will follow if wifi is initialized twice. */ /* Resource leaks will follow if wifi is initialized twice. */
if (wifi_st->data) if (wifi_st->data)
return false; return false;
wifi_driver_ctl(RARCH_WIFI_CTL_FIND_DRIVER, NULL); wifi_driver_ctl(RARCH_WIFI_CTL_FIND_DRIVER, NULL);
if (wifi_st->drv && wifi_st->drv->init) if (wifi_st->drv && wifi_st->drv->init)
{ {
wifi_st->data = wifi_st->drv->init(); wifi_st->data = wifi_st->drv->init();
if (wifi_st->data) if (wifi_st->data)
{ {
wifi_st->drv->enable(wifi_st->data, wifi_st->drv->enable(wifi_st->data,
settings->bools.wifi_enabled); settings->bools.wifi_enabled);
} }
else else
{ {
RARCH_ERR("Failed to initialize wifi driver. Will continue without wifi.\n"); RARCH_ERR("Failed to initialize wifi driver. Will continue without wifi.\n");
wifi_driver_ctl(RARCH_WIFI_CTL_UNSET_ACTIVE, NULL); wifi_driver_ctl(RARCH_WIFI_CTL_UNSET_ACTIVE, NULL);
} }
} }
break; break;
default: default:
break; break;
} }
return false; return false;
} }

View File

@ -1334,7 +1334,7 @@ bool playlist_push(playlist_t *playlist,
if (string_is_empty(core_name)) if (string_is_empty(core_name))
{ {
static char base_path[NAME_MAX_LENGTH] = {0}; static char base_path[NAME_MAX_LENGTH];
fill_pathname_base(base_path, real_core_path, sizeof(base_path)); fill_pathname_base(base_path, real_core_path, sizeof(base_path));
path_remove_extension(base_path); path_remove_extension(base_path);

View File

@ -34,7 +34,7 @@
#include "drivers/record_ffmpeg.h" #include "drivers/record_ffmpeg.h"
#include "drivers/record_wav.h" #include "drivers/record_wav.h"
static recording_state_t recording_state = {0}; static recording_state_t recording_state;
static const record_driver_t record_null = { static const record_driver_t record_null = {
NULL, /* new */ NULL, /* new */

View File

@ -330,14 +330,14 @@ struct rarch_state
void libnx_apply_overclock(void); void libnx_apply_overclock(void);
#endif #endif
static struct rarch_state rarch_st = {0}; static struct rarch_state rarch_st;
#ifdef HAVE_THREAD_STORAGE #ifdef HAVE_THREAD_STORAGE
static const void *MAGIC_POINTER = (void*)(uintptr_t)0x0DEFACED; static const void *MAGIC_POINTER = (void*)(uintptr_t)0x0DEFACED;
#endif #endif
static access_state_t access_state_st = {0}; static access_state_t access_state_st;
static struct global global_driver_st = {0}; /* retro_time_t alignment */ static struct global global_driver_st; /* retro_time_t alignment */
static void retro_frame_null(const void *data, unsigned width, static void retro_frame_null(const void *data, unsigned width,
unsigned height, size_t pitch) { } unsigned height, size_t pitch) { }
@ -361,7 +361,7 @@ static const location_driver_t *location_drivers[] = {
NULL, NULL,
}; };
static location_driver_state_t location_driver_st = {0}; static location_driver_state_t location_driver_st;
location_driver_state_t *location_state_get_ptr(void) location_driver_state_t *location_state_get_ptr(void)
{ {

View File

@ -322,7 +322,7 @@
#define PERF_LOG_FMT "[PERF]: Avg (%s): %llu ticks, %llu runs.\n" #define PERF_LOG_FMT "[PERF]: Avg (%s): %llu ticks, %llu runs.\n"
#endif #endif
static runloop_state_t runloop_state = {0}; static runloop_state_t runloop_state;
/* GLOBAL POINTER GETTERS */ /* GLOBAL POINTER GETTERS */
runloop_state_t *runloop_state_get_ptr(void) runloop_state_t *runloop_state_get_ptr(void)
@ -6740,7 +6740,7 @@ static enum runloop_state_enum runloop_check_state(
if (settings->bools.video_shader_watch_files) if (settings->bools.video_shader_watch_files)
{ {
static rarch_timer_t timer = {0}; static rarch_timer_t timer;
static bool need_to_apply = false; static bool need_to_apply = false;
if (video_shader_check_for_changes()) if (video_shader_check_for_changes())

View File

@ -990,7 +990,7 @@ static unsigned char invader_png[] = {
}; };
static unsigned int invader_png_len = 4008; static unsigned int invader_png_len = 4008;
static ui_window_qt_t ui_window = {0}; static ui_window_qt_t ui_window;
static const QPixmap getInvader(void) static const QPixmap getInvader(void)
{ {

View File

@ -1,259 +1,259 @@
/* RetroArch - A frontend for libretro. /* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2021 - Daniel De Matteis * Copyright (C) 2011-2021 - Daniel De Matteis
* *
* RetroArch is free software: you can redistribute it and/or modify it under the terms * RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found- * of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version. * ation, either version 3 of the License, or (at your option) any later version.
* *
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details. * PURPOSE. See the GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License along with RetroArch. * You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>. * If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <stdint.h> #include <stdint.h>
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include "../config.h" #include "../config.h"
#endif #endif
#include "../list_special.h" #include "../list_special.h"
#include "../retroarch.h" #include "../retroarch.h"
#include "../runloop.h" #include "../runloop.h"
#include "../verbosity.h" #include "../verbosity.h"
#include "ui_companion_driver.h" #include "ui_companion_driver.h"
static ui_companion_driver_t ui_companion_null = { static ui_companion_driver_t ui_companion_null = {
NULL, /* init */ NULL, /* init */
NULL, /* deinit */ NULL, /* deinit */
NULL, /* toggle */ NULL, /* toggle */
NULL, /* event_command */ NULL, /* event_command */
NULL, /* notify_refresh */ NULL, /* notify_refresh */
NULL, /* msg_queue_push */ NULL, /* msg_queue_push */
NULL, /* render_messagebox */ NULL, /* render_messagebox */
NULL, /* get_main_window */ NULL, /* get_main_window */
NULL, /* log_msg */ NULL, /* log_msg */
NULL, /* is_active */ NULL, /* is_active */
NULL, /* get_app_icons */ NULL, /* get_app_icons */
NULL, /* set_app_icon */ NULL, /* set_app_icon */
NULL, /* get_app_icon_texture */ NULL, /* get_app_icon_texture */
NULL, /* browser_window */ NULL, /* browser_window */
NULL, /* msg_window */ NULL, /* msg_window */
NULL, /* window */ NULL, /* window */
NULL, /* application */ NULL, /* application */
"null", /* ident */ "null", /* ident */
}; };
static const ui_companion_driver_t *ui_companion_drivers[] = { static const ui_companion_driver_t *ui_companion_drivers[] = {
#if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__) #if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__)
&ui_companion_win32, &ui_companion_win32,
#endif #endif
#if defined(OSX) #if defined(OSX)
&ui_companion_cocoa, &ui_companion_cocoa,
#endif #endif
#if defined(IOS) #if defined(IOS)
&ui_companion_cocoatouch, &ui_companion_cocoatouch,
#endif #endif
&ui_companion_null, &ui_companion_null,
NULL NULL
}; };
static uico_driver_state_t uico_driver_st = {0}; /* double alignment */ static uico_driver_state_t uico_driver_st; /* double alignment */
uico_driver_state_t *uico_state_get_ptr(void) uico_driver_state_t *uico_state_get_ptr(void)
{ {
return &uico_driver_st; return &uico_driver_st;
} }
uint8_t ui_companion_get_flags(void) uint8_t ui_companion_get_flags(void)
{ {
uico_driver_state_t *uico_st = &uico_driver_st; uico_driver_state_t *uico_st = &uico_driver_st;
if (!uico_st) if (!uico_st)
return 0; return 0;
return uico_st->flags; return uico_st->flags;
} }
void ui_companion_event_command(enum event_command action) void ui_companion_event_command(enum event_command action)
{ {
uico_driver_state_t *uico_st = &uico_driver_st; uico_driver_state_t *uico_st = &uico_driver_st;
const ui_companion_driver_t *ui = uico_st->drv; const ui_companion_driver_t *ui = uico_st->drv;
if (ui && ui->event_command) if (ui && ui->event_command)
ui->event_command(uico_st->data, action); ui->event_command(uico_st->data, action);
#ifdef HAVE_QT #ifdef HAVE_QT
if (ui_companion_qt.toggle && (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED)) if (ui_companion_qt.toggle && (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED))
ui_companion_qt.event_command(uico_st->qt_data, action); ui_companion_qt.event_command(uico_st->qt_data, action);
#endif #endif
} }
void ui_companion_driver_deinit(void) void ui_companion_driver_deinit(void)
{ {
uico_driver_state_t *uico_st = &uico_driver_st; uico_driver_state_t *uico_st = &uico_driver_st;
const ui_companion_driver_t *ui = uico_st->drv; const ui_companion_driver_t *ui = uico_st->drv;
if (!ui) if (!ui)
return; return;
if (ui->deinit) if (ui->deinit)
ui->deinit(uico_st->data); ui->deinit(uico_st->data);
#ifdef HAVE_QT #ifdef HAVE_QT
if (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED) if (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED)
{ {
ui_companion_qt.deinit(uico_st->qt_data); ui_companion_qt.deinit(uico_st->qt_data);
uico_st->qt_data = NULL; uico_st->qt_data = NULL;
} }
#endif #endif
uico_st->data = NULL; uico_st->data = NULL;
} }
void ui_companion_driver_toggle( void ui_companion_driver_toggle(
bool desktop_menu_enable, bool desktop_menu_enable,
bool ui_companion_toggle, bool ui_companion_toggle,
bool force) bool force)
{ {
uico_driver_state_t *uico_st = &uico_driver_st; uico_driver_state_t *uico_st = &uico_driver_st;
if (uico_st && uico_st->drv && uico_st->drv->toggle) if (uico_st && uico_st->drv && uico_st->drv->toggle)
uico_st->drv->toggle(uico_st->data, false); uico_st->drv->toggle(uico_st->data, false);
#ifdef HAVE_QT #ifdef HAVE_QT
if (desktop_menu_enable) if (desktop_menu_enable)
{ {
if ((ui_companion_toggle || force) && (!(uico_st->flags & UICO_ST_FLAG_QT_IS_INITED))) if ((ui_companion_toggle || force) && (!(uico_st->flags & UICO_ST_FLAG_QT_IS_INITED)))
{ {
uico_st->qt_data = ui_companion_qt.init(); uico_st->qt_data = ui_companion_qt.init();
uico_st->flags |= UICO_ST_FLAG_QT_IS_INITED; uico_st->flags |= UICO_ST_FLAG_QT_IS_INITED;
} }
if (ui_companion_qt.toggle && (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED)) if (ui_companion_qt.toggle && (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED))
ui_companion_qt.toggle(uico_st->qt_data, force); ui_companion_qt.toggle(uico_st->qt_data, force);
} }
#endif #endif
} }
void ui_companion_driver_init_first(void) void ui_companion_driver_init_first(void)
{ {
uico_driver_state_t *uico_st = &uico_driver_st; uico_driver_state_t *uico_st = &uico_driver_st;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
#ifdef HAVE_QT #ifdef HAVE_QT
bool desktop_menu_enable = settings->bools.desktop_menu_enable; bool desktop_menu_enable = settings->bools.desktop_menu_enable;
bool ui_companion_toggle = settings->bools.ui_companion_toggle; bool ui_companion_toggle = settings->bools.ui_companion_toggle;
if (desktop_menu_enable && ui_companion_toggle) if (desktop_menu_enable && ui_companion_toggle)
{ {
uico_st->qt_data = ui_companion_qt.init(); uico_st->qt_data = ui_companion_qt.init();
uico_st->flags |= UICO_ST_FLAG_QT_IS_INITED; uico_st->flags |= UICO_ST_FLAG_QT_IS_INITED;
} }
#else #else
bool desktop_menu_enable = false; bool desktop_menu_enable = false;
bool ui_companion_toggle = false; bool ui_companion_toggle = false;
#endif #endif
unsigned ui_companion_start_on_boot = unsigned ui_companion_start_on_boot =
settings->bools.ui_companion_start_on_boot; settings->bools.ui_companion_start_on_boot;
uico_st->drv = (ui_companion_driver_t*)ui_companion_drivers[0]; uico_st->drv = (ui_companion_driver_t*)ui_companion_drivers[0];
if (!uico_st->drv) if (!uico_st->drv)
return; return;
if (!ui_companion_start_on_boot) if (!ui_companion_start_on_boot)
return; return;
if (uico_st->drv->init) if (uico_st->drv->init)
uico_st->data = uico_st->drv->init(); uico_st->data = uico_st->drv->init();
ui_companion_driver_toggle(desktop_menu_enable, ui_companion_driver_toggle(desktop_menu_enable,
ui_companion_toggle, false); ui_companion_toggle, false);
} }
void ui_companion_driver_notify_refresh(void) void ui_companion_driver_notify_refresh(void)
{ {
uico_driver_state_t *uico_st = &uico_driver_st; uico_driver_state_t *uico_st = &uico_driver_st;
const ui_companion_driver_t *ui = uico_st->drv; const ui_companion_driver_t *ui = uico_st->drv;
if (!ui) if (!ui)
return; return;
if (ui->notify_refresh) if (ui->notify_refresh)
ui->notify_refresh(uico_st->data); ui->notify_refresh(uico_st->data);
#ifdef HAVE_QT #ifdef HAVE_QT
if (config_get_ptr()->bools.desktop_menu_enable) if (config_get_ptr()->bools.desktop_menu_enable)
if (ui_companion_qt.notify_refresh && (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED)) if (ui_companion_qt.notify_refresh && (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED))
ui_companion_qt.notify_refresh(uico_st->qt_data); ui_companion_qt.notify_refresh(uico_st->qt_data);
#endif #endif
} }
const ui_msg_window_t *ui_companion_driver_get_msg_window_ptr(void) const ui_msg_window_t *ui_companion_driver_get_msg_window_ptr(void)
{ {
uico_driver_state_t *uico_st = &uico_driver_st; uico_driver_state_t *uico_st = &uico_driver_st;
const ui_companion_driver_t *ui = uico_st->drv; const ui_companion_driver_t *ui = uico_st->drv;
if (ui) if (ui)
return ui->msg_window; return ui->msg_window;
return NULL; return NULL;
} }
const ui_window_t *ui_companion_driver_get_window_ptr(void) const ui_window_t *ui_companion_driver_get_window_ptr(void)
{ {
uico_driver_state_t *uico_st = &uico_driver_st; uico_driver_state_t *uico_st = &uico_driver_st;
const ui_companion_driver_t *ui = uico_st->drv; const ui_companion_driver_t *ui = uico_st->drv;
if (ui) if (ui)
return ui->window; return ui->window;
return NULL; return NULL;
} }
const ui_browser_window_t *ui_companion_driver_get_browser_window_ptr(void) const ui_browser_window_t *ui_companion_driver_get_browser_window_ptr(void)
{ {
uico_driver_state_t *uico_st = &uico_driver_st; uico_driver_state_t *uico_st = &uico_driver_st;
const ui_companion_driver_t *ui = uico_st->drv; const ui_companion_driver_t *ui = uico_st->drv;
if (ui) if (ui)
return ui->browser_window; return ui->browser_window;
return NULL; return NULL;
} }
void ui_companion_driver_msg_queue_push( void ui_companion_driver_msg_queue_push(
const char *msg, unsigned priority, const char *msg, unsigned priority,
unsigned duration, bool flush) unsigned duration, bool flush)
{ {
uico_driver_state_t *uico_st = &uico_driver_st; uico_driver_state_t *uico_st = &uico_driver_st;
const ui_companion_driver_t *ui = uico_st->drv; const ui_companion_driver_t *ui = uico_st->drv;
if (ui && ui->msg_queue_push) if (ui && ui->msg_queue_push)
ui->msg_queue_push(uico_st->data, msg, priority, duration, flush); ui->msg_queue_push(uico_st->data, msg, priority, duration, flush);
#ifdef HAVE_QT #ifdef HAVE_QT
if (config_get_ptr()->bools.desktop_menu_enable) if (config_get_ptr()->bools.desktop_menu_enable)
if (ui_companion_qt.msg_queue_push && (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED)) if (ui_companion_qt.msg_queue_push && (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED))
ui_companion_qt.msg_queue_push( ui_companion_qt.msg_queue_push(
uico_st->qt_data, uico_st->qt_data,
msg, priority, duration, flush); msg, priority, duration, flush);
#endif #endif
} }
void *ui_companion_driver_get_main_window(void) void *ui_companion_driver_get_main_window(void)
{ {
uico_driver_state_t *uico_st = &uico_driver_st; uico_driver_state_t *uico_st = &uico_driver_st;
const ui_companion_driver_t *ui = uico_st->drv; const ui_companion_driver_t *ui = uico_st->drv;
if (!ui || !ui->get_main_window) if (!ui || !ui->get_main_window)
return NULL; return NULL;
return ui->get_main_window(uico_st->data); return ui->get_main_window(uico_st->data);
} }
const char *ui_companion_driver_get_ident(void) const char *ui_companion_driver_get_ident(void)
{ {
uico_driver_state_t *uico_st = &uico_driver_st; uico_driver_state_t *uico_st = &uico_driver_st;
const ui_companion_driver_t *ui = uico_st->drv; const ui_companion_driver_t *ui = uico_st->drv;
if (ui) if (ui)
return ui->ident; return ui->ident;
return "null"; return "null";
} }
void ui_companion_driver_log_msg(const char *msg) void ui_companion_driver_log_msg(const char *msg)
{ {
#ifdef HAVE_QT #ifdef HAVE_QT
uico_driver_state_t *uico_st= &uico_driver_st; uico_driver_state_t *uico_st= &uico_driver_st;
bool window_is_active = uico_st->qt_data && (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED) bool window_is_active = uico_st->qt_data && (uico_st->flags & UICO_ST_FLAG_QT_IS_INITED)
&& ui_companion_qt.is_active(uico_st->qt_data); && ui_companion_qt.is_active(uico_st->qt_data);
if (config_get_ptr()->bools.desktop_menu_enable) if (config_get_ptr()->bools.desktop_menu_enable)
if (window_is_active) if (window_is_active)
ui_companion_qt.log_msg(uico_st->qt_data, msg); ui_companion_qt.log_msg(uico_st->qt_data, msg);
#endif #endif
} }

View File

@ -457,7 +457,7 @@ void rarch_log_file_init(
char log_file_path[PATH_MAX_LENGTH]; char log_file_path[PATH_MAX_LENGTH];
verbosity_state_t *g_verbosity = &main_verbosity_st; verbosity_state_t *g_verbosity = &main_verbosity_st;
static bool log_file_created = false; static bool log_file_created = false;
static char timestamped_log_file_name[64] = {0}; static char timestamped_log_file_name[64];
bool logging_to_file = g_verbosity->initialized; bool logging_to_file = g_verbosity->initialized;