Skip to content

Commit

Permalink
C89 buildfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Mar 24, 2019
1 parent fcd55d8 commit cec06a0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 22 deletions.
4 changes: 2 additions & 2 deletions cores/dynamic_dummy.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void libretro_dummy_retro_init(void)
#if defined(HAVE_MENU) && defined(HAVE_RGUI)
settings_t *settings = config_get_ptr();
#endif
uint32_t i;
unsigned i;

/* Sensible defaults */
frame_buf_width = 320;
Expand Down Expand Up @@ -95,7 +95,7 @@ void libretro_dummy_retro_init(void)
#endif

dummy_frame_buf = (uint16_t*)calloc(frame_buf_width * frame_buf_height, sizeof(uint16_t));
for (i = 0; i < frame_buf_width * frame_buf_height; i++)
for (i = 0; i < (unsigned)(frame_buf_width * frame_buf_height); i++)
dummy_frame_buf[i] = 4 << 5;
}

Expand Down
46 changes: 27 additions & 19 deletions libretro-common/formats/xml/rxml.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,28 +146,31 @@ static char *strdup_range_escape(const char *begin, const char *end)

static struct rxml_attrib_node *rxml_parse_attrs(const char *str)
{
char *copy = strdup(str);
const char *elem;
struct rxml_attrib_node *list = NULL;
struct rxml_attrib_node *tail = NULL;
char *attrib = NULL;
char *value = NULL;
char *last_char = NULL;
char *save = NULL;
char *copy = strdup(str);
if (!copy)
return NULL;

char *last_char = copy + strlen(copy) - 1;
last_char = copy + strlen(copy) - 1;
if (*last_char == '/')
*last_char = '\0';

struct rxml_attrib_node *list = NULL;
struct rxml_attrib_node *tail = NULL;

char *attrib = NULL;
char *value = NULL;
char *save;
const char *elem = strtok_r(copy, " \n\t\f\v\r", &save);
elem = strtok_r(copy, " \n\t\f\v\r", &save);
while (elem)
{
const char *end;
struct rxml_attrib_node *new_node;
const char *eq = strstr(elem, "=\"");
if (!eq)
goto end;

const char *end = strrchr(eq + 2, '\"');
end = strrchr(eq + 2, '\"');
if (!end || end != (elem + strlen(elem) - 1))
goto end;

Expand All @@ -176,15 +179,15 @@ static struct rxml_attrib_node *rxml_parse_attrs(const char *str)
if (!attrib || !value)
goto end;

struct rxml_attrib_node *new_node =
new_node =
(struct rxml_attrib_node*)calloc(1, sizeof(*new_node));
if (!new_node)
goto end;

new_node->attrib = attrib;
new_node->value = value;
attrib = NULL;
value = NULL;
attrib = NULL;
value = NULL;

if (tail)
{
Expand Down Expand Up @@ -217,10 +220,11 @@ static char *find_first_space(const char *str)

static bool rxml_parse_tag(struct rxml_node *node, const char *str)
{
const char *name_end;
const char *str_ptr = str;
rxml_skip_spaces(&str_ptr);

const char *name_end = find_first_space(str_ptr);
name_end = find_first_space(str_ptr);
if (name_end)
{
node->name = strdup_range(str_ptr, name_end);
Expand Down Expand Up @@ -375,15 +379,18 @@ static struct rxml_node *rxml_parse_node(const char **ptr_)

static char *purge_xml_comments(const char *str)
{
size_t len = strlen(str);
char *copy_dest;
const char *copy_src;
size_t len = strlen(str);
char *new_str = (char*)malloc(len + 1);
if (!new_str)
return NULL;

new_str[len] = '\0';
new_str[len] = '\0';

copy_dest = new_str;
copy_src = str;

char *copy_dest = new_str;
const char *copy_src = str;
for (;;)
{
ptrdiff_t copy_len;
Expand Down Expand Up @@ -411,6 +418,7 @@ static char *purge_xml_comments(const char *str)

rxml_document_t *rxml_load_document(const char *path)
{
rxml_document_t *doc;
char *memory_buffer = NULL;
char *new_memory_buffer = NULL;
const char *mem_ptr = NULL;
Expand All @@ -421,7 +429,7 @@ rxml_document_t *rxml_load_document(const char *path)
if (!file)
return NULL;

rxml_document_t *doc = (rxml_document_t*)calloc(1, sizeof(*doc));
doc = (rxml_document_t*)calloc(1, sizeof(*doc));
if (!doc)
goto error;

Expand Down
2 changes: 1 addition & 1 deletion menu/drivers/rgui.c
Original file line number Diff line number Diff line change
Expand Up @@ -2164,8 +2164,8 @@ static bool rgui_set_aspect_ratio(rgui_t *rgui, bool delay_update)

static void *rgui_init(void **userdata, bool video_is_threaded)
{
unsigned new_font_height;
size_t fb_pitch, start;
unsigned fb_width, fb_height, new_font_height;
rgui_t *rgui = NULL;
bool ret = false;
settings_t *settings = config_get_ptr();
Expand Down

0 comments on commit cec06a0

Please sign in to comment.