(OSX) Static code analyzer cleanups

This commit is contained in:
Twinaphex 2016-05-02 16:57:28 +02:00
parent c9eac5cdc0
commit eeeec23c66
6 changed files with 4 additions and 35 deletions

View file

@ -1056,8 +1056,6 @@ bool rpng_load_image_argb(const char *path, uint32_t **data,
if (!handle) if (!handle)
goto end; goto end;
ptr = nbio_get_ptr(handle, &file_len);
nbio_begin_read(handle); nbio_begin_read(handle);
while (!nbio_iterate(handle)); while (!nbio_iterate(handle));

View file

@ -461,7 +461,6 @@ static uint64_t libretrodb_tell(libretrodb_t *db)
int libretrodb_create_index(libretrodb_t *db, int libretrodb_create_index(libretrodb_t *db,
const char *name, const char *field_name) const char *name, const char *field_name)
{ {
int rv;
struct node_iter_ctx nictx; struct node_iter_ctx nictx;
struct rmsgpack_dom_value key; struct rmsgpack_dom_value key;
libretrodb_index_t idx; libretrodb_index_t idx;
@ -476,10 +475,7 @@ int libretrodb_create_index(libretrodb_t *db,
bintree_t *tree = bintree_new(node_compare, &field_size); bintree_t *tree = bintree_new(node_compare, &field_size);
if (!tree || (libretrodb_cursor_open(db, &cur, NULL) != 0)) if (!tree || (libretrodb_cursor_open(db, &cur, NULL) != 0))
{
rv = -1;
goto clean; goto clean;
}
key.type = RDT_STRING; key.type = RDT_STRING;
key.val.string.len = strlen(field_name); key.val.string.len = strlen(field_name);
@ -491,7 +487,6 @@ int libretrodb_create_index(libretrodb_t *db,
{ {
if (item.type != RDT_MAP) if (item.type != RDT_MAP)
{ {
rv = -EINVAL;
printf("Only map keys are supported\n"); printf("Only map keys are supported\n");
goto clean; goto clean;
} }
@ -500,21 +495,18 @@ int libretrodb_create_index(libretrodb_t *db,
if (!field) if (!field)
{ {
rv = -EINVAL;
printf("field not found in item\n"); printf("field not found in item\n");
goto clean; goto clean;
} }
if (field->type != RDT_BINARY) if (field->type != RDT_BINARY)
{ {
rv = -EINVAL;
printf("field is not binary\n"); printf("field is not binary\n");
goto clean; goto clean;
} }
if (field->val.binary.len == 0) if (field->val.binary.len == 0)
{ {
rv = -EINVAL;
printf("field is empty\n"); printf("field is empty\n");
goto clean; goto clean;
} }
@ -523,7 +515,6 @@ int libretrodb_create_index(libretrodb_t *db,
field_size = field->val.binary.len; field_size = field->val.binary.len;
else if (field->val.binary.len != field_size) else if (field->val.binary.len != field_size)
{ {
rv = -EINVAL;
printf("field is not of correct size\n"); printf("field is not of correct size\n");
goto clean; goto clean;
} }
@ -531,7 +522,6 @@ int libretrodb_create_index(libretrodb_t *db,
buff = malloc(field_size + sizeof(uint64_t)); buff = malloc(field_size + sizeof(uint64_t));
if (!buff) if (!buff)
{ {
rv = -ENOMEM;
goto clean; goto clean;
} }
@ -546,7 +536,6 @@ int libretrodb_create_index(libretrodb_t *db,
printf("Value is not unique: "); printf("Value is not unique: ");
rmsgpack_dom_value_print(field); rmsgpack_dom_value_print(field);
printf("\n"); printf("\n");
rv = -EINVAL;
goto clean; goto clean;
} }
buff = NULL; buff = NULL;
@ -557,7 +546,6 @@ int libretrodb_create_index(libretrodb_t *db,
idx_header_offset = filestream_seek(db->fd, 0, SEEK_END); idx_header_offset = filestream_seek(db->fd, 0, SEEK_END);
(void)idx_header_offset; (void)idx_header_offset;
(void)rv;
strncpy(idx.name, name, 50); strncpy(idx.name, name, 50);

View file

@ -223,7 +223,6 @@ int rmsgpack_write_bin(RFILE *fd, const void *s, uint32_t len)
{ {
uint16_t tmp_i16; uint16_t tmp_i16;
uint32_t tmp_i32; uint32_t tmp_i32;
int written = sizeof(int8_t);
if (len == (uint8_t)len) if (len == (uint8_t)len)
{ {
@ -231,7 +230,6 @@ int rmsgpack_write_bin(RFILE *fd, const void *s, uint32_t len)
goto error; goto error;
if (filestream_write(fd, &len, sizeof(uint8_t)) == -1) if (filestream_write(fd, &len, sizeof(uint8_t)) == -1)
goto error; goto error;
written += sizeof(uint8_t);
} }
else if (len == (uint16_t)len) else if (len == (uint16_t)len)
{ {
@ -240,7 +238,6 @@ int rmsgpack_write_bin(RFILE *fd, const void *s, uint32_t len)
tmp_i16 = swap_if_little16(len); tmp_i16 = swap_if_little16(len);
if (filestream_write(fd, &tmp_i16, sizeof(uint16_t)) == -1) if (filestream_write(fd, &tmp_i16, sizeof(uint16_t)) == -1)
goto error; goto error;
written += sizeof(uint16_t);
} }
else else
{ {
@ -249,13 +246,11 @@ int rmsgpack_write_bin(RFILE *fd, const void *s, uint32_t len)
tmp_i32 = swap_if_little32(len); tmp_i32 = swap_if_little32(len);
if (filestream_write(fd, &tmp_i32, sizeof(uint32_t)) == -1) if (filestream_write(fd, &tmp_i32, sizeof(uint32_t)) == -1)
goto error; goto error;
written += sizeof(uint32_t);
} }
if (filestream_write(fd, s, len) == -1) if (filestream_write(fd, s, len) == -1)
goto error; goto error;
written += len;
return 0; return 0;
error: error:

View file

@ -162,7 +162,7 @@ static int dom_read_array_start(uint32_t len, void *data)
v->val.array.len = len; v->val.array.len = len;
v->val.array.items = NULL; v->val.array.items = NULL;
items = (struct rmsgpack_dom_value *)calloc(len, sizeof(struct rmsgpack_dom_pair)); items = (struct rmsgpack_dom_value *)calloc(len, sizeof(*items));
if (!items) if (!items)
return -ENOMEM; return -ENOMEM;
@ -454,20 +454,14 @@ int rmsgpack_dom_read_into(RFILE *fd, ...)
} }
if (map.type != RDT_MAP) if (map.type != RDT_MAP)
{
rv = -EINVAL;
goto clean; goto clean;
}
while (1) while (1)
{ {
key_name = va_arg(ap, const char *); key_name = va_arg(ap, const char *);
if (!key_name) if (!key_name)
{
rv = 0;
goto clean; goto clean;
}
key.type = RDT_STRING; key.type = RDT_STRING;
key.val.string.len = strlen(key_name); key.val.string.len = strlen(key_name);
@ -508,7 +502,6 @@ int rmsgpack_dom_read_into(RFILE *fd, ...)
memcpy(buff_value, value->val.string.buff, (size_t)min_len); memcpy(buff_value, value->val.string.buff, (size_t)min_len);
break; break;
default: default:
rv = -1;
goto clean; goto clean;
} }
} }

View file

@ -1299,15 +1299,12 @@ static int menu_displaylist_parse_playlist(menu_displaylist_info_t *info,
{ {
uint32_t core_name_hash; uint32_t core_name_hash;
char fill_buf[PATH_MAX_LENGTH], path_copy[PATH_MAX_LENGTH]; char fill_buf[PATH_MAX_LENGTH], path_copy[PATH_MAX_LENGTH];
bool core_detected = false;
const char *core_name = NULL; const char *core_name = NULL;
const char *db_name = NULL; const char *db_name = NULL;
const char *path = NULL; const char *path = NULL;
const char *label = NULL; const char *label = NULL;
const char *crc32 = NULL; const char *crc32 = NULL;
(void)core_detected;
strlcpy(path_copy, info->path, sizeof(path_copy)); strlcpy(path_copy, info->path, sizeof(path_copy));
path = path_copy; path = path_copy;
@ -1335,7 +1332,6 @@ static int menu_displaylist_parse_playlist(menu_displaylist_info_t *info,
char tmp[PATH_MAX_LENGTH] = {0}; char tmp[PATH_MAX_LENGTH] = {0};
snprintf(tmp, sizeof(tmp), " (%s)", core_name); snprintf(tmp, sizeof(tmp), " (%s)", core_name);
strlcat(fill_buf, tmp, sizeof(fill_buf)); strlcat(fill_buf, tmp, sizeof(fill_buf));
core_detected = true;
} }
} }
} }

View file

@ -302,8 +302,8 @@ static size_t state_manager_raw_compress(const void *src,
if (skip >= num16s) if (skip >= num16s)
break; break;
old16 += skip; old16 += skip;
new16 += skip; new16 += skip;
num16s -= skip; num16s -= skip;
if (skip > UINT16_MAX) if (skip > UINT16_MAX)
@ -318,7 +318,6 @@ static size_t state_manager_raw_compress(const void *src,
*compressed16++ = 0; *compressed16++ = 0;
*compressed16++ = skip; *compressed16++ = skip;
*compressed16++ = skip >> 16; *compressed16++ = skip >> 16;
skip = 0;
continue; continue;
} }