eio functions no longer crash when passed NULL and throw errors accordingly

SVN revision: 81668
This commit is contained in:
Mike Blumenkrantz 2012-12-24 09:44:21 +00:00
parent b2de05f49a
commit 300ee59f38
6 changed files with 63 additions and 28 deletions

View File

@ -2,6 +2,7 @@
* eina_magic_fail() now throws error messages on NULL pointers instead of critical * eina_magic_fail() now throws error messages on NULL pointers instead of critical
* all efl object-freeing functions now take NULL without crashing or erroring * all efl object-freeing functions now take NULL without crashing or erroring
* eio functions no longer crash when passed NULL and throw errors accordingly
2012-12-19 Gustavo Sverzut Barbieri (k-s) 2012-12-19 Gustavo Sverzut Barbieri (k-s)

1
NEWS
View File

@ -88,3 +88,4 @@ Fixes:
* Fix many memory problems with ecore_evas_extn. * Fix many memory problems with ecore_evas_extn.
* Fix Evas RGBA_Image->flags.loaded for copied images. * Fix Evas RGBA_Image->flags.loaded for copied images.
* Fix evas_object_image_is_inside() * Fix evas_object_image_is_inside()
* eio functions no longer crash when passed NULL and throw errors accordingly

View File

@ -870,6 +870,8 @@ eio_file_associate_add(Eio_File *ls,
const char *key, const char *key,
const void *data, Eina_Free_Cb free_cb) const void *data, Eina_Free_Cb free_cb)
{ {
EINA_SAFETY_ON_NULL_RETURN_VAL(ls, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
/* FIXME: Check if we are in the right worker thred */ /* FIXME: Check if we are in the right worker thred */
if (!ls->worker.associated) if (!ls->worker.associated)
ls->worker.associated = eina_hash_string_small_new(eio_associate_free); ls->worker.associated = eina_hash_string_small_new(eio_associate_free);
@ -884,6 +886,8 @@ eio_file_associate_direct_add(Eio_File *ls,
const char *key, const char *key,
const void *data, Eina_Free_Cb free_cb) const void *data, Eina_Free_Cb free_cb)
{ {
EINA_SAFETY_ON_NULL_RETURN_VAL(ls, EINA_FALSE);
EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
/* FIXME: Check if we are in the right worker thred */ /* FIXME: Check if we are in the right worker thred */
if (!ls->worker.associated) if (!ls->worker.associated)
ls->worker.associated = eina_hash_string_small_new(eio_associate_free); ls->worker.associated = eina_hash_string_small_new(eio_associate_free);
@ -898,6 +902,8 @@ eio_file_associate_find(Eio_File *ls, const char *key)
{ {
Eio_File_Associate *search; Eio_File_Associate *search;
EINA_SAFETY_ON_NULL_RETURN_VAL(ls, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
if (!ls->main.associated) if (!ls->main.associated)
return NULL; return NULL;

View File

@ -266,6 +266,7 @@ eio_monitor_add(const char *path)
const char *tmp; const char *tmp;
Eio_Monitor *ret; Eio_Monitor *ret;
EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
tmp = eina_stringshare_add(path); tmp = eina_stringshare_add(path);
ret = eio_monitor_stringshared_add(tmp); ret = eio_monitor_stringshared_add(tmp);
eina_stringshare_del(tmp); eina_stringshare_del(tmp);
@ -278,6 +279,7 @@ eio_monitor_stringshared_add(const char *path)
Eio_Monitor *monitor; Eio_Monitor *monitor;
struct stat st; struct stat st;
EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
if (_monitor_pid == -1) return NULL; if (_monitor_pid == -1) return NULL;
if (_monitor_pid != getpid()) if (_monitor_pid != getpid())

View File

@ -417,8 +417,9 @@ eio_file_direct_stat(const char *path,
{ {
Eio_File_Stat *s = NULL; Eio_File_Stat *s = NULL;
if (!path || !done_cb || !error_cb) EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
return NULL; EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
s = malloc(sizeof (Eio_File_Stat)); s = malloc(sizeof (Eio_File_Stat));
if (!s) return NULL; if (!s) return NULL;
@ -449,8 +450,9 @@ eio_file_direct_lstat(const char *path,
#ifdef HAVE_LSTAT #ifdef HAVE_LSTAT
Eio_File_Stat *s = NULL; Eio_File_Stat *s = NULL;
if (!path || !done_cb || !error_cb) EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
return NULL; EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
s = malloc(sizeof (Eio_File_Stat)); s = malloc(sizeof (Eio_File_Stat));
if (!s) return NULL; if (!s) return NULL;
@ -481,8 +483,9 @@ eio_file_unlink(const char *path,
{ {
Eio_File_Unlink *l = NULL; Eio_File_Unlink *l = NULL;
if (!path || !done_cb || !error_cb) EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
return NULL; EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
l = malloc(sizeof (Eio_File_Unlink)); l = malloc(sizeof (Eio_File_Unlink));
if (!l) return NULL; if (!l) return NULL;
@ -510,8 +513,9 @@ eio_file_mkdir(const char *path,
{ {
Eio_File_Mkdir *r = NULL; Eio_File_Mkdir *r = NULL;
if (!path || !done_cb || !error_cb) EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
return NULL; EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
r = malloc(sizeof (Eio_File_Mkdir)); r = malloc(sizeof (Eio_File_Mkdir));
if (!r) return NULL; if (!r) return NULL;
@ -540,8 +544,9 @@ eio_file_chmod(const char *path,
{ {
Eio_File_Mkdir *r = NULL; Eio_File_Mkdir *r = NULL;
if (!path || !done_cb || !error_cb) EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
return NULL; EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
r = malloc(sizeof (Eio_File_Mkdir)); r = malloc(sizeof (Eio_File_Mkdir));
if (!r) return NULL; if (!r) return NULL;
@ -571,8 +576,9 @@ eio_file_chown(const char *path,
{ {
Eio_File_Chown *c = NULL; Eio_File_Chown *c = NULL;
if (!path || !done_cb || !error_cb) EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
return NULL; EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
c = malloc(sizeof (Eio_File_Chown)); c = malloc(sizeof (Eio_File_Chown));
if (!c) return NULL; if (!c) return NULL;

View File

@ -320,8 +320,10 @@ eio_file_xattr_get(const char *path,
{ {
Eio_File_Xattr *async; Eio_File_Xattr *async;
if (!path || !attribute || !done_cb || !error_cb) EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
return NULL; EINA_SAFETY_ON_NULL_RETURN_VAL(attribute, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
async = malloc(sizeof (Eio_File_Xattr)); async = malloc(sizeof (Eio_File_Xattr));
if (!async) return NULL; if (!async) return NULL;
@ -341,8 +343,10 @@ eio_file_xattr_string_get(const char *path,
{ {
Eio_File_Xattr *async; Eio_File_Xattr *async;
if (!path || !attribute || !done_cb || !error_cb) EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
return NULL; EINA_SAFETY_ON_NULL_RETURN_VAL(attribute, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
async = malloc(sizeof (Eio_File_Xattr)); async = malloc(sizeof (Eio_File_Xattr));
if (!async) return NULL; if (!async) return NULL;
@ -362,8 +366,10 @@ eio_file_xattr_double_get(const char *path,
{ {
Eio_File_Xattr *async; Eio_File_Xattr *async;
if (!path || !attribute || !done_cb || !error_cb) EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
return NULL; EINA_SAFETY_ON_NULL_RETURN_VAL(attribute, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
async = malloc(sizeof (Eio_File_Xattr)); async = malloc(sizeof (Eio_File_Xattr));
if (!async) return NULL; if (!async) return NULL;
@ -383,8 +389,10 @@ eio_file_xattr_int_get(const char *path,
{ {
Eio_File_Xattr *async; Eio_File_Xattr *async;
if (!path || !attribute || !done_cb || !error_cb) EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
return NULL; EINA_SAFETY_ON_NULL_RETURN_VAL(attribute, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
async = malloc(sizeof (Eio_File_Xattr)); async = malloc(sizeof (Eio_File_Xattr));
if (!async) return NULL; if (!async) return NULL;
@ -407,8 +415,12 @@ eio_file_xattr_set(const char *path,
{ {
Eio_File_Xattr *async; Eio_File_Xattr *async;
if (!path || !attribute || !done_cb || !xattr_data || !xattr_size || !error_cb) EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
return NULL; EINA_SAFETY_ON_NULL_RETURN_VAL(attribute, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(xattr_data, NULL);
EINA_SAFETY_ON_FALSE_RETURN_VAL(xattr_size, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
async = malloc(sizeof (Eio_File_Xattr) + xattr_size); async = malloc(sizeof (Eio_File_Xattr) + xattr_size);
if (!async) return NULL; if (!async) return NULL;
@ -433,8 +445,11 @@ eio_file_xattr_string_set(const char *path,
Eio_File_Xattr *async; Eio_File_Xattr *async;
int length; int length;
if (!path || !attribute || !done_cb || !xattr_string || !error_cb) EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
return NULL; EINA_SAFETY_ON_NULL_RETURN_VAL(attribute, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(xattr_string, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
async = malloc(sizeof (Eio_File_Xattr)); async = malloc(sizeof (Eio_File_Xattr));
if (!async) return NULL; if (!async) return NULL;
@ -464,8 +479,10 @@ eio_file_xattr_double_set(const char *path,
{ {
Eio_File_Xattr *async; Eio_File_Xattr *async;
if (!path || !attribute || !done_cb || !error_cb) EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
return NULL; EINA_SAFETY_ON_NULL_RETURN_VAL(attribute, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
async = malloc(sizeof (Eio_File_Xattr)); async = malloc(sizeof (Eio_File_Xattr));
if (!async) return NULL; if (!async) return NULL;
@ -487,8 +504,10 @@ eio_file_xattr_int_set(const char *path,
{ {
Eio_File_Xattr *async; Eio_File_Xattr *async;
if (!path || !attribute || !done_cb || !error_cb) EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
return NULL; EINA_SAFETY_ON_NULL_RETURN_VAL(attribute, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
async = malloc(sizeof (Eio_File_Xattr)); async = malloc(sizeof (Eio_File_Xattr));
if (!async) return NULL; if (!async) return NULL;