diff options
author | ache <ache@FreeBSD.org> | 2003-01-27 03:39:33 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 2003-01-27 03:39:33 +0000 |
commit | 5c5994bd15c2982f6eec78d9b72dfe3b6a8e0438 (patch) | |
tree | 4bed4faf934dfbf14110e7b7997083132aca15f9 /lib/libutil | |
parent | 779e19d00079797682b0f2839f0fcfc0506e4414 (diff) | |
download | FreeBSD-src-5c5994bd15c2982f6eec78d9b72dfe3b6a8e0438.zip FreeBSD-src-5c5994bd15c2982f6eec78d9b72dfe3b6a8e0438.tar.gz |
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.
Diffstat (limited to 'lib/libutil')
-rw-r--r-- | lib/libutil/property.c | 15 |
1 files changed, 9 insertions, 6 deletions
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 |