diff --git a/libretro-common/include/formats/rwav.h b/libretro-common/include/formats/rwav.h index 5407de832d..e33736cb86 100644 --- a/libretro-common/include/formats/rwav.h +++ b/libretro-common/include/formats/rwav.h @@ -31,13 +31,13 @@ RETRO_BEGIN_DECLS typedef struct { /* bits per sample */ - int bitspersample; + unsigned int bitspersample; /* number of channels */ - int numchannels; + unsigned int numchannels; /* sample rate */ - int samplerate; + unsigned int samplerate; /* number of *samples* */ size_t numsamples; diff --git a/libretro-common/include/retro_common_api.h b/libretro-common/include/retro_common_api.h index 536810c0c9..659f90d76e 100644 --- a/libretro-common/include/retro_common_api.h +++ b/libretro-common/include/retro_common_api.h @@ -76,15 +76,15 @@ typedef int ssize_t; #endif #ifdef _WIN32 -#define STRING_REP_INT64 "%I64u" +#define STRING_REP_INT64 "%I64d" #define STRING_REP_UINT64 "%I64u" #define STRING_REP_USIZE "%Iu" #elif defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L && !defined(VITA) && !defined(WIIU) -#define STRING_REP_INT64 "%llu" +#define STRING_REP_INT64 "%lld" #define STRING_REP_UINT64 "%llu" #define STRING_REP_USIZE "%zu" #else -#define STRING_REP_INT64 "%llu" +#define STRING_REP_INT64 "%lld" #define STRING_REP_UINT64 "%llu" #define STRING_REP_USIZE "%lu" #endif diff --git a/libretro-common/net/net_http.c b/libretro-common/net/net_http.c index d49dc38127..0d6d5b3c5d 100644 --- a/libretro-common/net/net_http.c +++ b/libretro-common/net/net_http.c @@ -117,8 +117,8 @@ void net_http_urlencode_full(char **dest, const char *source) for (; *source; source++) { /* any non-ascii character will just be encoded without question */ - if ((int)*source < sizeof(urlencode_lut) && urlencode_lut[(int)*source]) - snprintf(enc, len, "%c", urlencode_lut[(int)*source]); + if ((unsigned)*source < sizeof(urlencode_lut) && urlencode_lut[(unsigned)*source]) + snprintf(enc, len, "%c", urlencode_lut[(unsigned)*source]); else snprintf(enc, len, "%%%02X", *source & 0xFF); diff --git a/libretro-db/query.c b/libretro-db/query.c index f0fd6cb291..646b36d5dd 100644 --- a/libretro-db/query.c +++ b/libretro-db/query.c @@ -288,45 +288,26 @@ struct registered_func registered_functions[100] = { static void query_raise_expected_number(ssize_t where, const char **error) { -#ifdef _WIN32 snprintf(tmp_error_buff, MAX_ERROR_LEN, - "%I64u::Expected number", + STRING_REP_UINT64 "::Expected number", (uint64_t)where); -#else - snprintf(tmp_error_buff, MAX_ERROR_LEN, - "%llu::Expected number", - (uint64_t)where); -#endif *error = tmp_error_buff; } static void query_raise_expected_string(ssize_t where, const char ** error) { -#ifdef _WIN32 snprintf(tmp_error_buff, MAX_ERROR_LEN, - "%I64u::Expected string", + STRING_REP_UINT64 "::Expected string", (uint64_t)where); -#else - snprintf(tmp_error_buff, MAX_ERROR_LEN, - "%llu::Expected string", - (uint64_t)where); -#endif *error = tmp_error_buff; } static void query_raise_unexpected_eof(ssize_t where, const char ** error) { -#ifdef _WIN32 snprintf(tmp_error_buff, MAX_ERROR_LEN, - "%I64u::Unexpected EOF", + STRING_REP_UINT64 "::Unexpected EOF", (uint64_t)where ); -#else - snprintf(tmp_error_buff, MAX_ERROR_LEN, - "%llu::Unexpected EOF", - (uint64_t)where - ); -#endif *error = tmp_error_buff; } @@ -339,17 +320,10 @@ static void query_raise_enomem(const char **error) static void query_raise_unknown_function(ssize_t where, const char *name, ssize_t len, const char **error) { -#ifdef _WIN32 int n = snprintf(tmp_error_buff, MAX_ERROR_LEN, - "%I64u::Unknown function '", + STRING_REP_UINT64 "::Unknown function '", (uint64_t)where ); -#else - int n = snprintf(tmp_error_buff, MAX_ERROR_LEN, - "%llu::Unknown function '", - (uint64_t)where - ); -#endif if (len < (MAX_ERROR_LEN - n - 3)) strncpy(tmp_error_buff + n, name, len); @@ -361,19 +335,11 @@ static void query_raise_unknown_function(ssize_t where, const char *name, static void query_raise_expected_eof( ssize_t where, char found, const char **error) { -#ifdef _WIN32 snprintf(tmp_error_buff, MAX_ERROR_LEN, - "%I64u::Expected EOF found '%c'", + STRING_REP_UINT64 "::Expected EOF found '%c'", (uint64_t)where, found ); -#else - snprintf(tmp_error_buff, MAX_ERROR_LEN, - "%llu::Expected EOF found '%c'", - (uint64_t)where, - found - ); -#endif *error = tmp_error_buff; } @@ -381,15 +347,9 @@ static void query_raise_unexpected_char( ssize_t where, char expected, char found, const char **error) { -#ifdef _WIN32 snprintf(tmp_error_buff, MAX_ERROR_LEN, - "%I64u::Expected '%c' found '%c'", + STRING_REP_UINT64 "::Expected '%c' found '%c'", (uint64_t)where, expected, found); -#else - snprintf(tmp_error_buff, MAX_ERROR_LEN, - "%llu::Expected '%c' found '%c'", - (uint64_t)where, expected, found); -#endif *error = tmp_error_buff; } @@ -417,15 +377,9 @@ static struct buffer query_parse_integer(struct buffer buff, value->type = RDT_INT; -#ifdef _WIN32 test = (sscanf(buff.data + buff.offset, - "%I64d", - (int64_t*)&value->val.int_) == 0); -#else - test = (sscanf(buff.data + buff.offset, - "%lld", - (int64_t*)&value->val.int_) == 0); -#endif + STRING_REP_INT64, + (int64_t*)&value->val.int_) == 0); if (test) query_raise_expected_number(buff.offset, error); diff --git a/libretro-db/rmsgpack_dom.c b/libretro-db/rmsgpack_dom.c index 590cd00e25..f7d6d3d916 100644 --- a/libretro-db/rmsgpack_dom.c +++ b/libretro-db/rmsgpack_dom.c @@ -315,18 +315,10 @@ void rmsgpack_dom_value_print(struct rmsgpack_dom_value *obj) printf("false"); break; case RDT_INT: -#ifdef _WIN32 - printf("%I64d", (int64_t)obj->val.int_); -#else - printf("%lld", (int64_t)obj->val.int_); -#endif + printf(STRING_REP_INT64, (int64_t)obj->val.int_); break; case RDT_UINT: -#ifdef _WIN32 - printf("%I64u", (uint64_t)obj->val.uint_); -#else - printf("%llu", (uint64_t)obj->val.uint_); -#endif + printf(STRING_REP_UINT64, (uint64_t)obj->val.uint_); break; case RDT_STRING: printf("\"%s\"", obj->val.string.buff); diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 26335824d9..fab26f7c1e 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -558,11 +558,7 @@ static void menu_action_setting_disp_set_label_perf_counters_common( return; snprintf(s, len, -#ifdef _WIN32 - "%I64u ticks, %I64u runs.", -#else - "%llu ticks, %llu runs.", -#endif + STRING_REP_UINT64 " ticks, " STRING_REP_UINT64 " runs.", ((uint64_t)counters[offset]->total / (uint64_t)counters[offset]->call_cnt), (uint64_t)counters[offset]->call_cnt); diff --git a/tasks/task_save.c b/tasks/task_save.c index 4ea640fd1b..febb7b9143 100644 --- a/tasks/task_save.c +++ b/tasks/task_save.c @@ -173,10 +173,9 @@ static void autosave_thread(void *data) else RARCH_LOG("SRAM changed ... autosaving ...\n"); - failed |= filestream_write(file, save->buffer, save->bufsize) - != save->bufsize; - failed |= filestream_flush(file) != 0; - failed |= filestream_close(file) != 0; + failed |= ((size_t)filestream_write(file, save->buffer, save->bufsize) != save->bufsize); + failed |= (filestream_flush(file) != 0); + failed |= (filestream_close(file) != 0); if (failed) RARCH_WARN("Failed to autosave SRAM. Disk might be full.\n"); } @@ -184,12 +183,12 @@ static void autosave_thread(void *data) slock_lock(save->cond_lock); - if (!save->quit) + if (!save->quit) #if defined(_MSC_VER) && _MSC_VER <= 1200 - scond_wait_timeout(save->cond, save->cond_lock, save->interval * 1000000); -#else - scond_wait_timeout(save->cond, save->cond_lock, save->interval * 1000000LL); -#endif + scond_wait_timeout(save->cond, save->cond_lock, save->interval * 1000000); +#else + scond_wait_timeout(save->cond, save->cond_lock, save->interval * 1000000LL); +#endif slock_unlock(save->cond_lock); }