summaryrefslogtreecommitdiff
path: root/legacy/efreet/src/lib/efreet_desktop_command.c
diff options
context:
space:
mode:
authorSebastian Dransfeld <sd@tango.flipp.net>2012-05-23 20:10:27 +0000
committerSebastian Dransfeld <sd@tango.flipp.net>2012-05-23 20:10:27 +0000
commitf4191756571154d9c129765b48bf8d48cac20865 (patch)
tree08737aba1bb24e948de0ea62dbfe77855730ce54 /legacy/efreet/src/lib/efreet_desktop_command.c
parent44ba936c9c480e7090e802e3e549386b68d61a7b (diff)
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
Diffstat (limited to 'legacy/efreet/src/lib/efreet_desktop_command.c')
-rw-r--r--legacy/efreet/src/lib/efreet_desktop_command.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/legacy/efreet/src/lib/efreet_desktop_command.c b/legacy/efreet/src/lib/efreet_desktop_command.c
index 32f346d..1ff7059 100644
--- a/legacy/efreet/src/lib/efreet_desktop_command.c
+++ b/legacy/efreet/src/lib/efreet_desktop_command.c
@@ -152,7 +152,8 @@ efreet_desktop_command_local_get(Efreet_Desktop *desktop, Eina_List *files)
152 char *file; 152 char *file;
153 Eina_List *execs, *l; 153 Eina_List *execs, *l;
154 154
155 if (!desktop || !desktop->exec) return NULL; 155 EINA_SAFETY_ON_NULL_RETURN_VAL(desktop, NULL);
156 EINA_SAFETY_ON_NULL_RETURN_VAL(desktop->exec, NULL);
156 157
157 command = NEW(Efreet_Desktop_Command, 1); 158 command = NEW(Efreet_Desktop_Command, 1);
158 if (!command) return 0; 159 if (!command) return 0;
@@ -195,7 +196,9 @@ efreet_desktop_command_progress_get(Efreet_Desktop *desktop, Eina_List *files,
195 char *file; 196 char *file;
196 void *ret = NULL; 197 void *ret = NULL;
197 198
198 if (!desktop || !cb_command || !desktop->exec) return NULL; 199 EINA_SAFETY_ON_NULL_RETURN_VAL(desktop, NULL);
200 EINA_SAFETY_ON_NULL_RETURN_VAL(desktop->exec, NULL);
201 EINA_SAFETY_ON_NULL_RETURN_VAL(cb_command, NULL);
199 202
200 command = NEW(Efreet_Desktop_Command, 1); 203 command = NEW(Efreet_Desktop_Command, 1);
201 if (!command) return NULL; 204 if (!command) return NULL;
@@ -283,7 +286,7 @@ efreet_desktop_command_flags_get(Efreet_Desktop *desktop)
283 286
284 p = strchr(p, '%'); 287 p = strchr(p, '%');
285 } 288 }
286#ifdef SLOPPY_SPEC 289#ifdef SLOPPY_SPEC
287 /* NON-SPEC!!! this is to work around LOTS of 'broken' .desktop files that 290 /* NON-SPEC!!! this is to work around LOTS of 'broken' .desktop files that
288 * do not specify %U/%u, %F/F etc. etc. at all. just a command. this is 291 * do not specify %U/%u, %F/F etc. etc. at all. just a command. this is
289 * unlikely to be fixed in distributions etc. in the long run as gnome/kde 292 * 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
310 char *exec; 313 char *exec;
311 int num; 314 int num;
312 void *ret = NULL; 315 void *ret = NULL;
313 316
314 num = eina_list_count(execs); 317 num = eina_list_count(execs);
315 EINA_LIST_FOREACH(execs, l, exec) 318 EINA_LIST_FOREACH(execs, l, exec)
316 { 319 {
@@ -429,7 +432,7 @@ efreet_desktop_command_build(Efreet_Desktop_Command *command)
429 p++; 432 p++;
430 } 433 }
431 434
432#ifdef SLOPPY_SPEC 435#ifdef SLOPPY_SPEC
433 /* NON-SPEC!!! this is to work around LOTS of 'broken' .desktop files that 436 /* NON-SPEC!!! this is to work around LOTS of 'broken' .desktop files that
434 * do not specify %U/%u, %F/F etc. etc. at all. just a command. this is 437 * do not specify %U/%u, %F/F etc. etc. at all. just a command. this is
435 * unlikely to be fixed in distributions etc. in the long run as gnome/kde 438 * unlikely to be fixed in distributions etc. in the long run as gnome/kde