Wipe out a buncha warnings and pointless ifdefs (some warnings will remain until #5497 is fixed)

This commit is contained in:
Alcaro 2017-10-03 00:25:39 +02:00
parent 8d274f4f43
commit dc4c2cd6d9
7 changed files with 27 additions and 86 deletions

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

@ -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",
STRING_REP_INT64,
(int64_t*)&value->val.int_) == 0);
#else
test = (sscanf(buff.data + buff.offset,
"%lld",
(int64_t*)&value->val.int_) == 0);
#endif
if (test)
query_raise_expected_number(buff.offset, error);

View File

@ -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);

View File

@ -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);

View File

@ -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");
}