From 5c5994bd15c2982f6eec78d9b72dfe3b6a8e0438 Mon Sep 17 00:00:00 2001 From: ache Date: Mon, 27 Jan 2003 03:39:33 +0000 Subject: Now return NULLified struct in case of empty config file (previous variant return NULL pointer for both empty file case and error case, so caller can't sense error properly). It not affect existen programs because property_find() now returns NULL for both NULL pointer and NULLified struct. --- lib/libutil/property.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'lib/libutil') diff --git a/lib/libutil/property.c b/lib/libutil/property.c index 0a31879..34e6ee3 100644 --- a/lib/libutil/property.c +++ b/lib/libutil/property.c @@ -216,20 +216,23 @@ properties_read(int fd) break; } } + if (head == NULL && (head = property_alloc(NULL, NULL)) == NULL) + return (NULL); + return (head); } char * property_find(properties list, const char *name) { - if (!list || !name || !name[0]) - return NULL; - while (list) { - if (!strcmp(list->name, name)) - return list->value; + if (list == NULL || name == NULL || !name[0]) + return (NULL); + while (list != NULL) { + if (list->name != NULL && strcmp(list->name, name) == 0) + return (list->value); list = list->next; } - return NULL; + return (NULL); } void -- cgit v1.1