From ddbabaa3b659bed9dcf5c5a2bfc430fb816277c7 Mon Sep 17 00:00:00 2001 From: RincewindsHat <12514511+RincewindsHat@users.noreply.github.com> Date: Sun, 15 Oct 2023 18:21:31 +0200 Subject: Replace all old school booleans in lib witch C99 ones --- lib/utils_disk.c | 43 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) (limited to 'lib/utils_disk.c') diff --git a/lib/utils_disk.c b/lib/utils_disk.c index 5e95aef6..483be06d 100644 --- a/lib/utils_disk.c +++ b/lib/utils_disk.c @@ -170,9 +170,7 @@ np_find_parameter(struct parameter_list *list, const char *name) return NULL; } -void -np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list, int exact) -{ +void np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list, bool exact) { struct parameter_list *d; for (d = desired; d; d= d->name_next) { if (! d->best_match) { @@ -195,9 +193,9 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list if (! best_match) { for (me = mount_list; me; me = me->me_next) { size_t len = strlen (me->me_mountdir); - if ((exact == FALSE && (best_match_len <= len && len <= name_len && + if ((!exact && (best_match_len <= len && len <= name_len && (len == 1 || strncmp (me->me_mountdir, d->name, len) == 0))) - || (exact == TRUE && strcmp(me->me_mountdir, d->name)==0)) + || (exact && strcmp(me->me_mountdir, d->name)==0)) { if (get_fs_usage(me->me_mountdir, me->me_devname, &fsp) >= 0) { best_match = me; @@ -216,27 +214,23 @@ np_set_best_match(struct parameter_list *desired, struct mount_entry *mount_list } } -/* Returns TRUE if name is in list */ -int -np_find_name (struct name_list *list, const char *name) -{ +/* Returns true if name is in list */ +bool np_find_name (struct name_list *list, const char *name) { const struct name_list *n; if (list == NULL || name == NULL) { - return FALSE; + return false; } for (n = list; n; n = n->next) { if (!strcmp(name, n->name)) { - return TRUE; + return true; } } - return FALSE; + return false; } -/* Returns TRUE if name is in list */ -bool -np_find_regmatch (struct regex_list *list, const char *name) -{ +/* Returns true if name is in list */ +bool np_find_regmatch (struct regex_list *list, const char *name) { int len; regmatch_t m; @@ -257,25 +251,20 @@ np_find_regmatch (struct regex_list *list, const char *name) return false; } -int -np_seen_name(struct name_list *list, const char *name) -{ +bool np_seen_name(struct name_list *list, const char *name) { const struct name_list *s; for (s = list; s; s=s->next) { if (!strcmp(s->name, name)) { - return TRUE; + return true; } } - return FALSE; + return false; } -int -np_regex_match_mount_entry (struct mount_entry* me, regex_t* re) -{ +bool np_regex_match_mount_entry (struct mount_entry* me, regex_t* re) { if (regexec(re, me->me_devname, (size_t) 0, NULL, 0) == 0 || regexec(re, me->me_mountdir, (size_t) 0, NULL, 0) == 0 ) { - return TRUE; - } else { - return FALSE; + return true; } + return false; } -- cgit v1.2.3-74-g34f1