mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-20 17:54:11 +00:00
More static code analysis nits
This commit is contained in:
parent
631da50dfa
commit
0cc56e2a1a
@ -66,7 +66,7 @@ static unsigned bitswap(unsigned i, unsigned range)
|
||||
unsigned ret = 0;
|
||||
|
||||
for (shifts = 0; shifts < range; shifts++)
|
||||
ret |= i & (1 << (range - shifts - 1)) ? (1 << shifts) : 0;
|
||||
ret |= (i & (1 << (range - shifts - 1))) ? (1 << shifts) : 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ static void autosave_thread(void *data)
|
||||
|
||||
while (!save->quit)
|
||||
{
|
||||
bool differ = false;
|
||||
bool differ;
|
||||
|
||||
autosave_lock(save);
|
||||
differ = memcmp(save->buffer, save->retro_buffer,
|
||||
|
@ -331,7 +331,7 @@ void save_ram_file(const char *path, int type)
|
||||
|
||||
if (!data)
|
||||
return;
|
||||
if (size <= 0)
|
||||
if (size == 0)
|
||||
return;
|
||||
|
||||
if (!retro_write_file(path, data, size))
|
||||
|
35
file_ops.c
35
file_ops.c
@ -201,10 +201,10 @@ static int read_7zip_file(
|
||||
SRes res;
|
||||
ISzAlloc allocImp;
|
||||
ISzAlloc allocTempImp;
|
||||
uint8_t *outBuffer = 0;
|
||||
size_t outBufferSize = 0;
|
||||
uint8_t *output = 0;
|
||||
size_t output_size = 0;
|
||||
uint16_t *temp = NULL;
|
||||
size_t tempSize = 0;
|
||||
size_t temp_size = 0;
|
||||
long outsize = -1;
|
||||
bool file_found = false;
|
||||
|
||||
@ -254,11 +254,11 @@ static int read_7zip_file(
|
||||
|
||||
len = SzArEx_GetFileNameUtf16(&db, i, NULL);
|
||||
|
||||
if (len > tempSize)
|
||||
if (len > temp_size)
|
||||
{
|
||||
free(temp);
|
||||
tempSize = len;
|
||||
temp = (uint16_t *)malloc(tempSize * sizeof(temp[0]));
|
||||
temp_size = len;
|
||||
temp = (uint16_t *)malloc(temp_size * sizeof(temp[0]));
|
||||
if (temp == 0)
|
||||
{
|
||||
res = SZ_ERROR_MEM;
|
||||
@ -276,7 +276,7 @@ static int read_7zip_file(
|
||||
* */
|
||||
file_found = true;
|
||||
res = SzArEx_Extract(&db, &lookStream.s, i,&blockIndex,
|
||||
&outBuffer, &outBufferSize,&offset, &outSizeProcessed,
|
||||
&output, &output_size, &offset, &outSizeProcessed,
|
||||
&allocImp, &allocTempImp);
|
||||
|
||||
if (res != SZ_OK)
|
||||
@ -286,7 +286,7 @@ static int read_7zip_file(
|
||||
|
||||
if (optional_outfile != NULL)
|
||||
{
|
||||
const void *ptr = (const void*)(outBuffer + offset);
|
||||
const void *ptr = (const void*)(output + offset);
|
||||
|
||||
if (!retro_write_file(optional_outfile, ptr, outsize))
|
||||
{
|
||||
@ -307,14 +307,14 @@ static int read_7zip_file(
|
||||
* copy and free the old one. */
|
||||
*buf = malloc(outsize + 1);
|
||||
((char*)(*buf))[outsize] = '\0';
|
||||
memcpy(*buf,outBuffer+offset,outsize);
|
||||
memcpy(*buf,output + offset,outsize);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IAlloc_Free(&allocImp, outBuffer);
|
||||
IAlloc_Free(&allocImp, output);
|
||||
SzArEx_Free(&db, &allocImp);
|
||||
free(temp);
|
||||
File_Close(&archiveStream.file);
|
||||
@ -346,7 +346,7 @@ static struct string_list *compressed_7zip_file_list_new(
|
||||
ISzAlloc allocImp;
|
||||
ISzAlloc allocTempImp;
|
||||
uint16_t *temp = NULL;
|
||||
size_t tempSize = 0;
|
||||
size_t temp_size = 0;
|
||||
long outsize = -1;
|
||||
|
||||
struct string_list *ext_list = NULL;
|
||||
@ -384,13 +384,6 @@ static struct string_list *compressed_7zip_file_list_new(
|
||||
if (res == SZ_OK)
|
||||
{
|
||||
uint32_t i;
|
||||
uint32_t blockIndex = 0xFFFFFFFF;
|
||||
uint8_t *outBuffer = 0;
|
||||
size_t outBufferSize = 0;
|
||||
|
||||
(void)blockIndex;
|
||||
(void)outBufferSize;
|
||||
(void)outBuffer;
|
||||
|
||||
for (i = 0; i < db.db.NumFiles; i++)
|
||||
{
|
||||
@ -412,11 +405,11 @@ static struct string_list *compressed_7zip_file_list_new(
|
||||
|
||||
len = SzArEx_GetFileNameUtf16(&db, i, NULL);
|
||||
|
||||
if (len > tempSize)
|
||||
if (len > temp_size)
|
||||
{
|
||||
free(temp);
|
||||
tempSize = len;
|
||||
temp = (uint16_t *)malloc(tempSize * sizeof(temp[0]));
|
||||
temp_size = len;
|
||||
temp = (uint16_t *)malloc(temp_size * sizeof(temp[0]));
|
||||
|
||||
if (temp == 0)
|
||||
{
|
||||
|
@ -2980,13 +2980,12 @@ error:
|
||||
static void* gl_read_frame_raw(void *data, unsigned *width_p,
|
||||
unsigned *height_p, size_t *pitch_p)
|
||||
{
|
||||
int i;
|
||||
gl_t *gl = (gl_t*)data;
|
||||
unsigned width = gl->last_width[gl->tex_index];
|
||||
unsigned height = gl->last_height[gl->tex_index];
|
||||
size_t pitch = gl->tex_w * gl->base_size;
|
||||
gl_t *gl = (gl_t*)data;
|
||||
unsigned width = gl->last_width[gl->tex_index];
|
||||
unsigned height = gl->last_height[gl->tex_index];
|
||||
size_t pitch = gl->tex_w * gl->base_size;
|
||||
#ifdef HAVE_FBO
|
||||
void* buffer = NULL;
|
||||
void* buffer = NULL;
|
||||
#endif
|
||||
void* buffer_texture = NULL;
|
||||
|
||||
@ -3019,6 +3018,8 @@ unsigned *height_p, size_t *pitch_p)
|
||||
#ifdef HAVE_FBO
|
||||
if (gl->hw_render_use)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for(i = 0; i < height ; i++)
|
||||
memcpy((uint8_t*)buffer + i * pitch,
|
||||
(uint8_t*)buffer_texture + (height - 1 - i) * pitch, pitch);
|
||||
|
@ -106,7 +106,6 @@ static unsigned twoxbr_generic_threads(void *data)
|
||||
|
||||
static void SetupFormat(void * data)
|
||||
{
|
||||
uint16_t r, g, b, y, u, v;
|
||||
uint32_t c;
|
||||
struct filter_data *filt = (struct filter_data*)data;
|
||||
|
||||
@ -210,12 +209,12 @@ static void SetupFormat(void * data)
|
||||
|
||||
for (c = 0; c < 65536; c++)
|
||||
{
|
||||
r = filt->tbl_5_to_8[(c & RED_MASK565) >> 11];
|
||||
g = filt->tbl_6_to_8[(c & GREEN_MASK565) >> 5];
|
||||
b = filt->tbl_5_to_8[(c & BLUE_MASK565) ];
|
||||
y = ((r << 4) + (g << 5) + (b << 2));
|
||||
u = ( -r - (g << 1) + (b << 2));
|
||||
v = ((r << 1) - (g << 1) - (b >> 1));
|
||||
uint16_t r = filt->tbl_5_to_8[(c & RED_MASK565) >> 11];
|
||||
uint16_t g = filt->tbl_6_to_8[(c & GREEN_MASK565) >> 5];
|
||||
uint16_t b = filt->tbl_5_to_8[(c & BLUE_MASK565) ];
|
||||
uint16_t y = ((r << 4) + (g << 5) + (b << 2));
|
||||
uint16_t u = ( -r - (g << 1) + (b << 2));
|
||||
uint16_t v = ((r << 1) - (g << 1) - (b >> 1));
|
||||
filt->RGBtoYUV[c] = y + u + v;
|
||||
}
|
||||
}
|
||||
|
@ -246,7 +246,6 @@ static void udev_handle_mouse(udev_input_t *udev,
|
||||
else if (event->value == -1)
|
||||
udev->mouse_whd = 1;
|
||||
break;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -759,10 +759,8 @@ static int zlib_get_file_list_cb(const char *path, const char *valid_exts,
|
||||
|
||||
if (ext_list)
|
||||
{
|
||||
char last_char = ' ';
|
||||
|
||||
/* Checks if this entry is a directory or a file. */
|
||||
last_char = path[strlen(path)-1];
|
||||
char last_char = path[strlen(path)-1];
|
||||
|
||||
if (last_char == '/' || last_char == '\\' ) /* Skip if directory. */
|
||||
goto error;
|
||||
|
@ -154,7 +154,7 @@ bool path_contains_compressed_file(const char *path)
|
||||
**/
|
||||
bool path_is_compressed_file(const char* path)
|
||||
{
|
||||
#ifdef HAVE_COMPRESSION
|
||||
#if defined(HAVE_COMPRESSION) && (defined(HAVE_ZLIB) || defined(HAVE_7ZIP))
|
||||
const char* file_ext = path_get_extension(path);
|
||||
|
||||
#ifdef HAVE_ZLIB
|
||||
|
@ -220,9 +220,9 @@ static bool png_process_ihdr(struct png_ihdr *ihdr)
|
||||
#ifdef RPNG_TEST
|
||||
fprintf(stderr, "IHDR: (%u x %u), bpc = %u, palette = %s, color = %s, alpha = %s, adam7 = %s.\n",
|
||||
ihdr->width, ihdr->height,
|
||||
ihdr->depth, ihdr->color_type == PNG_IHDR_COLOR_PLT ? "yes" : "no",
|
||||
ihdr->color_type & PNG_IHDR_COLOR_RGB ? "yes" : "no",
|
||||
ihdr->color_type & PNG_IHDR_COLOR_GRAY_ALPHA ? "yes" : "no",
|
||||
ihdr->depth, (ihdr->color_type == PNG_IHDR_COLOR_PLT) ? "yes" : "no",
|
||||
(ihdr->color_type & PNG_IHDR_COLOR_RGB) ? "yes" : "no",
|
||||
(ihdr->color_type & PNG_IHDR_COLOR_GRAY_ALPHA) ? "yes" : "no",
|
||||
ihdr->interlace == 1 ? "yes" : "no");
|
||||
#endif
|
||||
|
||||
|
@ -80,7 +80,6 @@ static void sha256_block(struct sha256_ctx *p)
|
||||
unsigned i;
|
||||
uint32_t s0, s1;
|
||||
uint32_t a, b, c, d, e, f, g, h;
|
||||
uint32_t t1, t2, maj, ch;
|
||||
|
||||
for (i = 0; i < 16; i++)
|
||||
p->w[i] = load32be(p->in.u32 + i);
|
||||
@ -97,15 +96,23 @@ static void sha256_block(struct sha256_ctx *p)
|
||||
|
||||
for (i = 0; i < 64; i++)
|
||||
{
|
||||
uint32_t t1, t2, maj, ch;
|
||||
|
||||
s0 = ROR32(a, 2) ^ ROR32(a, 13) ^ ROR32(a, 22);
|
||||
maj = (a & b) ^ (a & c) ^ (b & c);
|
||||
t2 = s0 + maj;
|
||||
s1 = ROR32(e, 6) ^ ROR32(e, 11) ^ ROR32(e, 25);
|
||||
ch = (e & f) ^ (~e & g);
|
||||
t1 = h + s1 + ch + T_K[i] + p->w[i];
|
||||
t2 = s0 + maj;
|
||||
s1 = ROR32(e, 6) ^ ROR32(e, 11) ^ ROR32(e, 25);
|
||||
ch = (e & f) ^ (~e & g);
|
||||
t1 = h + s1 + ch + T_K[i] + p->w[i];
|
||||
|
||||
h = g; g = f; f = e; e = d + t1;
|
||||
d = c; c = b; b = a; a = t1 + t2;
|
||||
h = g;
|
||||
g = f;
|
||||
f = e;
|
||||
e = d + t1;
|
||||
d = c;
|
||||
c = b;
|
||||
b = a;
|
||||
a = t1 + t2;
|
||||
}
|
||||
|
||||
p->h[0] += a; p->h[1] += b; p->h[2] += c; p->h[3] += d;
|
||||
@ -118,20 +125,20 @@ static void sha256_block(struct sha256_ctx *p)
|
||||
static void sha256_chunk(struct sha256_ctx *p,
|
||||
const uint8_t *s, unsigned len)
|
||||
{
|
||||
unsigned l;
|
||||
|
||||
p->len += len;
|
||||
|
||||
while (len)
|
||||
{
|
||||
l = 64 - p->inlen;
|
||||
l = (len < l) ? len : l;
|
||||
unsigned l = 64 - p->inlen;
|
||||
|
||||
if (len < l)
|
||||
l = len;
|
||||
|
||||
memcpy(p->in.u8 + p->inlen, s, l);
|
||||
|
||||
s += l;
|
||||
p->inlen += l;
|
||||
len -= l;
|
||||
s += l;
|
||||
p->inlen += l;
|
||||
len -= l;
|
||||
|
||||
if (p->inlen == 64)
|
||||
sha256_block(p);
|
||||
|
@ -262,7 +262,6 @@ static void rmenu_wallpaper_set_defaults(char *s, size_t len)
|
||||
|
||||
static void rmenu_context_reset(void)
|
||||
{
|
||||
unsigned fb_width, fb_height;
|
||||
char menu_bg[PATH_MAX_LENGTH] = {0};
|
||||
menu_handle_t *menu = menu_driver_get_ptr();
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
@ -2324,16 +2324,17 @@ static void xmb_list_clear(file_list_t *list)
|
||||
|
||||
static void xmb_list_deep_copy(menu_handle_t *menu, const file_list_t *src, file_list_t *dst)
|
||||
{
|
||||
size_t size, i;
|
||||
size_t i;
|
||||
size_t size = dst->size;
|
||||
|
||||
size = dst->size;
|
||||
for (i = 0; i < size; ++i)
|
||||
{
|
||||
float *subjects[5];
|
||||
xmb_node_t *node = (xmb_node_t*)file_list_get_userdata_at_offset(dst, i);
|
||||
|
||||
if (node)
|
||||
{
|
||||
float *subjects[5];
|
||||
|
||||
subjects[0] = &node->alpha;
|
||||
subjects[1] = &node->label_alpha;
|
||||
subjects[2] = &node->zoom;
|
||||
@ -2350,6 +2351,7 @@ static void xmb_list_deep_copy(menu_handle_t *menu, const file_list_t *src, file
|
||||
file_list_copy(src, dst);
|
||||
|
||||
size = dst->size;
|
||||
|
||||
for (i = 0; i < size; ++i)
|
||||
{
|
||||
void *src_udata = file_list_get_userdata_at_offset(src, i);
|
||||
|
@ -936,7 +936,7 @@ static int menu_displaylist_parse_playlist(menu_displaylist_info_t *info,
|
||||
|
||||
list_size = content_playlist_size(playlist);
|
||||
|
||||
if (list_size <= 0)
|
||||
if (list_size == 0)
|
||||
{
|
||||
menu_list_push(info->list,
|
||||
menu_hash_to_str(MENU_LABEL_VALUE_NO_PLAYLIST_ENTRIES_AVAILABLE),
|
||||
@ -1525,7 +1525,7 @@ static int deferred_push_video_shader_parameters_common(
|
||||
unsigned i;
|
||||
size_t list_size = shader->num_parameters;
|
||||
|
||||
if (list_size <= 0)
|
||||
if (list_size == 0)
|
||||
{
|
||||
menu_list_push(info->list,
|
||||
menu_hash_to_str(MENU_LABEL_VALUE_NO_SHADER_PARAMETERS),
|
||||
@ -2207,7 +2207,7 @@ static int menu_displaylist_parse_generic(menu_displaylist_info_t *info, bool *n
|
||||
|
||||
list_size = str_list->size;
|
||||
|
||||
if (list_size <= 0)
|
||||
if (list_size == 0)
|
||||
{
|
||||
if (!(info->flags & SL_FLAG_ALLOW_EMPTY_LIST))
|
||||
{
|
||||
|
@ -350,9 +350,11 @@ void menu_input_st_hex_callback(void *userdata, const char *str)
|
||||
setting = menu_setting_find(label);
|
||||
|
||||
if (setting)
|
||||
{
|
||||
if (str[0] == '#')
|
||||
str++;
|
||||
*setting->value.unsigned_integer = strtoul(str, NULL, 16);
|
||||
}
|
||||
}
|
||||
|
||||
menu_input_key_end_line();
|
||||
|
@ -55,7 +55,6 @@ static void menu_settings_info_list_free(rarch_setting_info_t *list_info)
|
||||
{
|
||||
if (list_info)
|
||||
free(list_info);
|
||||
list_info = NULL;
|
||||
}
|
||||
|
||||
static bool menu_settings_list_append(rarch_setting_t **list,
|
||||
@ -668,7 +667,7 @@ static int setting_action_start_analog_dpad_mode(void *data)
|
||||
|
||||
static int setting_action_start_libretro_device_type(void *data)
|
||||
{
|
||||
unsigned current_device, i, devices[128], types = 0, port = 0;
|
||||
unsigned current_device, devices[128], types = 0, port = 0;
|
||||
const struct retro_controller_info *desc = NULL;
|
||||
rarch_setting_t *setting = (rarch_setting_t*)data;
|
||||
settings_t *settings = config_get_ptr();
|
||||
@ -692,6 +691,8 @@ static int setting_action_start_libretro_device_type(void *data)
|
||||
|
||||
if (desc)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < desc->num_types; i++)
|
||||
{
|
||||
unsigned id = desc->types[i].id;
|
||||
@ -1690,17 +1691,19 @@ static void setting_get_string_representation_uint_user_language(void *data,
|
||||
static void setting_get_string_representation_uint_libretro_log_level(void *data,
|
||||
char *s, size_t len)
|
||||
{
|
||||
static const char *modes[] = {
|
||||
"0 (Debug)",
|
||||
"1 (Info)",
|
||||
"2 (Warning)",
|
||||
"3 (Error)"
|
||||
};
|
||||
rarch_setting_t *setting = (rarch_setting_t*)data;
|
||||
|
||||
if (setting)
|
||||
{
|
||||
static const char *modes[] = {
|
||||
"0 (Debug)",
|
||||
"1 (Info)",
|
||||
"2 (Warning)",
|
||||
"3 (Error)"
|
||||
};
|
||||
strlcpy(s, modes[*setting->value.unsigned_integer],
|
||||
len);
|
||||
}
|
||||
}
|
||||
|
||||
static void setting_get_string_representation_uint(void *data,
|
||||
@ -6600,6 +6603,7 @@ rarch_setting_t *menu_setting_new(unsigned mask)
|
||||
goto error;
|
||||
|
||||
menu_settings_info_list_free(list_info);
|
||||
list_info = NULL;
|
||||
|
||||
return list;
|
||||
|
||||
@ -6608,6 +6612,8 @@ error:
|
||||
menu_settings_info_list_free(list_info);
|
||||
menu_setting_free(list);
|
||||
|
||||
list_info = NULL;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -402,12 +402,13 @@ error:
|
||||
**/
|
||||
static int rarch_main_data_http_iterate_transfer(void *data)
|
||||
{
|
||||
http_handle_t *http = (http_handle_t*)data;
|
||||
http_handle_t *http = (http_handle_t*)data;
|
||||
size_t pos = 0, tot = 0;
|
||||
int percent = 0;
|
||||
|
||||
if (!net_http_update(http->handle, &pos, &tot))
|
||||
{
|
||||
int percent = 0;
|
||||
|
||||
if(tot != 0)
|
||||
percent = (unsigned long long)pos * 100
|
||||
/ (unsigned long long)tot;
|
||||
|
Loading…
x
Reference in New Issue
Block a user