{
ConfNode *child;
+ if (node == NULL || name == NULL) {
+ return NULL;
+ }
+
TAILQ_FOREACH(child, &node->head, next) {
- if (strcmp(child->name, name) == 0)
+ if (child->name != NULL && strcmp(child->name, name) == 0)
return child;
}
static int ConfNodeLookupChildTest(void)
{
+ int retval = 0;
char *test_vals[] = { "one", "two", "three" };
size_t u;
child = ConfNodeLookupChild(parent, "one");
if (child == NULL)
- return 0;
+ goto end;
if (strcmp(child->name, "one") != 0)
- return 0;
+ goto end;
if (strcmp(child->val, "one") != 0)
- return 0;
+ goto end;
child = ConfNodeLookupChild(parent, "two");
if (child == NULL)
- return 0;
+ goto end;
if (strcmp(child->name, "two") != 0)
- return 0;
+ goto end;
if (strcmp(child->val, "two") != 0)
- return 0;
+ goto end;
child = ConfNodeLookupChild(parent, "three");
if (child == NULL)
- return 0;
+ goto end;
if (strcmp(child->name, "three") != 0)
- return 0;
+ goto end;
if (strcmp(child->val, "three") != 0)
- return 0;
+ goto end;
child = ConfNodeLookupChild(parent, "four");
if (child != NULL)
- return 0;
+ goto end;
- ConfNodeFree(parent);
+ if (ConfNodeLookupChild(NULL, NULL) != NULL) {
+ goto end;
+ }
- return 1;
+ retval = 1;
+
+end:
+ if (parent != NULL) {
+ ConfNodeFree(parent);
+ }
+
+ return retval;
}
static int ConfNodeLookupChildValueTest(void)