Skip to content

Commit fbcd3a7

Browse files
Merge pull request #17705 from pstef/silence-warnings-ctr
CTR: more compiler warnings cleanup
2 parents bf3752e + bad0e58 commit fbcd3a7

5 files changed

Lines changed: 40 additions & 35 deletions

File tree

audio/drivers/ctr_csnd_audio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static void ctr_csnd_audio_free(void *data)
164164

165165
static ssize_t ctr_csnd_audio_write(void *data, const void *buf, size_t len)
166166
{
167-
int i;
167+
unsigned int i;
168168
uint32_t samples_played = 0;
169169
uint64_t current_tick = 0;
170170
const uint16_t *src = buf;

ctr/ctr_debug.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void dump_result_value(Result val);
1717
#define DEBUG_HOLD() do{printf("%s@%s:%d.\n",__FUNCTION__, __FILE__, __LINE__);fflush(stdout);wait_for_input();}while(0)
1818
#define DEBUG_LINE() do{printf("%s:%d.\n",__FUNCTION__, __LINE__);fflush(stdout);}while(0)
1919
#define DEBUG_STR(X) printf( "%s: %s\n", #X, (char*)(X))
20-
#define DEBUG_VAR(X) printf( "%-20s: 0x%08X\n", #X, (u32)(X))
20+
#define DEBUG_VAR(X) printf( "%-20s: 0x%08" PRIX32 "\n", #X, (uint32_t)(X))
2121
#define DEBUG_INT(X) printf( "%-20s: %10i\n", #X, (s32)(X))
2222
#define DEBUG_VAR64(X) printf( #X"\r\t\t\t\t : 0x%016llX\n", (u64)(X))
2323
#define DEBUG_ERROR(X) do{if(X)dump_result_value(X);}while(0)

ctr/ctr_system.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ void __attribute__((noreturn)) __ctru_exit(int rc)
257257
{
258258
__libc_fini_array();
259259
__appExit();
260-
asm ("mov sp, %[saved_stack] \n\t" : : [saved_stack] "r" (__saved_stack) : "sp");
260+
asm ("mov sp, %[saved_stack] \n\t" : : [saved_stack] "r" (__saved_stack));
261261
__libctru_exit(rc);
262262
}
263263

gfx/common/ctr_defines.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ typedef struct ctr_video
9292
void *texture_linear;
9393
void *texture_swizzled;
9494
int display_list_size;
95-
int texture_width;
96-
int texture_height;
95+
unsigned int texture_width;
96+
unsigned int texture_height;
9797

9898
ctr_scale_vector_t scale_vector;
9999
ctr_vertex_t* frame_coords;
@@ -119,7 +119,7 @@ typedef struct ctr_video
119119
{
120120
ctr_vertex_t* buffer;
121121
ctr_vertex_t* current;
122-
int size;
122+
size_t size;
123123
}vertex_cache;
124124

125125
int state_slot;
@@ -158,10 +158,10 @@ typedef struct ctr_video
158158

159159
typedef struct ctr_texture
160160
{
161-
int width;
162-
int height;
163-
int active_width;
164-
int active_height;
161+
unsigned int width;
162+
unsigned int height;
163+
unsigned int active_width;
164+
unsigned int active_height;
165165

166166
enum texture_filter_type type;
167167
void* data;

gfx/drivers/ctr_gfx.c

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ gfx_display_ctx_driver_t gfx_display_ctx_ctr = {
232232
static void* ctr_font_init(void* data, const char* font_path,
233233
float font_size, bool is_threaded)
234234
{
235-
int i, j;
235+
unsigned int i, j;
236236
ctr_scale_vector_t *vec_top = NULL;
237237
ctr_scale_vector_t *vec_bottom = NULL;
238238
const uint8_t* src = NULL;
@@ -321,7 +321,7 @@ static void ctr_font_free(void* data, bool is_threaded)
321321
static int ctr_font_get_message_width(void* data, const char* msg,
322322
size_t msg_len, float scale)
323323
{
324-
int i;
324+
size_t i;
325325
int delta_x = 0;
326326
const struct font_glyph* glyph_q = NULL;
327327
ctr_font_t* font = (ctr_font_t*)data;
@@ -361,7 +361,7 @@ static void ctr_font_render_line(
361361
float pos_y,
362362
unsigned width, unsigned height, unsigned text_align)
363363
{
364-
unsigned i;
364+
unsigned int i;
365365
const struct font_glyph* glyph_q = NULL;
366366
ctr_vertex_t* v = NULL;
367367
int delta_x = 0;
@@ -504,7 +504,7 @@ static void ctr_font_render_message(
504504
for (;;)
505505
{
506506
const char* delim = strchr(msg, '\n');
507-
size_t msg_len = delim ? (delim - msg) : strlen(msg);
507+
size_t msg_len = delim ? (size_t)(delim - msg) : strlen(msg);
508508

509509
/* Draw the line */
510510
ctr_font_render_line(ctr, font, msg, msg_len,
@@ -729,7 +729,7 @@ static INLINE void ctr_set_screen_coords(ctr_video_t * ctr)
729729
#ifdef HAVE_OVERLAY
730730
static void ctr_free_overlay(ctr_video_t *ctr)
731731
{
732-
int i;
732+
unsigned int i;
733733

734734
for (i = 0; i < ctr->overlays; i++)
735735
{
@@ -818,8 +818,10 @@ static void ctr_update_state_date(void *data)
818818
ctr_video_t *ctr = (ctr_video_t*)data;
819819
time_t now = time(NULL);
820820
struct tm *t = localtime(&now);
821-
snprintf(ctr->state_date, sizeof(ctr->state_date), "%02d/%02d/%d",
822-
t->tm_mon + 1, t->tm_mday, t->tm_year + 1900);
821+
snprintf(ctr->state_date, sizeof(ctr->state_date), "%02u/%02u/%u",
822+
((unsigned)t->tm_mon + 1) % 100,
823+
(unsigned)t->tm_mday % 100,
824+
((unsigned)t->tm_year + 1900) % 10000);
823825
}
824826

825827
static bool ctr_update_state_date_from_file(void *data)
@@ -846,10 +848,11 @@ static bool ctr_update_state_date_from_file(void *data)
846848

847849
ft = mtime;
848850
t = localtime(&ft);
849-
snprintf(ctr->state_date, sizeof(ctr->state_date), "%02d/%02d/%d",
850-
t->tm_mon + 1, t->tm_mday, t->tm_year + 1900);
851-
852-
return true;
851+
snprintf(ctr->state_date, sizeof(ctr->state_date), "%02u/%02u/%u",
852+
((unsigned)t->tm_mon + 1) % 100,
853+
(unsigned)t->tm_mday % 100,
854+
((unsigned)t->tm_year + 1900) % 10000);
855+
return true;
853856

854857
error:
855858
ctr->state_data_exist = false;
@@ -1052,6 +1055,8 @@ static void ctr_bottom_menu_control(void* data, bool lcd_bottom, uint32_t flags)
10521055

10531056
switch (ctr->bottom_menu)
10541057
{
1058+
case CTR_BOTTOM_MENU_NOT_AVAILABLE:
1059+
return;
10551060
case CTR_BOTTOM_MENU_DEFAULT:
10561061
BIT64_SET(lifecycle_state, RARCH_MENU_TOGGLE);
10571062
break;
@@ -1142,8 +1147,7 @@ static void ctr_bottom_menu_control(void* data, bool lcd_bottom, uint32_t flags)
11421147
ctr->refresh_bottom_menu = true;
11431148
}
11441149

1145-
if ( ctr->bottom_menu == CTR_BOTTOM_MENU_NOT_AVAILABLE
1146-
|| (!(flags & RUNLOOP_FLAG_CORE_RUNNING)))
1150+
if (!(flags & RUNLOOP_FLAG_CORE_RUNNING))
11471151
return;
11481152

11491153

@@ -1580,6 +1584,9 @@ static void ctr_lcd_aptHook(APT_HookType hook, void* param)
15801584
case APTHOOK_ONWAKEUP:
15811585
command_event(CMD_EVENT_AUDIO_START, NULL);
15821586
break;
1587+
case APTHOOK_ONEXIT:
1588+
case APTHOOK_COUNT:
1589+
break;
15831590
}
15841591
}
15851592

@@ -1792,7 +1799,7 @@ static void* ctr_init(const video_info_t* video,
17921799
video->is_threaded,
17931800
FONT_DRIVER_RENDER_CTR);
17941801

1795-
ctr->msg_rendering_enabled = false;
1802+
ctr->msg_rendering_enabled = true;
17961803
ctr->menu_texture_frame_enable = false;
17971804
ctr->menu_texture_enable = false;
17981805

@@ -2058,7 +2065,7 @@ static bool ctr_frame(void* data, const void* frame,
20582065
}
20592066
else
20602067
{
2061-
int i;
2068+
unsigned int i;
20622069
uint8_t *dst = (uint8_t*)ctr->texture_linear;
20632070
const uint8_t *src = frame;
20642071

@@ -2195,11 +2202,9 @@ static bool ctr_frame(void* data, const void* frame,
21952202
}
21962203
}
21972204

2198-
ctr->msg_rendering_enabled = true;
21992205
#ifdef HAVE_MENU
22002206
menu_driver_frame(menu_is_alive, video_info);
22012207
#endif
2202-
ctr->msg_rendering_enabled = false;
22032208
}
22042209
else if (statistics_show)
22052210
{
@@ -2463,7 +2468,7 @@ static void ctr_free(void* data)
24632468
static void ctr_set_texture_frame(void* data, const void* frame, bool rgb32,
24642469
unsigned width, unsigned height, float alpha)
24652470
{
2466-
int i;
2471+
unsigned int i;
24672472
uint16_t *dst;
24682473
const uint16_t *src;
24692474
ctr_video_t *ctr = (ctr_video_t*)data;
@@ -2563,10 +2568,10 @@ static uintptr_t ctr_load_texture(void *video_data, void *data,
25632568
ctr_texture_t *texture = NULL;
25642569
ctr_video_t *ctr = (ctr_video_t*)video_data;
25652570
struct texture_image *image = (struct texture_image*)data;
2566-
int size = image->width
2571+
u32 size = image->width
25672572
* image->height * sizeof(uint32_t);
25682573

2569-
if ((size * 3) > linearSpaceFree())
2574+
if ((u64)size * 3 > linearSpaceFree())
25702575
return 0;
25712576

25722577
if (!ctr || !image || image->width > 2048 || image->height > 2048)
@@ -2591,7 +2596,7 @@ static uintptr_t ctr_load_texture(void *video_data, void *data,
25912596

25922597
if ((image->width <= 32) || (image->height <= 32))
25932598
{
2594-
int i, j;
2599+
unsigned int i, j;
25952600
uint32_t* src = (uint32_t*)image->pixels;
25962601

25972602
for (j = 0; j < image->height; j++)
@@ -2610,7 +2615,7 @@ static uintptr_t ctr_load_texture(void *video_data, void *data,
26102615
}
26112616
else
26122617
{
2613-
int i;
2618+
unsigned int i;
26142619
uint32_t *src = NULL;
26152620
uint32_t *dst = NULL;
26162621

@@ -2716,7 +2721,7 @@ static void ctr_overlay_vertex_geom(void *data,
27162721
static bool ctr_overlay_load(void *data,
27172722
const void *image_data, unsigned num_images)
27182723
{
2719-
int i, j;
2724+
unsigned int i, j;
27202725
void *tmpdata;
27212726
ctr_texture_t *texture = NULL;
27222727
ctr_video_t *ctr = (ctr_video_t *)data;
@@ -2823,7 +2828,7 @@ static void ctr_overlay_set_alpha(void *data, unsigned image, float mod){ }
28232828

28242829
static void ctr_render_overlay(ctr_video_t *ctr)
28252830
{
2826-
int i;
2831+
unsigned int i;
28272832

28282833
for (i = 0; i < ctr->overlays; i++)
28292834
{
@@ -2905,7 +2910,7 @@ static const video_poke_interface_t ctr_poke_interface = {
29052910
ctr_apply_state_changes,
29062911
ctr_set_texture_frame,
29072912
ctr_set_texture_enable,
2908-
font_driver_render_msg,
2913+
ctr_set_osd_msg,
29092914
NULL, /* show_mouse */
29102915
NULL, /* grab_mouse_toggle */
29112916
NULL, /* get_current_shader */

0 commit comments

Comments
 (0)