From 573f9e60c7a955f5f6562a3b7af5fdc0ec83848e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 31 Jul 2020 10:54:57 +0200 Subject: [PATCH] (libnx) Prevent some warnings --- audio/drivers/switch_audio.c | 38 +++++++++++++++++------------- frontend/drivers/platform_switch.c | 4 ++-- gfx/drivers_font/switch_font.c | 8 +++---- menu/menu_displaylist.c | 2 +- 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/audio/drivers/switch_audio.c b/audio/drivers/switch_audio.c index cdb1d146aa..620b440b6f 100644 --- a/audio/drivers/switch_audio.c +++ b/audio/drivers/switch_audio.c @@ -29,11 +29,11 @@ #define BUFFER_COUNT 3 #endif -static const int sample_rate = 48000; -static const int max_num_samples = sample_rate; -static const int num_channels = 2; + +#define SAMPLE_RATE 48000 +#define NUM_CHANNELS 2 #ifndef HAVE_LIBNX -static const size_t sample_buffer_size = ((max_num_samples * num_channels * sizeof(uint16_t)) + 0xfff) & ~0xfff; +#define SAMPLE_BUFFER_SIZE (((SAMPLE_RATE * NUM_CHANNELS * sizeof(uint16_t)) + 0xfff) & ~0xfff) #endif typedef struct @@ -51,16 +51,19 @@ typedef struct #endif } switch_audio_t; +#ifdef HAVE_LIBNX static uint32_t switch_audio_data_size(void) { -#ifdef HAVE_LIBNX - static const int framerate = 1000 / 30; - static const int samplecount = (sample_rate / framerate); - return (samplecount * num_channels * sizeof(uint16_t)); -#else - return sample_buffer_size; -#endif + static const int framerate = 1000 / 30; + static const int samplecount = (SAMPLE_RATE / framerate); + return (samplecount * NUM_CHANNELS * sizeof(uint16_t)); } +#else +static uint32_t switch_audio_data_size(void) +{ + return SAMPLE_BUFFER_SIZE; +} +#endif static size_t switch_audio_buffer_size(void *data) { @@ -68,7 +71,7 @@ static size_t switch_audio_buffer_size(void *data) #ifdef HAVE_LIBNX return (switch_audio_data_size() + 0xfff) & ~0xfff; #else - return sample_buffer_size; + return SAMPLE_BUFFER_SIZE; #endif } @@ -267,16 +270,16 @@ static void *switch_audio_init(const char *device, if (audio_ipc_open_output(names[0], &swa->output) != 0) goto fail_audio_ipc; - if (swa->output.sample_rate != sample_rate) + if (swa->output.sample_rate != SAMPLE_RATE) { RARCH_ERR("expected sample rate of %d, got sample rate of %d\n", - sample_rate, swa->output.sample_rate); + SAMPLE_RATE, swa->output.sample_rate); goto fail_audio_output; } - if (swa->output.num_channels != num_channels) + if (swa->output.num_channels != NUM_CHANNELS) { - RARCH_ERR("expected %d channels, got %d\n", num_channels, + RARCH_ERR("expected %d channels, got %d\n", NUM_CHANNELS, swa->output.num_channels); goto fail_audio_output; } @@ -308,7 +311,8 @@ static void *switch_audio_init(const char *device, #else swa->buffers[i].ptr = &swa->buffers[i].sample_data; swa->buffers[i].unknown = 0; - swa->buffers[i].sample_data = alloc_pages(sample_buffer_size, switch_audio_buffer_size(NULL), NULL); + swa->buffers[i].sample_data = alloc_pages(SAMPLE_BUFFER_SIZE, + switch_audio_buffer_size(NULL), NULL); if (!swa->buffers[i].sample_data) goto fail_audio_output; diff --git a/frontend/drivers/platform_switch.c b/frontend/drivers/platform_switch.c index d3975496c9..035ba666e8 100644 --- a/frontend/drivers/platform_switch.c +++ b/frontend/drivers/platform_switch.c @@ -331,7 +331,7 @@ static void frontend_switch_exec(const char *path, bool should_load_game) args++; #endif - game_path[0] = NULL; + game_path[0] = '\0'; RARCH_LOG("Attempt to load core: [%s].\n", path); @@ -339,7 +339,7 @@ static void frontend_switch_exec(const char *path, bool should_load_game) if (should_load_game && !path_is_empty(RARCH_PATH_CONTENT)) { strlcpy(game_path, path_get(RARCH_PATH_CONTENT), sizeof(game_path)); - arg_data[args] = game_path; + arg_data[args] = game_path; arg_data[args + 1] = NULL; args++; RARCH_LOG("content path: [%s].\n", path_get(RARCH_PATH_CONTENT)); diff --git a/gfx/drivers_font/switch_font.c b/gfx/drivers_font/switch_font.c index d5db2ecc82..86d8aeaa79 100644 --- a/gfx/drivers_font/switch_font.c +++ b/gfx/drivers_font/switch_font.c @@ -140,7 +140,7 @@ static void switch_font_render_line( for (i = 0; i < msg_len; i++) { - int off_x, off_y, tex_x, tex_y, width, height, y; + int off_x, off_y, tex_x, tex_y, width, height; const char *msg_tmp = &msg[i]; unsigned code = utf8_walk(&msg_tmp); unsigned skip = msg_tmp - &msg[i]; @@ -157,9 +157,9 @@ static void switch_font_render_line( if (!glyph) continue; - off_x = x + glyph->draw_offset_x + delta_x; - off_y = y + glyph->draw_offset_y + delta_y; - width = glyph->width; + off_x = x + glyph->draw_offset_x + delta_x; + off_y = y + glyph->draw_offset_y + delta_y; + width = glyph->width; height = glyph->height; tex_x = glyph->atlas_offset_x; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 948d026e64..3fa94139fd 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -9367,8 +9367,8 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, { unsigned i; char text[PATH_MAX_LENGTH]; - char current_profile[PATH_MAX_LENGTH]; #ifdef HAVE_LAKKA_SWITCH + char current_profile[PATH_MAX_LENGTH]; FILE *profile = NULL; #endif const size_t profiles_count = sizeof(SWITCH_CPU_PROFILES)/sizeof(SWITCH_CPU_PROFILES[1]);