From d56c809b91824e20a0676e3ad31972b6844272be Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Fri, 18 Dec 2020 23:29:25 -0330 Subject: [PATCH] libretro: Fix warnings with memset; use default initialization instead. --- src/libretro/libretro.cxx | 10 +++++---- src/libretro/libretro.h | 44 +++++++++++++++++++-------------------- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/src/libretro/libretro.cxx b/src/libretro/libretro.cxx index 42408bd97..34383b73e 100644 --- a/src/libretro/libretro.cxx +++ b/src/libretro/libretro.cxx @@ -423,7 +423,7 @@ void retro_set_input_state(retro_input_state_t cb) { input_state_cb = cb; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void retro_get_system_info(struct retro_system_info *info) { - memset(info,0,sizeof(retro_system_info)); + *info = retro_system_info{}; // reset to defaults info->library_name = stella.getCoreName(); #ifndef GIT_VERSION @@ -438,18 +438,20 @@ void retro_get_system_info(struct retro_system_info *info) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void retro_get_system_av_info(struct retro_system_av_info *info) { - memset(info,0,sizeof(retro_system_av_info)); + *info = retro_system_av_info{}; // reset to defaults info->timing.fps = stella.getVideoRate(); info->timing.sample_rate = stella.getAudioRate(); - info->geometry.base_width = stella.getRenderWidth() - crop_left * (stella.getVideoZoom() == 1 ? 2 : 1); + info->geometry.base_width = stella.getRenderWidth() - crop_left * + (stella.getVideoZoom() == 1 ? 2 : 1); info->geometry.base_height = stella.getRenderHeight(); info->geometry.max_width = stella.getVideoWidthMax(); info->geometry.max_height = stella.getVideoHeightMax(); - info->geometry.aspect_ratio = stella.getVideoAspectPar() * (float) info->geometry.base_width / (float) info->geometry.base_height; + info->geometry.aspect_ratio = stella.getVideoAspectPar() * + (float) info->geometry.base_width / (float) info->geometry.base_height; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/libretro/libretro.h b/src/libretro/libretro.h index 534d57ca6..1901465ae 100644 --- a/src/libretro/libretro.h +++ b/src/libretro/libretro.h @@ -2100,16 +2100,16 @@ struct retro_system_info /* All pointers are owned by libretro implementation, and pointers must * remain valid until retro_deinit() is called. */ - const char *library_name; /* Descriptive name of library. Should not - * contain any version numbers, etc. */ - const char *library_version; /* Descriptive version of core. */ + const char *library_name{nullptr}; /* Descriptive name of library. Should not + * contain any version numbers, etc. */ + const char *library_version{nullptr}; /* Descriptive version of core. */ - const char *valid_extensions; /* A string listing probably content - * extensions the core will be able to - * load, separated with pipe. - * I.e. "bin|rom|iso". - * Typically used for a GUI to filter - * out extensions. */ + const char *valid_extensions{nullptr}; /* A string listing probably content + * extensions the core will be able to + * load, separated with pipe. + * I.e. "bin|rom|iso". + * Typically used for a GUI to filter + * out extensions. */ /* If true, retro_load_game() is guaranteed to provide a valid pathname * in retro_game_info::path. @@ -2122,33 +2122,33 @@ struct retro_system_info * load from file. * Implementations should strive for setting this to false, as it allows * the frontend to perform patching, etc. */ - bool need_fullpath; + bool need_fullpath{false}; /* If true, the frontend is not allowed to extract any archives before * loading the real content. * Necessary for certain libretro implementations that load games * from zipped archives. */ - bool block_extract; + bool block_extract{false}; }; struct retro_game_geometry { - unsigned base_width; /* Nominal video width of game. */ - unsigned base_height; /* Nominal video height of game. */ - unsigned max_width; /* Maximum possible width of game. */ - unsigned max_height; /* Maximum possible height of game. */ + unsigned base_width{0}; /* Nominal video width of game. */ + unsigned base_height{0}; /* Nominal video height of game. */ + unsigned max_width{0}; /* Maximum possible width of game. */ + unsigned max_height{0}; /* Maximum possible height of game. */ - float aspect_ratio; /* Nominal aspect ratio of game. If - * aspect_ratio is <= 0.0, an aspect ratio - * of base_width / base_height is assumed. - * A frontend could override this setting, - * if desired. */ + float aspect_ratio{0.F}; /* Nominal aspect ratio of game. If + * aspect_ratio is <= 0.0, an aspect ratio + * of base_width / base_height is assumed. + * A frontend could override this setting, + * if desired. */ }; struct retro_system_timing { - double fps; /* FPS of video content. */ - double sample_rate; /* Sampling rate of audio. */ + double fps{0.F}; /* FPS of video content. */ + double sample_rate{0.F}; /* Sampling rate of audio. */ }; struct retro_system_av_info