forked from enlightenment/efl
Eolian: fix coverity issues.
CID 1216274 CID 1216275 CID 1216276 CID 1216277 CID 1216278 CID 1216279 CID 1216280
This commit is contained in:
parent
1aa3510666
commit
b10a1b11f1
|
@ -28,7 +28,7 @@ _class_func_names_fill(const Eolian_Class class, const char *over_classname, con
|
|||
{
|
||||
current_class = class;
|
||||
if (!class)
|
||||
strcpy(current_classname, over_classname);
|
||||
strncpy(current_classname, over_classname, sizeof(current_classname) - 1);
|
||||
else
|
||||
_class_name_concatenate(class, current_classname);
|
||||
|
||||
|
|
|
@ -588,6 +588,7 @@ eo_source_end_generate(const Eolian_Class class, Eina_Strbuf *buf)
|
|||
if (!str_classtype)
|
||||
{
|
||||
ERR ("Unknown class type for class %s !", classname);
|
||||
free(classname);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,9 +62,8 @@ _function_exists(const char* func_name, Eina_Strbuf *buffer)
|
|||
return EINA_TRUE;
|
||||
}
|
||||
}
|
||||
default:
|
||||
ptr++; /* so strstr doesn't fall again on func_name */
|
||||
}
|
||||
ptr++; /* so strstr doesn't fall again on func_name */
|
||||
}
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
@ -87,9 +86,8 @@ _type_exists(const char* type_name, Eina_Strbuf *buffer)
|
|||
return EINA_TRUE;
|
||||
}
|
||||
}
|
||||
default:
|
||||
ptr++; /* so strstr doesn't fall again on type_name */
|
||||
}
|
||||
ptr++; /* so strstr doesn't fall again on type_name */
|
||||
}
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
|
|
@ -310,7 +310,7 @@ _eapi_func_generate(const Eolian_Class class, Eolian_Function funcid, Eolian_Fun
|
|||
if (rettype && (!ret_is_void))
|
||||
{
|
||||
char tmp_ret_str[0xFF];
|
||||
sprintf (tmp_ret_str, "%s%s", ret_const?"const ":"", rettype?rettype:"void");
|
||||
sprintf (tmp_ret_str, "%s%s", ret_const?"const ":"", rettype);
|
||||
const char *dflt_ret_val =
|
||||
eolian_function_return_dflt_value_get(funcid, ftype);
|
||||
Eina_Bool had_star = !!strchr(rettype, '*');
|
||||
|
|
|
@ -131,17 +131,28 @@ _generate_impl_c_file(char *filename, const Eolian_Class class)
|
|||
{
|
||||
fseek(fd, 0, SEEK_END);
|
||||
file_size = ftell(fd);
|
||||
fseek(fd, 0, SEEK_SET);
|
||||
char *content = malloc(file_size + 1);
|
||||
fread(content, file_size, 1, fd);
|
||||
content[file_size] = '\0';
|
||||
fclose(fd);
|
||||
|
||||
if (!content)
|
||||
if (file_size <= 0)
|
||||
{
|
||||
ERR("Couldnt read file %s", filename);
|
||||
ERR("Couldnt determine length for file %s", filename);
|
||||
goto end;
|
||||
}
|
||||
fseek(fd, 0, SEEK_SET);
|
||||
char *content = malloc(file_size + 1);
|
||||
if (!content)
|
||||
{
|
||||
ERR("Couldnt allocate memory for file %s", filename);
|
||||
goto end;
|
||||
}
|
||||
if (0 == fread(content, file_size, 1, fd))
|
||||
{
|
||||
ERR("Couldnt read the %ld bytes of file %s", file_size, filename);
|
||||
free(content);
|
||||
goto end;
|
||||
}
|
||||
|
||||
content[file_size] = '\0';
|
||||
fclose(fd);
|
||||
fd = NULL;
|
||||
|
||||
buffer = eina_strbuf_manage_new(content);
|
||||
}
|
||||
|
@ -164,10 +175,9 @@ _generate_impl_c_file(char *filename, const Eolian_Class class)
|
|||
const char *text = eina_strbuf_string_get(buffer);
|
||||
if (text) fputs(text, fd);
|
||||
|
||||
fclose(fd);
|
||||
|
||||
ret = EINA_TRUE;
|
||||
end:
|
||||
if (fd) fclose(fd);
|
||||
eina_strbuf_free(buffer);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -223,7 +223,7 @@ eolian_type_find_by_alias(const char *alias)
|
|||
Eina_Stringshare *shr = eina_stringshare_add(alias);
|
||||
Type_Desc *cl = eina_hash_find(_types, shr);
|
||||
eina_stringshare_del(shr);
|
||||
return cl->type;
|
||||
return cl?cl->type:NULL;
|
||||
}
|
||||
|
||||
Eolian_Class
|
||||
|
|
Loading…
Reference in New Issue