efreet: Add parameter checking to exported API

Some efreet APIs do not check input parameters.  So I add checking by
using EINA_SAFETY_ON_XXX().
ISO/IEC statndards says that "If an argument to a function has an
invalid value, behavior is undefined" . But this is  just for the
primitive functions such as libc.  I think that parameter checking is
needed in at least EFL exported APIs to prevent run-time abnormal
behavior.
EINA_SAFTETY_ON_XXX are better than "if (xxx) return" because it gives
error message and can be maintainable.

Patch by Bluezery, modified by me

SVN revision: 71366
devs/devilhorns/wayland_egl
Sebastian Dransfeld 11 years ago
parent 44ba936c9c
commit f419175657
  1. 2
      legacy/efreet/src/lib/efreet.c
  2. 2
      legacy/efreet/src/lib/efreet_cache.c
  3. 47
      legacy/efreet/src/lib/efreet_desktop.c
  4. 13
      legacy/efreet/src/lib/efreet_desktop_command.c
  5. 8
      legacy/efreet/src/lib/efreet_icon.c
  6. 58
      legacy/efreet/src/lib/efreet_ini.c
  7. 31
      legacy/efreet/src/lib/efreet_menu.c
  8. 16
      legacy/efreet/src/lib/efreet_mime.c
  9. 4
      legacy/efreet/src/lib/efreet_trash.c
  10. 8
      legacy/efreet/src/lib/efreet_uri.c
  11. 18
      legacy/efreet/src/lib/efreet_utils.c

