summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2012-12-24 09:44:21 +0000
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>2012-12-24 09:44:21 +0000
commit300ee59f38c9649163cc3a05d58e9906decc3192 (patch)
tree767ef8e62cd3e7aff9a4edc1bbc3db4f437154c5 /src
parentb2de05f49a5b064952a224b22d1bb6a9093c4b3b (diff)
eio functions no longer crash when passed NULL and throw errors accordingly
SVN revision: 81668
Diffstat (limited to 'src')
-rw-r--r--src/lib/eio/eio_file.c6
-rw-r--r--src/lib/eio/eio_monitor.c2
-rw-r--r--src/lib/eio/eio_single.c30
-rw-r--r--src/lib/eio/eio_xattr.c51
4 files changed, 61 insertions, 28 deletions
diff --git a/src/lib/eio/eio_file.c b/src/lib/eio/eio_file.c
index 431d088e69..a7a8457deb 100644
--- a/src/lib/eio/eio_file.c
+++ b/src/lib/eio/eio_file.c
@@ -870,6 +870,8 @@ eio_file_associate_add(Eio_File *ls,
870 const char *key, 870 const char *key,
871 const void *data, Eina_Free_Cb free_cb) 871 const void *data, Eina_Free_Cb free_cb)
872{ 872{
873 EINA_SAFETY_ON_NULL_RETURN_VAL(ls, EINA_FALSE);
874 EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
873 /* FIXME: Check if we are in the right worker thred */ 875 /* FIXME: Check if we are in the right worker thred */
874 if (!ls->worker.associated) 876 if (!ls->worker.associated)
875 ls->worker.associated = eina_hash_string_small_new(eio_associate_free); 877 ls->worker.associated = eina_hash_string_small_new(eio_associate_free);
@@ -884,6 +886,8 @@ eio_file_associate_direct_add(Eio_File *ls,
884 const char *key, 886 const char *key,
885 const void *data, Eina_Free_Cb free_cb) 887 const void *data, Eina_Free_Cb free_cb)
886{ 888{
889 EINA_SAFETY_ON_NULL_RETURN_VAL(ls, EINA_FALSE);
890 EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE);
887 /* FIXME: Check if we are in the right worker thred */ 891 /* FIXME: Check if we are in the right worker thred */
888 if (!ls->worker.associated) 892 if (!ls->worker.associated)
889 ls->worker.associated = eina_hash_string_small_new(eio_associate_free); 893 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)
898{ 902{
899 Eio_File_Associate *search; 903 Eio_File_Associate *search;
900 904
905 EINA_SAFETY_ON_NULL_RETURN_VAL(ls, NULL);
906 EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL);
901 if (!ls->main.associated) 907 if (!ls->main.associated)
902 return NULL; 908 return NULL;
903 909
diff --git a/src/lib/eio/eio_monitor.c b/src/lib/eio/eio_monitor.c
index 36c8b1d8f2..3a6d9c91e2 100644
--- a/src/lib/eio/eio_monitor.c
+++ b/src/lib/eio/eio_monitor.c
@@ -266,6 +266,7 @@ eio_monitor_add(const char *path)
266 const char *tmp; 266 const char *tmp;
267 Eio_Monitor *ret; 267 Eio_Monitor *ret;
268 268
269 EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
269 tmp = eina_stringshare_add(path); 270 tmp = eina_stringshare_add(path);
270 ret = eio_monitor_stringshared_add(tmp); 271 ret = eio_monitor_stringshared_add(tmp);
271 eina_stringshare_del(tmp); 272 eina_stringshare_del(tmp);
@@ -278,6 +279,7 @@ eio_monitor_stringshared_add(const char *path)
278 Eio_Monitor *monitor; 279 Eio_Monitor *monitor;
279 struct stat st; 280 struct stat st;
280 281
282 EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
281 if (_monitor_pid == -1) return NULL; 283 if (_monitor_pid == -1) return NULL;
282 284
283 if (_monitor_pid != getpid()) 285 if (_monitor_pid != getpid())
diff --git a/src/lib/eio/eio_single.c b/src/lib/eio/eio_single.c
index d80dd840e6..179f8be2ea 100644
--- a/src/lib/eio/eio_single.c
+++ b/src/lib/eio/eio_single.c
@@ -417,8 +417,9 @@ eio_file_direct_stat(const char *path,
417{ 417{
418 Eio_File_Stat *s = NULL; 418 Eio_File_Stat *s = NULL;
419 419
420 if (!path || !done_cb || !error_cb) 420 EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
421 return NULL; 421 EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
422 EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
422 423
423 s = malloc(sizeof (Eio_File_Stat)); 424 s = malloc(sizeof (Eio_File_Stat));
424 if (!s) return NULL; 425 if (!s) return NULL;
@@ -449,8 +450,9 @@ eio_file_direct_lstat(const char *path,
449#ifdef HAVE_LSTAT 450#ifdef HAVE_LSTAT
450 Eio_File_Stat *s = NULL; 451 Eio_File_Stat *s = NULL;
451 452
452 if (!path || !done_cb || !error_cb) 453 EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
453 return NULL; 454 EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
455 EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
454 456
455 s = malloc(sizeof (Eio_File_Stat)); 457 s = malloc(sizeof (Eio_File_Stat));
456 if (!s) return NULL; 458 if (!s) return NULL;
@@ -481,8 +483,9 @@ eio_file_unlink(const char *path,
481{ 483{
482 Eio_File_Unlink *l = NULL; 484 Eio_File_Unlink *l = NULL;
483 485
484 if (!path || !done_cb || !error_cb) 486 EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
485 return NULL; 487 EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
488 EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
486 489
487 l = malloc(sizeof (Eio_File_Unlink)); 490 l = malloc(sizeof (Eio_File_Unlink));
488 if (!l) return NULL; 491 if (!l) return NULL;
@@ -510,8 +513,9 @@ eio_file_mkdir(const char *path,
510{ 513{
511 Eio_File_Mkdir *r = NULL; 514 Eio_File_Mkdir *r = NULL;
512 515
513 if (!path || !done_cb || !error_cb) 516 EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
514 return NULL; 517 EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
518 EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
515 519
516 r = malloc(sizeof (Eio_File_Mkdir)); 520 r = malloc(sizeof (Eio_File_Mkdir));
517 if (!r) return NULL; 521 if (!r) return NULL;
@@ -540,8 +544,9 @@ eio_file_chmod(const char *path,
540{ 544{
541 Eio_File_Mkdir *r = NULL; 545 Eio_File_Mkdir *r = NULL;
542 546
543 if (!path || !done_cb || !error_cb) 547 EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
544 return NULL; 548 EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
549 EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
545 550
546 r = malloc(sizeof (Eio_File_Mkdir)); 551 r = malloc(sizeof (Eio_File_Mkdir));
547 if (!r) return NULL; 552 if (!r) return NULL;
@@ -571,8 +576,9 @@ eio_file_chown(const char *path,
571{ 576{
572 Eio_File_Chown *c = NULL; 577 Eio_File_Chown *c = NULL;
573 578
574 if (!path || !done_cb || !error_cb) 579 EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
575 return NULL; 580 EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
581 EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
576 582
577 c = malloc(sizeof (Eio_File_Chown)); 583 c = malloc(sizeof (Eio_File_Chown));
578 if (!c) return NULL; 584 if (!c) return NULL;
diff --git a/src/lib/eio/eio_xattr.c b/src/lib/eio/eio_xattr.c
index b1105141b5..918b03cc31 100644
--- a/src/lib/eio/eio_xattr.c
+++ b/src/lib/eio/eio_xattr.c
@@ -320,8 +320,10 @@ eio_file_xattr_get(const char *path,
320{ 320{
321 Eio_File_Xattr *async; 321 Eio_File_Xattr *async;
322 322
323 if (!path || !attribute || !done_cb || !error_cb) 323 EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
324 return NULL; 324 EINA_SAFETY_ON_NULL_RETURN_VAL(attribute, NULL);
325 EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
326 EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
325 327
326 async = malloc(sizeof (Eio_File_Xattr)); 328 async = malloc(sizeof (Eio_File_Xattr));
327 if (!async) return NULL; 329 if (!async) return NULL;
@@ -341,8 +343,10 @@ eio_file_xattr_string_get(const char *path,
341{ 343{
342 Eio_File_Xattr *async; 344 Eio_File_Xattr *async;
343 345
344 if (!path || !attribute || !done_cb || !error_cb) 346 EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
345 return NULL; 347 EINA_SAFETY_ON_NULL_RETURN_VAL(attribute, NULL);
348 EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
349 EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
346 350
347 async = malloc(sizeof (Eio_File_Xattr)); 351 async = malloc(sizeof (Eio_File_Xattr));
348 if (!async) return NULL; 352 if (!async) return NULL;
@@ -362,8 +366,10 @@ eio_file_xattr_double_get(const char *path,
362{ 366{
363 Eio_File_Xattr *async; 367 Eio_File_Xattr *async;
364 368
365 if (!path || !attribute || !done_cb || !error_cb) 369 EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
366 return NULL; 370 EINA_SAFETY_ON_NULL_RETURN_VAL(attribute, NULL);
371 EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
372 EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
367 373
368 async = malloc(sizeof (Eio_File_Xattr)); 374 async = malloc(sizeof (Eio_File_Xattr));
369 if (!async) return NULL; 375 if (!async) return NULL;
@@ -383,8 +389,10 @@ eio_file_xattr_int_get(const char *path,
383{ 389{
384 Eio_File_Xattr *async; 390 Eio_File_Xattr *async;
385 391
386 if (!path || !attribute || !done_cb || !error_cb) 392 EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
387 return NULL; 393 EINA_SAFETY_ON_NULL_RETURN_VAL(attribute, NULL);
394 EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
395 EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
388 396
389 async = malloc(sizeof (Eio_File_Xattr)); 397 async = malloc(sizeof (Eio_File_Xattr));
390 if (!async) return NULL; 398 if (!async) return NULL;
@@ -407,8 +415,12 @@ eio_file_xattr_set(const char *path,
407{ 415{
408 Eio_File_Xattr *async; 416 Eio_File_Xattr *async;
409 417
410 if (!path || !attribute || !done_cb || !xattr_data || !xattr_size || !error_cb) 418 EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
411 return NULL; 419 EINA_SAFETY_ON_NULL_RETURN_VAL(attribute, NULL);
420 EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
421 EINA_SAFETY_ON_NULL_RETURN_VAL(xattr_data, NULL);
422 EINA_SAFETY_ON_FALSE_RETURN_VAL(xattr_size, NULL);
423 EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
412 424
413 async = malloc(sizeof (Eio_File_Xattr) + xattr_size); 425 async = malloc(sizeof (Eio_File_Xattr) + xattr_size);
414 if (!async) return NULL; 426 if (!async) return NULL;
@@ -433,8 +445,11 @@ eio_file_xattr_string_set(const char *path,
433 Eio_File_Xattr *async; 445 Eio_File_Xattr *async;
434 int length; 446 int length;
435 447
436 if (!path || !attribute || !done_cb || !xattr_string || !error_cb) 448 EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
437 return NULL; 449 EINA_SAFETY_ON_NULL_RETURN_VAL(attribute, NULL);
450 EINA_SAFETY_ON_NULL_RETURN_VAL(xattr_string, NULL);
451 EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
452 EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
438 453
439 async = malloc(sizeof (Eio_File_Xattr)); 454 async = malloc(sizeof (Eio_File_Xattr));
440 if (!async) return NULL; 455 if (!async) return NULL;
@@ -464,8 +479,10 @@ eio_file_xattr_double_set(const char *path,
464{ 479{
465 Eio_File_Xattr *async; 480 Eio_File_Xattr *async;
466 481
467 if (!path || !attribute || !done_cb || !error_cb) 482 EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
468 return NULL; 483 EINA_SAFETY_ON_NULL_RETURN_VAL(attribute, NULL);
484 EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
485 EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
469 486
470 async = malloc(sizeof (Eio_File_Xattr)); 487 async = malloc(sizeof (Eio_File_Xattr));
471 if (!async) return NULL; 488 if (!async) return NULL;
@@ -487,8 +504,10 @@ eio_file_xattr_int_set(const char *path,
487{ 504{
488 Eio_File_Xattr *async; 505 Eio_File_Xattr *async;
489 506
490 if (!path || !attribute || !done_cb || !error_cb) 507 EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
491 return NULL; 508 EINA_SAFETY_ON_NULL_RETURN_VAL(attribute, NULL);
509 EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);
510 EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);
492 511
493 async = malloc(sizeof (Eio_File_Xattr)); 512 async = malloc(sizeof (Eio_File_Xattr));
494 if (!async) return NULL; 513 if (!async) return NULL;