mirror of
https://github.com/libretro/RetroArch
synced 2025-03-28 08:37:41 +00:00
Get rid of return variable for snprintf
This commit is contained in:
parent
dd922bfc2c
commit
0482892a9c
@ -116,7 +116,6 @@ bool core_backup_get_backup_path(
|
||||
const char *core_path, uint32_t crc, enum core_backup_mode backup_mode,
|
||||
const char *dir_core_assets, char *backup_path, size_t len)
|
||||
{
|
||||
int n;
|
||||
time_t current_time;
|
||||
struct tm time_info;
|
||||
const char *core_filename = NULL;
|
||||
@ -152,7 +151,7 @@ bool core_backup_get_backup_path(
|
||||
rtime_localtime(¤t_time, &time_info);
|
||||
|
||||
/* Generate backup filename */
|
||||
n = snprintf(backup_filename, sizeof(backup_filename),
|
||||
snprintf(backup_filename, sizeof(backup_filename),
|
||||
"%s.%04u%02u%02uT%02u%02u%02u.%08x.%u%s",
|
||||
core_filename,
|
||||
(unsigned)time_info.tm_year + 1900,
|
||||
@ -165,10 +164,6 @@ bool core_backup_get_backup_path(
|
||||
(unsigned)backup_mode,
|
||||
FILE_PATH_CORE_BACKUP_EXTENSION);
|
||||
|
||||
if ((n < 0) || (n >= 128))
|
||||
n = 0; /* Silence GCC warnings... */
|
||||
|
||||
(void)n;
|
||||
/* Build final path */
|
||||
fill_pathname_join(backup_path, backup_dir,
|
||||
backup_filename, len);
|
||||
@ -712,7 +707,6 @@ bool core_backup_list_get_entry_timestamp_str(
|
||||
enum core_backup_date_separator_type date_separator,
|
||||
char *timestamp, size_t len)
|
||||
{
|
||||
int n;
|
||||
const char *format_str = "";
|
||||
|
||||
if (!entry || (len < 20))
|
||||
@ -732,7 +726,7 @@ bool core_backup_list_get_entry_timestamp_str(
|
||||
break;
|
||||
}
|
||||
|
||||
n = snprintf(timestamp, len,
|
||||
snprintf(timestamp, len,
|
||||
format_str,
|
||||
entry->date.year,
|
||||
entry->date.month,
|
||||
@ -741,9 +735,6 @@ bool core_backup_list_get_entry_timestamp_str(
|
||||
entry->date.minute,
|
||||
entry->date.second);
|
||||
|
||||
if ((n < 0) || (n >= 32))
|
||||
n = 0; /* Silence GCC warnings... */
|
||||
(void)n;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -754,15 +745,9 @@ bool core_backup_list_get_entry_crc_str(
|
||||
const core_backup_list_entry_t *entry,
|
||||
char *crc, size_t len)
|
||||
{
|
||||
int n;
|
||||
|
||||
if (!entry || (len < 9))
|
||||
return false;
|
||||
|
||||
n = snprintf(crc, len, "%08x", entry->crc);
|
||||
|
||||
if ((n < 0) || (n >= 32))
|
||||
n = 0; /* Silence GCC warnings... */
|
||||
(void)n;
|
||||
snprintf(crc, len, "%08x", entry->crc);
|
||||
return true;
|
||||
}
|
||||
|
@ -3381,7 +3381,6 @@ static bool materialui_render_process_entry_playlist_desktop(
|
||||
const char *core_name = NULL;
|
||||
const char *runtime_str = NULL;
|
||||
const char *last_played_str = NULL;
|
||||
int n;
|
||||
|
||||
/* Read playlist entry */
|
||||
playlist_get_index(mui->playlist, playlist_idx, &entry);
|
||||
@ -3433,7 +3432,7 @@ static bool materialui_render_process_entry_playlist_desktop(
|
||||
last_played_str = mui->status_bar.last_played_fallback_str;
|
||||
|
||||
/* Generate metadata string */
|
||||
n = snprintf(mui->status_bar.str, sizeof(mui->status_bar.str),
|
||||
snprintf(mui->status_bar.str, sizeof(mui->status_bar.str),
|
||||
"%s %s%s%s%s%s",
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_CORE),
|
||||
core_name,
|
||||
@ -3442,10 +3441,6 @@ static bool materialui_render_process_entry_playlist_desktop(
|
||||
MUI_TICKER_SPACER,
|
||||
last_played_str);
|
||||
|
||||
if ((n < 0) || (n >= 255))
|
||||
n = 0; /* Silence GCC warnings... */
|
||||
(void)n;
|
||||
|
||||
/* All metadata is cached */
|
||||
mui->status_bar.cached = true;
|
||||
|
||||
@ -7236,8 +7231,6 @@ static void materialui_status_bar_init(
|
||||
|
||||
if (mui->status_bar.enabled)
|
||||
{
|
||||
int n;
|
||||
|
||||
/* Determine status bar height */
|
||||
mui->status_bar.height = (unsigned)(((float)mui->font_data.hint.line_height * 1.6f) + 0.5f);
|
||||
|
||||
@ -7246,22 +7239,15 @@ static void materialui_status_bar_init(
|
||||
* materialui_init()? Because re-caching the
|
||||
* values each time allows us to handle changes
|
||||
* in user interface language settings) */
|
||||
n = snprintf(mui->status_bar.runtime_fallback_str,
|
||||
snprintf(mui->status_bar.runtime_fallback_str,
|
||||
sizeof(mui->status_bar.runtime_fallback_str), "%s %s",
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_RUNTIME),
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISABLED));
|
||||
|
||||
if ((n < 0) || (n >= 255))
|
||||
n = 0; /* Silence GCC warnings... */
|
||||
(void)n;
|
||||
n = snprintf(mui->status_bar.last_played_fallback_str,
|
||||
snprintf(mui->status_bar.last_played_fallback_str,
|
||||
sizeof(mui->status_bar.last_played_fallback_str), "%s %s",
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISABLED));
|
||||
|
||||
if ((n < 0) || (n >= 255))
|
||||
n = 0; /* Silence GCC warnings... */
|
||||
(void)n;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -561,20 +561,14 @@ void runtime_log_get_runtime_usec(
|
||||
void runtime_log_get_runtime_str(runtime_log_t *runtime_log,
|
||||
char *s, size_t len)
|
||||
{
|
||||
int n = 0;
|
||||
|
||||
if (runtime_log)
|
||||
n = snprintf(s, len, "%s %02u:%02u:%02u",
|
||||
snprintf(s, len, "%s %02u:%02u:%02u",
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_RUNTIME),
|
||||
runtime_log->runtime.hours, runtime_log->runtime.minutes,
|
||||
runtime_log->runtime.seconds);
|
||||
else
|
||||
n = snprintf(s, len, "%s 00:00:00",
|
||||
snprintf(s, len, "%s 00:00:00",
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_RUNTIME));
|
||||
|
||||
if ((n < 0) || (n >= 64))
|
||||
n = 0; /* Silence GCC warnings... */
|
||||
(void)n;
|
||||
}
|
||||
|
||||
/* Gets last played entry values */
|
||||
@ -657,7 +651,6 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||
char tmp[64];
|
||||
bool has_am_pm = false;
|
||||
const char *format_str = "";
|
||||
size_t n = 0;
|
||||
|
||||
tmp[0] = '\0';
|
||||
|
||||
@ -799,9 +792,10 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||
if (has_am_pm)
|
||||
{
|
||||
last_played_strftime(runtime_log, tmp, sizeof(tmp), format_str);
|
||||
strlcpy(str, msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), len);
|
||||
strlcat(str, tmp, len);
|
||||
snprintf(str, len, "%s%s",
|
||||
msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
|
||||
tmp);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -821,7 +815,7 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||
format_str = "%s %04u-%02u-%02u %02u:%02u";
|
||||
break;
|
||||
}
|
||||
n = snprintf(str, len, format_str,
|
||||
snprintf(str, len, format_str,
|
||||
msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
|
||||
runtime_log->last_played.year,
|
||||
@ -829,7 +823,6 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||
runtime_log->last_played.day,
|
||||
runtime_log->last_played.hour,
|
||||
runtime_log->last_played.minute);
|
||||
(void)n;
|
||||
return;
|
||||
case PLAYLIST_LAST_PLAYED_STYLE_YMD:
|
||||
switch (date_separator)
|
||||
@ -844,13 +837,12 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||
format_str = "%s %04u-%02u-%02u";
|
||||
break;
|
||||
}
|
||||
n = snprintf(str, len, format_str,
|
||||
snprintf(str, len, format_str,
|
||||
msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
|
||||
runtime_log->last_played.year,
|
||||
runtime_log->last_played.month,
|
||||
runtime_log->last_played.day);
|
||||
(void)n;
|
||||
return;
|
||||
case PLAYLIST_LAST_PLAYED_STYLE_YM:
|
||||
switch (date_separator)
|
||||
@ -865,12 +857,11 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||
format_str = "%s %04u-%02u";
|
||||
break;
|
||||
}
|
||||
n = snprintf(str, len, format_str,
|
||||
snprintf(str, len, format_str,
|
||||
msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
|
||||
runtime_log->last_played.year,
|
||||
runtime_log->last_played.month);
|
||||
(void)n;
|
||||
return;
|
||||
case PLAYLIST_LAST_PLAYED_STYLE_MDYYYY_HMS:
|
||||
switch (date_separator)
|
||||
@ -885,7 +876,7 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||
format_str = "%s %02u-%02u-%04u %02u:%02u:%02u";
|
||||
break;
|
||||
}
|
||||
n = snprintf(str, len, format_str,
|
||||
snprintf(str, len, format_str,
|
||||
msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
|
||||
runtime_log->last_played.month,
|
||||
@ -894,7 +885,6 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||
runtime_log->last_played.hour,
|
||||
runtime_log->last_played.minute,
|
||||
runtime_log->last_played.second);
|
||||
(void)n;
|
||||
return;
|
||||
case PLAYLIST_LAST_PLAYED_STYLE_MDYYYY_HM:
|
||||
switch (date_separator)
|
||||
@ -909,7 +899,7 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||
format_str = "%s %02u-%02u-%04u %02u:%02u";
|
||||
break;
|
||||
}
|
||||
n = snprintf(str, len, format_str,
|
||||
snprintf(str, len, format_str,
|
||||
msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
|
||||
runtime_log->last_played.month,
|
||||
@ -917,7 +907,6 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||
runtime_log->last_played.year,
|
||||
runtime_log->last_played.hour,
|
||||
runtime_log->last_played.minute);
|
||||
(void)n;
|
||||
return;
|
||||
case PLAYLIST_LAST_PLAYED_STYLE_MD_HM:
|
||||
switch (date_separator)
|
||||
@ -932,14 +921,13 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||
format_str = "%s %02u-%02u %02u:%02u";
|
||||
break;
|
||||
}
|
||||
n = snprintf(str, len, format_str,
|
||||
snprintf(str, len, format_str,
|
||||
msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
|
||||
runtime_log->last_played.month,
|
||||
runtime_log->last_played.day,
|
||||
runtime_log->last_played.hour,
|
||||
runtime_log->last_played.minute);
|
||||
(void)n;
|
||||
return;
|
||||
case PLAYLIST_LAST_PLAYED_STYLE_MDYYYY:
|
||||
switch (date_separator)
|
||||
@ -954,13 +942,12 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||
format_str = "%s %02u-%02u-%04u";
|
||||
break;
|
||||
}
|
||||
n = snprintf(str, len, format_str,
|
||||
snprintf(str, len, format_str,
|
||||
msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
|
||||
runtime_log->last_played.month,
|
||||
runtime_log->last_played.day,
|
||||
runtime_log->last_played.year);
|
||||
(void)n;
|
||||
return;
|
||||
case PLAYLIST_LAST_PLAYED_STYLE_MD:
|
||||
switch (date_separator)
|
||||
@ -975,12 +962,11 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||
format_str = "%s %02u-%02u";
|
||||
break;
|
||||
}
|
||||
n = snprintf(str, len, format_str,
|
||||
snprintf(str, len, format_str,
|
||||
msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
|
||||
runtime_log->last_played.month,
|
||||
runtime_log->last_played.day);
|
||||
(void)n;
|
||||
return;
|
||||
case PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HMS:
|
||||
switch (date_separator)
|
||||
@ -995,7 +981,7 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||
format_str = "%s %02u-%02u-%04u %02u:%02u:%02u";
|
||||
break;
|
||||
}
|
||||
n = snprintf(str, len, format_str,
|
||||
snprintf(str, len, format_str,
|
||||
msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
|
||||
runtime_log->last_played.day,
|
||||
@ -1004,7 +990,6 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||
runtime_log->last_played.hour,
|
||||
runtime_log->last_played.minute,
|
||||
runtime_log->last_played.second);
|
||||
(void)n;
|
||||
return;
|
||||
case PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HM:
|
||||
switch (date_separator)
|
||||
@ -1019,7 +1004,7 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||
format_str = "%s %02u-%02u-%04u %02u:%02u";
|
||||
break;
|
||||
}
|
||||
n = snprintf(str, len, format_str,
|
||||
snprintf(str, len, format_str,
|
||||
msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
|
||||
runtime_log->last_played.day,
|
||||
@ -1027,7 +1012,6 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||
runtime_log->last_played.year,
|
||||
runtime_log->last_played.hour,
|
||||
runtime_log->last_played.minute);
|
||||
(void)n;
|
||||
return;
|
||||
case PLAYLIST_LAST_PLAYED_STYLE_DDMM_HM:
|
||||
switch (date_separator)
|
||||
@ -1042,14 +1026,13 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||
format_str = "%s %02u-%02u %02u:%02u";
|
||||
break;
|
||||
}
|
||||
n = snprintf(str, len, format_str,
|
||||
snprintf(str, len, format_str,
|
||||
msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
|
||||
runtime_log->last_played.day,
|
||||
runtime_log->last_played.month,
|
||||
runtime_log->last_played.hour,
|
||||
runtime_log->last_played.minute);
|
||||
(void)n;
|
||||
return;
|
||||
case PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY:
|
||||
switch (date_separator)
|
||||
@ -1064,13 +1047,12 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||
format_str = "%s %02u-%02u-%04u";
|
||||
break;
|
||||
}
|
||||
n = snprintf(str, len, format_str,
|
||||
snprintf(str, len, format_str,
|
||||
msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
|
||||
runtime_log->last_played.day,
|
||||
runtime_log->last_played.month,
|
||||
runtime_log->last_played.year);
|
||||
(void)n;
|
||||
return;
|
||||
case PLAYLIST_LAST_PLAYED_STYLE_DDMM:
|
||||
switch (date_separator)
|
||||
@ -1085,11 +1067,10 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||
format_str = "%s %02u-%02u";
|
||||
break;
|
||||
}
|
||||
n = snprintf(str, len, format_str,
|
||||
snprintf(str, len, format_str,
|
||||
msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
|
||||
runtime_log->last_played.day, runtime_log->last_played.month);
|
||||
(void)n;
|
||||
return;
|
||||
case PLAYLIST_LAST_PLAYED_STYLE_YMD_HMS:
|
||||
default:
|
||||
@ -1105,7 +1086,7 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||
format_str = "%s %04u-%02u-%02u %02u:%02u:%02u";
|
||||
break;
|
||||
}
|
||||
n = snprintf(str, len, format_str,
|
||||
snprintf(str, len, format_str,
|
||||
msg_hash_to_str(
|
||||
MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
|
||||
runtime_log->last_played.year,
|
||||
@ -1114,21 +1095,15 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||
runtime_log->last_played.hour,
|
||||
runtime_log->last_played.minute,
|
||||
runtime_log->last_played.second);
|
||||
(void)n;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
n = strlcpy(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), len);
|
||||
str[n ] = ' ';
|
||||
str[n+1] = '\0';
|
||||
n = strlcat(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_INLINE_CORE_DISPLAY_NEVER), len);
|
||||
}
|
||||
|
||||
if (n >= 64)
|
||||
n = 0; /* Silence GCC warnings... */
|
||||
(void)n;
|
||||
snprintf(str, len,
|
||||
"%s %s",
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
|
||||
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_INLINE_CORE_DISPLAY_NEVER)
|
||||
);
|
||||
}
|
||||
|
||||
/* Status */
|
||||
@ -1206,14 +1181,11 @@ void runtime_log_save(runtime_log_t *runtime_log)
|
||||
rjsonwriter_add_newline(writer);
|
||||
|
||||
/* > Runtime entry */
|
||||
value_string[0] = '\0';
|
||||
n = snprintf(value_string,
|
||||
sizeof(value_string), LOG_FILE_RUNTIME_FORMAT_STR,
|
||||
snprintf(value_string,
|
||||
sizeof(value_string),
|
||||
LOG_FILE_RUNTIME_FORMAT_STR,
|
||||
runtime_log->runtime.hours, runtime_log->runtime.minutes,
|
||||
runtime_log->runtime.seconds);
|
||||
if ((n < 0) || (n >= 64))
|
||||
n = 0; /* Silence GCC warnings... */
|
||||
(void)n;
|
||||
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "runtime");
|
||||
@ -1225,16 +1197,13 @@ void runtime_log_save(runtime_log_t *runtime_log)
|
||||
|
||||
/* > Last played entry */
|
||||
value_string[0] = '\0';
|
||||
n = snprintf(value_string, sizeof(value_string),
|
||||
snprintf(value_string, sizeof(value_string),
|
||||
LOG_FILE_LAST_PLAYED_FORMAT_STR,
|
||||
runtime_log->last_played.year, runtime_log->last_played.month,
|
||||
runtime_log->last_played.day,
|
||||
runtime_log->last_played.hour, runtime_log->last_played.minute,
|
||||
runtime_log->last_played.second);
|
||||
if ((n < 0) || (n >= 64))
|
||||
n = 0; /* Silence GCC warnings... */
|
||||
|
||||
(void)n;
|
||||
rjsonwriter_add_spaces(writer, 2);
|
||||
rjsonwriter_add_string(writer, "last_played");
|
||||
rjsonwriter_add_colon(writer);
|
||||
|
Loading…
x
Reference in New Issue
Block a user