@ -312,6 +312,8 @@ efreet_fsetowner(int fd)
EAPI void
efreet_setowner(const char *path)
{
EINA_SAFETY_ON_NULL_RETURN(path);
int fd;
fd = open(path, O_RDONLY);

@ -265,6 +265,8 @@ efreet_icon_cache_file(const char *theme)
static char cache_file[PATH_MAX] = { '\0' };
const char *cache;
EINA_SAFETY_ON_NULL_RETURN_VAL(theme, NULL);
cache = efreet_cache_home_get();
snprintf(cache_file, sizeof(cache_file), "%s/efreet/icons_%s_%s.eet", cache, theme, efreet_hostname_get());

@ -162,6 +162,8 @@ efreet_desktop_get(const char *file)
{
Efreet_Desktop *desktop;
EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
desktop = efreet_desktop_new(file);
if (!desktop) return NULL;
@ -187,7 +189,7 @@ efreet_desktop_get(const char *file)
EAPI int
efreet_desktop_ref(Efreet_Desktop *desktop)
{
if (!desktop) return 0;
EINA_SAFETY_ON_NULL_RETURN_VAL(desktop, 0);
desktop->ref++;
return desktop->ref;
}
@ -197,6 +199,8 @@ efreet_desktop_empty_new(const char *file)
{
Efreet_Desktop *desktop;
EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
desktop = NEW(Efreet_Desktop, 1);
if (!desktop) return NULL;
@ -213,7 +217,8 @@ efreet_desktop_new(const char *file)
{
Efreet_Desktop *desktop = NULL;
if (!file) return NULL;
EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
desktop = efreet_cache_desktop_find(file);
if (desktop)
{
@ -235,7 +240,8 @@ efreet_desktop_uncached_new(const char *file)
Efreet_Desktop *desktop = NULL;
char rp[PATH_MAX];
if (!file) return NULL;
EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
if (!realpath(file, rp)) return NULL;
if (!ecore_file_exists(rp)) return NULL;
@ -259,6 +265,8 @@ efreet_desktop_save(Efreet_Desktop *desktop)
Efreet_Ini *ini;
int ok = 1;
EINA_SAFETY_ON_NULL_RETURN_VAL(desktop, 0);
ini = efreet_ini_new(NULL);
if (!ini) return 0;
efreet_ini_section_add(ini, "Desktop Entry");
@ -309,6 +317,9 @@ efreet_desktop_save(Efreet_Desktop *desktop)
EAPI int
efreet_desktop_save_as(Efreet_Desktop *desktop, const char *file)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(desktop, 0);
EINA_SAFETY_ON_NULL_RETURN_VAL(file, 0);
/* If we save data from eet as new, we will be in trouble */
if (desktop->eet) return 0;
@ -381,14 +392,15 @@ efreet_desktop_environment_get(void)
EAPI unsigned int
efreet_desktop_category_count_get(Efreet_Desktop *desktop)
{
if (!desktop || !desktop->categories) return 0;
EINA_SAFETY_ON_NULL_RETURN_VAL(desktop, 0);
return eina_list_count(desktop->categories);
}
EAPI void
efreet_desktop_category_add(Efreet_Desktop *desktop, const char *category)
{
if (!desktop) return;
EINA_SAFETY_ON_NULL_RETURN(desktop);
EINA_SAFETY_ON_NULL_RETURN(category);
if (eina_list_search_unsorted(desktop->categories,
EINA_COMPARE_CB(strcmp), category)) return;
@ -402,7 +414,7 @@ efreet_desktop_category_del(Efreet_Desktop *desktop, const char *category)
{
char *found = NULL;
if (!desktop || !desktop->categories) return 0;
EINA_SAFETY_ON_NULL_RETURN_VAL(desktop, 0);
if ((found = eina_list_search_unsorted(desktop->categories,
EINA_COMPARE_CB(strcmp), category)))
@ -453,8 +465,8 @@ efreet_desktop_type_alias(int from_type, const char *alias)
EAPI Eina_Bool
efreet_desktop_x_field_set(Efreet_Desktop *desktop, const char *key, const char *data)
{
if (!desktop || strncmp(key, "X-", 2))
return EINA_FALSE;
EINA_SAFETY_ON_NULL_RETURN_VAL(desktop, EINA_FALSE);
EINA_SAFETY_ON_TRUE_RETURN_VAL(strncmp(key, "X-", 2), EINA_FALSE);
if (!desktop->x)
desktop->x = eina_hash_string_superfast_new(EINA_FREE_CB(eina_stringshare_del));
@ -470,11 +482,9 @@ efreet_desktop_x_field_get(Efreet_Desktop *desktop, const char *key)
{
const char *ret;
if (!desktop || strncmp(key, "X-", 2))
return NULL;
if (!desktop->x)
return NULL;
EINA_SAFETY_ON_NULL_RETURN_VAL(desktop, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(desktop->x, NULL);
EINA_SAFETY_ON_TRUE_RETURN_VAL(strncmp(key, "X-", 2), NULL);
ret = eina_hash_find(desktop->x, key);
if (!ret)
@ -486,11 +496,9 @@ efreet_desktop_x_field_get(Efreet_Desktop *desktop, const char *key)
EAPI Eina_Bool
efreet_desktop_x_field_del(Efreet_Desktop *desktop, const char *key)
{
if (!desktop || strncmp(key, "X-", 2))
return EINA_FALSE;
if (!desktop->x)
return EINA_FALSE;
EINA_SAFETY_ON_NULL_RETURN_VAL(desktop, EINA_FALSE);
EINA_SAFETY_ON_TRUE_RETURN_VAL(strncmp(key, "X-", 2), EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(desktop->x, EINA_FALSE);
return eina_hash_del_by_key(desktop->x, key);
}
@ -498,6 +506,7 @@ efreet_desktop_x_field_del(Efreet_Desktop *desktop, const char *key)
EAPI void *
efreet_desktop_type_data_get(Efreet_Desktop *desktop)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(desktop, NULL);
return desktop->type_data;
}
@ -509,7 +518,7 @@ efreet_desktop_string_list_parse(const char *string)
char *s, *p;
size_t len;
if (!string) return NULL;
EINA_SAFETY_ON_NULL_RETURN_VAL(string, NULL);
len = strlen(string) + 1;
tmp = alloca(len);

@ -152,7 +152,8 @@ efreet_desktop_command_local_get(Efreet_Desktop *desktop, Eina_List *files)
char *file;
Eina_List *execs, *l;
if (!desktop || !desktop->exec) return NULL;
EINA_SAFETY_ON_NULL_RETURN_VAL(desktop, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(desktop->exec, NULL);
command = NEW(Efreet_Desktop_Command, 1);
if (!command) return 0;
@ -195,7 +196,9 @@ efreet_desktop_command_progress_get(Efreet_Desktop *desktop, Eina_List *files,
char *file;
void *ret = NULL;
if (!desktop || !cb_command || !desktop->exec) return NULL;
EINA_SAFETY_ON_NULL_RETURN_VAL(desktop, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(desktop->exec, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(cb_command, NULL);
command = NEW(Efreet_Desktop_Command, 1);
if (!command) return NULL;
@ -283,7 +286,7 @@ efreet_desktop_command_flags_get(Efreet_Desktop *desktop)
p = strchr(p, '%');
}
#ifdef SLOPPY_SPEC
#ifdef SLOPPY_SPEC
/* NON-SPEC!!! this is to work around LOTS of 'broken' .desktop files that
* do not specify %U/%u, %F/F etc. etc. at all. just a command. this is
* unlikely to be fixed in distributions etc. in the long run as gnome/kde
@ -310,7 +313,7 @@ efreet_desktop_command_execs_process(Efreet_Desktop_Command *command, Eina_List
char *exec;
int num;
void *ret = NULL;
num = eina_list_count(execs);
EINA_LIST_FOREACH(execs, l, exec)
{
@ -429,7 +432,7 @@ efreet_desktop_command_build(Efreet_Desktop_Command *command)
p++;
}
#ifdef SLOPPY_SPEC
#ifdef SLOPPY_SPEC
/* NON-SPEC!!! this is to work around LOTS of 'broken' .desktop files that
* do not specify %U/%u, %F/F etc. etc. at all. just a command. this is
* unlikely to be fixed in distributions etc. in the long run as gnome/kde

@ -155,6 +155,8 @@ efreet_icon_extension_add(const char *ext)
{
Eina_List *l;
EINA_SAFETY_ON_NULL_RETURN(ext);
ext = eina_stringshare_add(ext);
if ((l = eina_list_data_find_list(efreet_icon_extensions, ext)))
@ -235,6 +237,8 @@ efreet_icon_path_find(const char *theme_name, const char *icon, unsigned int siz
const char *value = NULL;
Efreet_Icon_Theme *theme;
EINA_SAFETY_ON_NULL_RETURN_VAL(icon, NULL);
theme = efreet_icon_theme_find(theme_name);
#ifdef SLOPPY_SPEC
@ -281,6 +285,8 @@ efreet_icon_list_find(const char *theme_name, Eina_List *icons,
char *data;
Efreet_Icon_Theme *theme;
EINA_SAFETY_ON_NULL_RETURN_VAL(icons, NULL);
theme = efreet_icon_theme_find(theme_name);
#ifdef SLOPPY_SPEC
@ -350,6 +356,8 @@ efreet_icon_find(const char *theme_name, const char *icon, unsigned int size)
{
const char *path;
EINA_SAFETY_ON_NULL_RETURN_VAL(icon, NULL);
path = efreet_icon_path_find(theme_name, icon, size);
if (path)
{

@ -122,7 +122,7 @@ efreet_ini_parse(const char *file)
left = file_stat.st_size;
/* let's make mmap safe and just get 0 pages for IO erro */
eina_mmap_safety_enabled_set(EINA_TRUE);
buffer = mmap(NULL, left, PROT_READ, MAP_SHARED, fileno(f), 0);
if (buffer == MAP_FAILED)
{
@ -298,7 +298,10 @@ efreet_ini_save(Efreet_Ini *ini, const char *file)
{
char *dir;
FILE *f;
if (!ini || !ini->data) return 0;
EINA_SAFETY_ON_NULL_RETURN_VAL(ini, 0);
EINA_SAFETY_ON_NULL_RETURN_VAL(ini->data, 0);
EINA_SAFETY_ON_NULL_RETURN_VAL(file, 0);
dir = ecore_file_dir_get(file);
if (!ecore_file_mkpath(dir))
@ -318,7 +321,9 @@ efreet_ini_save(Efreet_Ini *ini, const char *file)
EAPI int
efreet_ini_section_set(Efreet_Ini *ini, const char *section)
{
if (!ini || !ini->data || !section) return 0;
EINA_SAFETY_ON_NULL_RETURN_VAL(ini, 0);
EINA_SAFETY_ON_NULL_RETURN_VAL(ini->data, 0);
EINA_SAFETY_ON_NULL_RETURN_VAL(section, 0);
ini->section = eina_hash_find(ini->data, section);
return (ini->section ? 1 : 0);
@ -329,7 +334,8 @@ efreet_ini_section_add(Efreet_Ini *ini, const char *section)
{
Eina_Hash *hash;
if (!ini || !section) return;
EINA_SAFETY_ON_NULL_RETURN(ini);
EINA_SAFETY_ON_NULL_RETURN(section);
if (!ini->data)
ini->data = eina_hash_string_small_new(EINA_FREE_CB(eina_hash_free));
@ -342,7 +348,9 @@ efreet_ini_section_add(Efreet_Ini *ini, const char *section)
EAPI const char *
efreet_ini_string_get(Efreet_Ini *ini, const char *key)
{
if (!ini || !key || !ini->section) return NULL;
EINA_SAFETY_ON_NULL_RETURN_VAL(ini, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(ini->section, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
return eina_hash_find(ini->section, key);
}
@ -350,7 +358,9 @@ efreet_ini_string_get(Efreet_Ini *ini, const char *key)
EAPI void
efreet_ini_string_set(Efreet_Ini *ini, const char *key, const char *value)
{
if (!ini || !key || !ini->section) return;
EINA_SAFETY_ON_NULL_RETURN(ini);
EINA_SAFETY_ON_NULL_RETURN(ini->section);
EINA_SAFETY_ON_NULL_RETURN(key);
eina_hash_del_by_key(ini->section, key);
eina_hash_add(ini->section, key, eina_stringshare_add(value));
@ -361,7 +371,9 @@ efreet_ini_int_get(Efreet_Ini *ini, const char *key)
{
const char *str;
if (!ini || !key || !ini->section) return -1;
EINA_SAFETY_ON_NULL_RETURN_VAL(ini, -1);
EINA_SAFETY_ON_NULL_RETURN_VAL(ini->section, -1);
EINA_SAFETY_ON_NULL_RETURN_VAL(key, -1);
str = efreet_ini_string_get(ini, key);
if (str) return atoi(str);
@ -374,7 +386,9 @@ efreet_ini_int_set(Efreet_Ini *ini, const char *key, int value)
{
char str[12];
if (!ini || !key || !ini->section) return;
EINA_SAFETY_ON_NULL_RETURN(ini);
EINA_SAFETY_ON_NULL_RETURN(ini->section);
EINA_SAFETY_ON_NULL_RETURN(key);
snprintf(str, 12, "%d", value);
efreet_ini_string_set(ini, key, str);
@ -385,7 +399,9 @@ efreet_ini_double_get(Efreet_Ini *ini, const char *key)
{
const char *str;
if (!ini || !key || !ini->section) return -1;
EINA_SAFETY_ON_NULL_RETURN_VAL(ini, -1);
EINA_SAFETY_ON_NULL_RETURN_VAL(ini->section, -1);
EINA_SAFETY_ON_NULL_RETURN_VAL(key, -1);
str = efreet_ini_string_get(ini, key);
if (str) return atof(str);
@ -399,7 +415,9 @@ efreet_ini_double_set(Efreet_Ini *ini, const char *key, double value)
char str[512];
size_t len;
if (!ini || !key || !ini->section) return;
EINA_SAFETY_ON_NULL_RETURN(ini);
EINA_SAFETY_ON_NULL_RETURN(ini->section);
EINA_SAFETY_ON_NULL_RETURN(key);
snprintf(str, 512, "%.6f", value);
len = strlen(str) - 1;
@ -413,7 +431,9 @@ efreet_ini_boolean_get(Efreet_Ini *ini, const char *key)
{
const char *str;
if (!ini || !key || !ini->section) return 0;
EINA_SAFETY_ON_NULL_RETURN_VAL(ini, 0);
EINA_SAFETY_ON_NULL_RETURN_VAL(ini->section, 0);
EINA_SAFETY_ON_NULL_RETURN_VAL(key, 0);
str = efreet_ini_string_get(ini, key);
if (str && !strcmp("true", str)) return 1;
@ -424,7 +444,9 @@ efreet_ini_boolean_get(Efreet_Ini *ini, const char *key)
EAPI void
efreet_ini_boolean_set(Efreet_Ini *ini, const char *key, unsigned int value)
{
if (!ini || !key || !ini->section) return;
EINA_SAFETY_ON_NULL_RETURN(ini);
EINA_SAFETY_ON_NULL_RETURN(ini->section);
EINA_SAFETY_ON_NULL_RETURN(key);
if (value) efreet_ini_string_set(ini, key, "true");
else efreet_ini_string_set(ini, key, "false");
@ -439,7 +461,9 @@ efreet_ini_localestring_get(Efreet_Ini *ini, const char *key)
int maxlen = 5; /* _, @, [, ] and \0 */
int found = 0;
if (!ini || !key || !ini->section) return NULL;
EINA_SAFETY_ON_NULL_RETURN_VAL(ini, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(ini->section, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
lang = efreet_lang_get();
country = efreet_lang_country_get();
@ -493,7 +517,9 @@ efreet_ini_localestring_set(Efreet_Ini *ini, const char *key, const char *value)
char *buf;
int maxlen = 5; /* _, @, [, ] and \0 */
if (!ini || !key || !ini->section) return;
EINA_SAFETY_ON_NULL_RETURN(ini);
EINA_SAFETY_ON_NULL_RETURN(ini->section);
EINA_SAFETY_ON_NULL_RETURN(key);
lang = efreet_lang_get();
country = efreet_lang_country_get();
@ -523,7 +549,9 @@ efreet_ini_localestring_set(Efreet_Ini *ini, const char *key, const char *value)
EAPI void
efreet_ini_key_unset(Efreet_Ini *ini, const char *key)
{
if (!ini || !key || !ini->section) return;
EINA_SAFETY_ON_NULL_RETURN(ini);
EINA_SAFETY_ON_NULL_RETURN(ini->section);
EINA_SAFETY_ON_NULL_RETURN(key);
eina_hash_del_by_key(ini->section, key);
}

@ -523,11 +523,8 @@ efreet_menu_new(const char *name)
{
Efreet_Menu *menu;
if (!name)
{
ERR("Efreet_menu: Error creating a new menu, name is missing");
return NULL;
}
EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
menu = efreet_menu_entry_new();
menu->type = EFREET_MENU_ENTRY_MENU;
menu->name = eina_stringshare_add(name);
@ -584,6 +581,8 @@ efreet_menu_parse(const char *path)
Efreet_Menu_Internal *internal = NULL;
Efreet_Menu *entry = NULL;
EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
xml = efreet_xml_new(path);
if (!xml) return NULL;
@ -655,6 +654,9 @@ efreet_menu_save(Efreet_Menu *menu, const char *path)
FILE *f;
int ret;
EINA_SAFETY_ON_NULL_RETURN_VAL(menu, 0);
EINA_SAFETY_ON_NULL_RETURN_VAL(path, 0);
f = fopen(path, "w");
if (!f) return 0;
fprintf(f, "<?xml version=\"1.0\"?>\n");
@ -769,7 +771,9 @@ efreet_menu_desktop_insert(Efreet_Menu *menu, Efreet_Desktop *desktop, int pos)
Efreet_Menu *entry;
const char *id;
if (!desktop || !menu) return 0;
EINA_SAFETY_ON_NULL_RETURN_VAL(menu, 0);
EINA_SAFETY_ON_NULL_RETURN_VAL(desktop, 0);
id = efreet_util_path_to_file_id(desktop->orig_path);
if (!id) return 0;
@ -796,7 +800,8 @@ efreet_menu_desktop_remove(Efreet_Menu *menu, Efreet_Desktop *desktop)
{
Efreet_Menu *entry;
if (!desktop || !menu) return 0;
EINA_SAFETY_ON_NULL_RETURN_VAL(menu, 0);
EINA_SAFETY_ON_NULL_RETURN_VAL(desktop, 0);
entry = eina_list_search_unsorted(menu->entries,
EINA_COMPARE_CB(efreet_menu_cb_entry_compare_desktop),
@ -815,6 +820,9 @@ efreet_menu_dump(Efreet_Menu *menu, const char *indent)
{
Eina_List *l;
EINA_SAFETY_ON_NULL_RETURN(menu);
EINA_SAFETY_ON_NULL_RETURN(indent);
INF("%s%s: ", indent, menu->name);
INF("%s", (menu->icon ? menu->icon : "No icon"));
@ -864,6 +872,9 @@ efreet_default_dirs_get(const char *user_dir, Eina_List *system_dirs,
Eina_List *list = NULL;
Eina_List *l;
EINA_SAFETY_ON_NULL_RETURN_VAL(user_dir, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(suffix, NULL);
snprintf(dir, sizeof(dir), "%s/%s", user_dir, suffix);
list = eina_list_append(list, eina_stringshare_add(dir));
@ -1540,7 +1551,7 @@ efreet_menu_merge(Efreet_Menu_Internal *parent, Efreet_Xml *xml, const char *pat
}
/* don't merge the same path twice */
if (eina_hash_find(efreet_merged_menus, rp))
if (eina_hash_find(efreet_merged_menus, rp))
{
return 1;
}
@ -2459,6 +2470,8 @@ efreet_menu_free(Efreet_Menu *entry)
{
Efreet_Menu *sub;
if (!entry) return;
IF_RELEASE(entry->name);
IF_RELEASE(entry->icon);
EINA_LIST_FREE(entry->entries, sub)
@ -2815,7 +2828,7 @@ efreet_menu_filter_not_matches(Efreet_Menu_Filter_Op *op, Efreet_Menu_Desktop *m
if ((eina_list_count(op->categories) > 0) && !md->desktop->categories)
return 1;
EINA_LIST_FOREACH(op->categories, l, t)
EINA_LIST_FOREACH(op->categories, l, t)
{
if (eina_list_search_unsorted(md->desktop->categories,
EINA_COMPARE_CB(strcmp), t))

@ -272,8 +272,7 @@ efreet_mime_type_get(const char *file)
{
const char *type = NULL;
if (!file)
return NULL;
EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
if ((type = efreet_mime_special_check(file)))
return type;
@ -304,8 +303,8 @@ efreet_mime_type_icon_get(const char *mime, const char *theme, unsigned int size
char buf[PATH_MAX];
const char *cache;
if (!mime || !theme || !size)
return NULL;
EINA_SAFETY_ON_NULL_RETURN_VAL(mime, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(theme, NULL);
mime = eina_stringshare_add(mime);
theme = eina_stringshare_add(theme);
@ -393,6 +392,7 @@ efreet_mime_type_cache_flush(void)
EAPI const char *
efreet_mime_magic_type_get(const char *file)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
return efreet_mime_magic_check_priority(file, 0, 0);
}
@ -405,9 +405,9 @@ efreet_mime_globs_type_get(const char *file)
const char *s;
char *ext, *mime;
/* Check in the extension hash for the type */
if (!file) return NULL;
EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
/* Check in the extension hash for the type */
ext = strchr(file, '.');
if (ext)
{
@ -444,12 +444,14 @@ efreet_mime_globs_type_get(const char *file)
EAPI const char *
efreet_mime_special_type_get(const char *file)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
return efreet_mime_special_check(file);
}
EAPI const char *
efreet_mime_fallback_type_get(const char *file)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(file, NULL);
return efreet_mime_fallback_check(file);
}
@ -1015,7 +1017,7 @@ efreet_mime_shared_mimeinfo_magic_load(const char *file)
/* let's make mmap safe and just get 0 pages for IO erro */
eina_mmap_safety_enabled_set(EINA_TRUE);
data = mmap(NULL, size, PROT_READ, MAP_SHARED, fd, 0);
if (data == MAP_FAILED)
{

@ -163,7 +163,9 @@ efreet_trash_delete_uri(Efreet_Uri *uri, int force_delete)
time_t now;
FILE *f;
if (!uri || !uri->path || !ecore_file_can_write(uri->path)) return 0;
EINA_SAFETY_ON_NULL_RETURN_VAL(uri, 0);
EINA_SAFETY_ON_NULL_RETURN_VAL(uri->path, 0);
EINA_SAFETY_ON_FALSE_RETURN_VAL(ecore_file_can_write(uri->path), 0);
fname = ecore_file_file_get(uri->path);

@ -27,6 +27,8 @@ efreet_uri_decode(const char *full_uri)
char protocol[64], hostname[_POSIX_HOST_NAME_MAX], path[PATH_MAX];
int i = 0;
EINA_SAFETY_ON_NULL_RETURN_VAL(full_uri, NULL);
/* An uri should be in the form <protocol>://<hostname>/<path> */
if (!strstr(full_uri, "://")) return NULL;
@ -83,7 +85,10 @@ efreet_uri_encode(Efreet_Uri *uri)
const char *p;
int i;
if (!uri || !uri->path || !uri->protocol) return NULL;
EINA_SAFETY_ON_NULL_RETURN_VAL(uri, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(uri->path, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(uri->protocol, NULL);
memset(dest, 0, PATH_MAX * 3 + 4);
snprintf(dest, strlen(uri->protocol) + 4, "%s://", uri->protocol);
@ -106,6 +111,7 @@ EAPI void
efreet_uri_free(Efreet_Uri *uri)
{
if (!uri) return;
IF_RELEASE(uri->protocol);
IF_RELEASE(uri->path);
IF_RELEASE(uri->hostname);

@ -105,7 +105,8 @@ efreet_util_path_to_file_id(const char *path)
char *base;
const char *file_id;
if (!path) return NULL;
EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
file_id = eina_hash_find(file_id_by_desktop_path, path);
if (file_id) return file_id;
@ -142,12 +143,14 @@ efreet_util_path_to_file_id(const char *path)
EAPI Eina_List *
efreet_util_desktop_mime_list(const char *mime)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(mime, NULL);
return efreet_util_cache_list("mime_types", mime);
}
EAPI Efreet_Desktop *
efreet_util_desktop_wm_class_find(const char *wmname, const char *wmclass)
{
EINA_SAFETY_ON_TRUE_RETURN_VAL((!wmname) && (!wmclass), NULL);
return efreet_util_cache_find("startup_wm_class", wmname, wmclass);
}
@ -158,7 +161,7 @@ efreet_util_desktop_file_id_find(const char *file_id)
Efreet_Desktop *ret = NULL;
const char *str;
if (!file_id) return NULL;
EINA_SAFETY_ON_NULL_RETURN_VAL(file_id, NULL);
hash = efreet_cache_util_hash_string("file_id");
if (!hash) return NULL;
@ -176,7 +179,7 @@ efreet_util_desktop_exec_find(const char *exec)
Efreet_Cache_Array_String *names = NULL;
unsigned int i;
if (!exec) return NULL;
EINA_SAFETY_ON_NULL_RETURN_VAL(exec, NULL);
names = efreet_cache_util_names("exec_list");
if (!names) return NULL;
@ -216,18 +219,21 @@ efreet_util_desktop_exec_find(const char *exec)
EAPI Efreet_Desktop *
efreet_util_desktop_name_find(const char *name)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(name, NULL);
return efreet_util_cache_find("name", name, NULL);
}
EAPI Efreet_Desktop *
efreet_util_desktop_generic_name_find(const char *generic_name)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(generic_name, NULL);
return efreet_util_cache_find("generic_name", generic_name, NULL);
}
EAPI Eina_List *
efreet_util_desktop_name_glob_list(const char *glob)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(glob, NULL);
return efreet_util_cache_glob_list("name", glob);
}
@ -239,7 +245,8 @@ efreet_util_desktop_exec_glob_list(const char *glob)
Efreet_Cache_Array_String *names = NULL;
unsigned int i;
if (!glob) return NULL;
EINA_SAFETY_ON_NULL_RETURN_VAL(glob, NULL);
if (!strcmp(glob, "*"))
glob = NULL;
@ -280,12 +287,14 @@ efreet_util_desktop_exec_glob_list(const char *glob)
EAPI Eina_List *
efreet_util_desktop_generic_name_glob_list(const char *glob)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(glob, NULL);
return efreet_util_cache_glob_list("generic_name", glob);
}
EAPI Eina_List *
efreet_util_desktop_comment_glob_list(const char *glob)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(glob, NULL);
return efreet_util_cache_glob_list("comment", glob);
}
@ -306,6 +315,7 @@ efreet_util_desktop_categories_list(void)
EAPI Eina_List *
efreet_util_desktop_category_list(const char *category)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(category, NULL);
return efreet_util_cache_list("categories", category);
}

Loading…
Cancel
Save