(Frontend) Cleanups

This commit is contained in:
twinaphex 2015-06-12 23:38:46 +02:00
parent b70c1c134f
commit 413230d77d
5 changed files with 63 additions and 51 deletions

View File

@ -303,10 +303,11 @@ static void frontend_darwin_get_os(char *s, size_t len, int *major, int *minor)
static void frontend_darwin_get_environment_settings(int *argc, char *argv[], static void frontend_darwin_get_environment_settings(int *argc, char *argv[],
void *args, void *params_data) void *args, void *params_data)
{ {
char temp_dir[PATH_MAX_LENGTH];
char bundle_path_buf[PATH_MAX_LENGTH], home_dir_buf[PATH_MAX_LENGTH];
CFURLRef bundle_url; CFURLRef bundle_url;
CFStringRef bundle_path; CFStringRef bundle_path;
char temp_dir[PATH_MAX_LENGTH] = {0};
char bundle_path_buf[PATH_MAX_LENGTH] = {0};
char home_dir_buf[PATH_MAX_LENGTH] = {0};
CFBundleRef bundle = CFBundleGetMainBundle(); CFBundleRef bundle = CFBundleGetMainBundle();
(void)temp_dir; (void)temp_dir;
@ -380,7 +381,7 @@ static void frontend_darwin_load_content(void)
static int frontend_darwin_get_rating(void) static int frontend_darwin_get_rating(void)
{ {
char model[PATH_MAX_LENGTH]; char model[PATH_MAX_LENGTH] = {0};
frontend_darwin_get_name(model, sizeof(model)); frontend_darwin_get_name(model, sizeof(model));

View File

@ -103,8 +103,8 @@ check_proc_acpi_battery(const char * node, bool * have_battery,
bool * charging, int *seconds, int *percent) bool * charging, int *seconds, int *percent)
{ {
const char *base = proc_acpi_battery_path; const char *base = proc_acpi_battery_path;
char info[1024]; char info[1024] = {0};
char state[1024]; char state[1024] = {0};
char *ptr = NULL; char *ptr = NULL;
char *key = NULL; char *key = NULL;
char *val = NULL; char *val = NULL;
@ -121,6 +121,7 @@ check_proc_acpi_battery(const char * node, bool * have_battery,
return; return;
ptr = &state[0]; ptr = &state[0];
while (make_proc_acpi_key_val(&ptr, &key, &val)) while (make_proc_acpi_key_val(&ptr, &key, &val))
{ {
if (!strcmp(key, "present")) if (!strcmp(key, "present"))
@ -140,6 +141,7 @@ check_proc_acpi_battery(const char * node, bool * have_battery,
{ {
char *endptr = NULL; char *endptr = NULL;
const int cvt = (int) strtol(val, &endptr, 10); const int cvt = (int) strtol(val, &endptr, 10);
if (*endptr == ' ') if (*endptr == ' ')
remaining = cvt; remaining = cvt;
} }
@ -152,6 +154,7 @@ check_proc_acpi_battery(const char * node, bool * have_battery,
{ {
char *endptr = NULL; char *endptr = NULL;
const int cvt = (int) strtol(val, &endptr, 10); const int cvt = (int) strtol(val, &endptr, 10);
if (*endptr == ' ') if (*endptr == ' ')
maximum = cvt; maximum = cvt;
} }
@ -194,7 +197,7 @@ static void
check_proc_acpi_ac_adapter(const char * node, bool *have_ac) check_proc_acpi_ac_adapter(const char * node, bool *have_ac)
{ {
const char *base = proc_acpi_ac_adapter_path; const char *base = proc_acpi_ac_adapter_path;
char state[256]; char state[256] = {0};
char *ptr = NULL; char *ptr = NULL;
char *key = NULL; char *key = NULL;
char *val = NULL; char *val = NULL;
@ -246,16 +249,16 @@ static bool int_string(char *str, int *val)
bool frontend_linux_powerstate_check_apm(enum frontend_powerstate *state, bool frontend_linux_powerstate_check_apm(enum frontend_powerstate *state,
int *seconds, int *percent) int *seconds, int *percent)
{ {
ssize_t br;
int ac_status = 0; int ac_status = 0;
int battery_status = 0; int battery_status = 0;
int battery_flag = 0; int battery_flag = 0;
int battery_percent = 0; int battery_percent = 0;
int battery_time = 0; int battery_time = 0;
const int fd = open(proc_apm_path, O_RDONLY); const int fd = open(proc_apm_path, O_RDONLY);
char buf[128]; char buf[128] = {0};
char *ptr = &buf[0]; char *ptr = &buf[0];
char *str = NULL; char *str = NULL;
ssize_t br;
if (fd == -1) if (fd == -1)
return false; /* can't use this interface. */ return false; /* can't use this interface. */
@ -357,6 +360,7 @@ bool frontend_linux_powerstate_check_acpi(enum frontend_powerstate *state,
while ((dent = readdir(dirp)) != NULL) while ((dent = readdir(dirp)) != NULL)
{ {
const char *node = dent->d_name; const char *node = dent->d_name;
check_proc_acpi_ac_adapter(node, &have_ac); check_proc_acpi_ac_adapter(node, &have_ac);
} }
closedir(dirp); closedir(dirp);

View File

@ -95,8 +95,8 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[],
unsigned int get_type; unsigned int get_type;
unsigned int get_attributes; unsigned int get_attributes;
CellGameContentSize size; CellGameContentSize size;
char dirName[CELL_GAME_DIRNAME_SIZE]; char dirName[CELL_GAME_DIRNAME_SIZE] = {0};
char contentInfoPath[PATH_MAX_LENGTH]; char contentInfoPath[PATH_MAX_LENGTH] = {0};
#ifdef HAVE_MULTIMAN #ifdef HAVE_MULTIMAN
/* not launched from external launcher, set default path */ /* not launched from external launcher, set default path */
@ -355,20 +355,24 @@ static void frontend_ps3_exitspawn(char *core_path, size_t core_path_size)
static void frontend_ps3_exec(const char *path, bool should_load_game) static void frontend_ps3_exec(const char *path, bool should_load_game)
{ {
char spawn_data[256] = {0};
unsigned i;
(void)should_load_game; (void)should_load_game;
char spawn_data[256];
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
global_t *global = global_get_ptr(); global_t *global = global_get_ptr();
bool original_verbose = global->verbosity; bool original_verbose = global->verbosity;
char game_path[256] = {0};
global->verbosity = true; global->verbosity = true;
char game_path[256];
game_path[0] = '\0'; game_path[0] = '\0';
#endif #endif
RARCH_LOG("Attempt to load executable: [%s].\n", path); RARCH_LOG("Attempt to load executable: [%s].\n", path);
for(unsigned int i = 0; i < sizeof(spawn_data); ++i) for(i = 0; i < sizeof(spawn_data); ++i)
spawn_data[i] = i & 0xff; spawn_data[i] = i & 0xff;
SceNpDrmKey * k_licensee = NULL; SceNpDrmKey * k_licensee = NULL;

View File

@ -187,8 +187,7 @@ static void frontend_psp_init(void *data)
static void frontend_psp_exec(const char *path, bool should_load_game) static void frontend_psp_exec(const char *path, bool should_load_game)
{ {
#if defined(HAVE_KERNEL_PRX) || defined(IS_SALAMANDER) #if defined(HAVE_KERNEL_PRX) || defined(IS_SALAMANDER)
char argp[512] = {0};
char argp[512];
SceSize args = 0; SceSize args = 0;
argp[0] = '\0'; argp[0] = '\0';

View File

@ -69,8 +69,8 @@ static HRESULT xbox_io_mount(char *szDrive, char *szDevice)
bool original_verbose = global->verbosity; bool original_verbose = global->verbosity;
global->verbosity = true; global->verbosity = true;
#endif #endif
char szSourceDevice[48]; char szSourceDevice[48] = {0};
char szDestinationDrive[16]; char szDestinationDrive[16] = {0};
snprintf(szSourceDevice, sizeof(szSourceDevice), snprintf(szSourceDevice, sizeof(szSourceDevice),
"\\Device\\%s", szDevice); "\\Device\\%s", szDevice);
@ -105,7 +105,8 @@ static HRESULT xbox_io_mount(char *szDrive, char *szDevice)
static HRESULT xbox_io_unmount(char *szDrive) static HRESULT xbox_io_unmount(char *szDrive)
{ {
char szDestinationDrive[16]; char szDestinationDrive[16] = {0};
snprintf(szDestinationDrive, sizeof(szDestinationDrive), snprintf(szDestinationDrive, sizeof(szDestinationDrive),
"\\??\\%s", szDrive); "\\??\\%s", szDrive);
@ -131,6 +132,7 @@ static void frontend_xdk_get_environment_settings(int *argc, char *argv[],
#ifndef IS_SALAMANDER #ifndef IS_SALAMANDER
global_t *global = global_get_ptr(); global_t *global = global_get_ptr();
bool original_verbose = global->verbosity; bool original_verbose = global->verbosity;
global->verbosity = true; global->verbosity = true;
#endif #endif
@ -334,13 +336,15 @@ static void frontend_xdk_exec(const char *path, bool should_load_game)
#if defined(_XBOX1) #if defined(_XBOX1)
LAUNCH_DATA ptr; LAUNCH_DATA ptr;
memset(&ptr, 0, sizeof(ptr)); memset(&ptr, 0, sizeof(ptr));
if (should_load_game && global->fullpath[0] != '\0') if (should_load_game && global->fullpath[0] != '\0')
snprintf((char*)ptr.Data, sizeof(ptr.Data), "%s", global->fullpath); snprintf((char*)ptr.Data, sizeof(ptr.Data), "%s", global->fullpath);
if (path[0] != '\0') if (path[0] != '\0')
XLaunchNewImage(path, ptr.Data[0] != '\0' ? &ptr : NULL); XLaunchNewImage(path, ptr.Data[0] != '\0' ? &ptr : NULL);
#elif defined(_XBOX360) #elif defined(_XBOX360)
char game_path[1024]; char game_path[1024] = {0};
if (should_load_game && global->fullpath[0] != '\0') if (should_load_game && global->fullpath[0] != '\0')
{ {
strlcpy(game_path, global->fullpath, sizeof(game_path)); strlcpy(game_path, global->fullpath, sizeof(game_path));