mirror of
https://github.com/libretro/RetroArch
synced 2025-04-11 00:44:20 +00:00
More static code analysis fixes
This commit is contained in:
parent
b5456bc940
commit
1eb80f6c93
@ -201,6 +201,10 @@ int database_info_build_query(char *s, size_t len,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NOTE: Allocates memory, it is the caller's responsibility to free the
|
||||||
|
* memory after it is no longer required.
|
||||||
|
*/
|
||||||
char *bin_to_hex_alloc(const uint8_t *data, size_t len)
|
char *bin_to_hex_alloc(const uint8_t *data, size_t len)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
@ -210,7 +214,7 @@ char *bin_to_hex_alloc(const uint8_t *data, size_t len)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
snprintf(ret+i*2, 3, "%02X", data[i]);
|
snprintf(ret+i * 2, 3, "%02X", data[i]);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,6 +113,10 @@ void database_info_free(database_info_handle_t *handle);
|
|||||||
int database_info_build_query(
|
int database_info_build_query(
|
||||||
char *query, size_t len, const char *label, const char *path);
|
char *query, size_t len, const char *label, const char *path);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NOTE: Allocates memory, it is the caller's responsibility to free the
|
||||||
|
* memory after it is no longer required.
|
||||||
|
*/
|
||||||
char *bin_to_hex_alloc(const uint8_t *data, size_t len);
|
char *bin_to_hex_alloc(const uint8_t *data, size_t len);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -40,11 +40,11 @@ bool texture_image_set_color_shifts(unsigned *r_shift, unsigned *g_shift,
|
|||||||
{
|
{
|
||||||
driver_t *driver = driver_get_ptr();
|
driver_t *driver = driver_get_ptr();
|
||||||
/* This interface "leak" is very ugly. FIXME: Fix this properly ... */
|
/* This interface "leak" is very ugly. FIXME: Fix this properly ... */
|
||||||
bool use_rgba = driver ? driver->gfx_use_rgba : false;
|
bool use_rgba = driver ? driver->gfx_use_rgba : false;
|
||||||
*a_shift = 24;
|
*a_shift = 24;
|
||||||
*r_shift = use_rgba ? 0 : 16;
|
*r_shift = use_rgba ? 0 : 16;
|
||||||
*g_shift = 8;
|
*g_shift = 8;
|
||||||
*b_shift = use_rgba ? 16 : 0;
|
*b_shift = use_rgba ? 16 : 0;
|
||||||
|
|
||||||
return use_rgba;
|
return use_rgba;
|
||||||
}
|
}
|
||||||
@ -63,11 +63,11 @@ bool texture_image_color_convert(unsigned r_shift,
|
|||||||
for (i = 0; i < num_pixels; i++)
|
for (i = 0; i < num_pixels; i++)
|
||||||
{
|
{
|
||||||
uint32_t col = pixels[i];
|
uint32_t col = pixels[i];
|
||||||
uint8_t a = (uint8_t)(col >> 24);
|
uint8_t a = (uint8_t)(col >> 24);
|
||||||
uint8_t r = (uint8_t)(col >> 16);
|
uint8_t r = (uint8_t)(col >> 16);
|
||||||
uint8_t g = (uint8_t)(col >> 8);
|
uint8_t g = (uint8_t)(col >> 8);
|
||||||
uint8_t b = (uint8_t)(col >> 0);
|
uint8_t b = (uint8_t)(col >> 0);
|
||||||
pixels[i] = (a << a_shift) |
|
pixels[i] = (a << a_shift) |
|
||||||
(r << r_shift) | (g << g_shift) | (b << b_shift);
|
(r << r_shift) | (g << g_shift) | (b << b_shift);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,8 +219,8 @@ bool texture_image_load(struct texture_image *out_img, const char *path)
|
|||||||
#else
|
#else
|
||||||
bool texture_image_load(struct texture_image *out_img, const char *path)
|
bool texture_image_load(struct texture_image *out_img, const char *path)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
|
||||||
unsigned r_shift, g_shift, b_shift, a_shift;
|
unsigned r_shift, g_shift, b_shift, a_shift;
|
||||||
|
bool ret = false;
|
||||||
|
|
||||||
texture_image_set_color_shifts(&r_shift, &g_shift, &b_shift,
|
texture_image_set_color_shifts(&r_shift, &g_shift, &b_shift,
|
||||||
&a_shift);
|
&a_shift);
|
||||||
@ -229,9 +229,9 @@ bool texture_image_load(struct texture_image *out_img, const char *path)
|
|||||||
|
|
||||||
if (strstr(path, ".tga"))
|
if (strstr(path, ".tga"))
|
||||||
{
|
{
|
||||||
void *raw_buf = NULL;
|
|
||||||
uint8_t *buf = NULL;
|
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
|
void *raw_buf = NULL;
|
||||||
|
uint8_t *buf = NULL;
|
||||||
ret = read_file(path, &raw_buf, &len);
|
ret = read_file(path, &raw_buf, &len);
|
||||||
|
|
||||||
if (!ret || len < 0)
|
if (!ret || len < 0)
|
||||||
|
@ -776,7 +776,7 @@ bool video_driver_overlay_interface(const video_overlay_interface_t **iface)
|
|||||||
driver_t *driver = driver_get_ptr();
|
driver_t *driver = driver_get_ptr();
|
||||||
const video_driver_t *video = video_driver_ctx_get_ptr(driver);
|
const video_driver_t *video = video_driver_ctx_get_ptr(driver);
|
||||||
|
|
||||||
if (video->overlay_interface)
|
if (video && video->overlay_interface)
|
||||||
{
|
{
|
||||||
video->overlay_interface(driver->video_data, iface);
|
video->overlay_interface(driver->video_data, iface);
|
||||||
return true;
|
return true;
|
||||||
|
@ -407,11 +407,16 @@ static int database_info_iterate_serial_lookup(
|
|||||||
|
|
||||||
if (db_state->entry_index == 0)
|
if (db_state->entry_index == 0)
|
||||||
{
|
{
|
||||||
char query[50] = {0};
|
char query[50];
|
||||||
snprintf(query, sizeof(query), "{'serial': b'%s'}",
|
char *serial_buf = bin_to_hex_alloc((uint8_t*)db_state->serial, 10 * sizeof(uint8_t));
|
||||||
bin_to_hex_alloc((uint8_t*)db_state->serial, 10*sizeof(uint8_t)));
|
|
||||||
|
|
||||||
|
if (!serial_buf)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
snprintf(query, sizeof(query), "{'serial': b'%s'}", serial_buf);
|
||||||
database_info_list_iterate_new(db_state, query);
|
database_info_list_iterate_new(db_state, query);
|
||||||
|
|
||||||
|
free(serial_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (db_state->info)
|
if (db_state->info)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user