if (0 == sub_len) {
*out_list = NULL;
+ free(sub_query);
WARN("no numbers, emails, names for query");
return CONTACTS_ERROR_NO_DATA;
}
if (0 == sub_len) {
*out_list = NULL;
+ free(sub_query);
WARN("no person_id for aggregation suggestions");
return CONTACTS_ERROR_NO_DATA;
}
_print_errors,
};
-bool test_main_is_selected(int argc, char **argv, int depth, const func _func[])
+bool test_main_is_selected(int argc, char **argv, int depth, const func test_func[], int count)
{
if (argc <= depth) {
return false;
}
int select = atoi(argv[depth]);
- _func[select](argc, argv);
+
+ if (0 <= select && select < count)
+ test_func[select](argc, argv);
+ else
+ ERR("no test func (%d)", select);
return true;
}
ENTER();
DBG("argc(%d)", argc);
- if (true == test_main_is_selected(argc, argv, 1, _func))
+
+ int count = sizeof(_func) / sizeof(func);
+ if (true == test_main_is_selected(argc, argv, 1, _func, count))
return 0;
int i = 0;
- int count = sizeof(_func) / sizeof(func);
for (i = 0; i < count; i++) {
if (_func[i](argc, argv) < 0)
break;
#define __TEST_MAIN_H__
typedef int (*func)(int argc, char **argv);
-bool test_main_is_selected(int argc, char **argv, int step, const func _func[]);
+bool test_main_is_selected(int argc, char **argv, int step, const func test_func[], int count);
#endif /* __TEST_MAIN_H__ */
{
ENTER();
- if (true == test_main_is_selected(argc, argv, 2, _func))
+ int count = sizeof(_func) / sizeof(func);
+ if (true == test_main_is_selected(argc, argv, 2, _func, count))
return 0;
int i = 0;
- int count = sizeof(_func) / sizeof(func);
for (i = 0; i < count; i++) {
if (_func[i](argc, argv) < 0)
break;