2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 06:15:37 +00:00

Add debug_decl/debug_return (almost) everywhere.

Remove old sudo_debug() and convert users to sudo_debug_printf().
This commit is contained in:
Todd C. Miller
2011-10-22 14:40:21 -04:00
parent 9923464d96
commit 839919566e
72 changed files with 1745 additions and 968 deletions

View File

@@ -62,6 +62,7 @@ alias_compare(const void *v1, const void *v2)
const struct alias *a1 = (const struct alias *)v1;
const struct alias *a2 = (const struct alias *)v2;
int res;
debug_decl(alias_compare, SUDO_DEBUG_ALIAS)
if (v1 == NULL)
res = -1;
@@ -69,7 +70,7 @@ alias_compare(const void *v1, const void *v2)
res = 1;
else if ((res = strcmp(a1->name, a2->name)) == 0)
res = a1->type - a2->type;
return res;
debug_return_int(res);
}
/*
@@ -82,6 +83,7 @@ alias_find(char *name, int type)
struct alias key;
struct rbnode *node;
struct alias *a = NULL;
debug_decl(alias_find, SUDO_DEBUG_ALIAS)
key.name = name;
key.type = type;
@@ -94,13 +96,13 @@ alias_find(char *name, int type)
a = node->data;
if (a->seqno == alias_seqno) {
errno = ELOOP;
return NULL;
debug_return_ptr(NULL);
}
a->seqno = alias_seqno;
} else {
errno = ENOENT;
}
return a;
debug_return_ptr(a);
}
/*
@@ -112,6 +114,7 @@ alias_add(char *name, int type, struct member *members)
{
static char errbuf[512];
struct alias *a;
debug_decl(alias_add, SUDO_DEBUG_ALIAS)
a = emalloc(sizeof(*a));
a->name = name;
@@ -121,9 +124,9 @@ alias_add(char *name, int type, struct member *members)
if (rbinsert(aliases, a)) {
snprintf(errbuf, sizeof(errbuf), _("Alias `%s' already defined"), name);
alias_free(a);
return errbuf;
debug_return_str(errbuf);
}
return NULL;
debug_return_str(NULL);
}
/*
@@ -132,7 +135,11 @@ alias_add(char *name, int type, struct member *members)
void
alias_apply(int (*func)(void *, void *), void *cookie)
{
debug_decl(alias_apply, SUDO_DEBUG_ALIAS)
rbapply(aliases, func, cookie, inorder);
debug_return;
}
/*
@@ -141,7 +148,8 @@ alias_apply(int (*func)(void *, void *), void *cookie)
int
no_aliases(void)
{
return rbisempty(aliases);
debug_decl(no_aliases, SUDO_DEBUG_ALIAS)
debug_return_int(rbisempty(aliases));
}
/*
@@ -154,6 +162,7 @@ alias_free(void *v)
struct member *m;
struct sudo_command *c;
void *next;
debug_decl(alias_free, SUDO_DEBUG_ALIAS)
efree(a->name);
for (m = a->members.first; m != NULL; m = next) {
@@ -167,6 +176,8 @@ alias_free(void *v)
efree(m);
}
efree(a);
debug_return;
}
/*
@@ -177,6 +188,7 @@ alias_remove(char *name, int type)
{
struct rbnode *node;
struct alias key;
debug_decl(alias_remove, SUDO_DEBUG_ALIAS)
key.name = name;
key.type = type;
@@ -184,13 +196,17 @@ alias_remove(char *name, int type)
errno = ENOENT;
return NULL;
}
return rbdelete(aliases, node);
debug_return_ptr(rbdelete(aliases, node));
}
void
init_aliases(void)
{
debug_decl(init_aliases, SUDO_DEBUG_ALIAS)
if (aliases != NULL)
rbdestroy(aliases, alias_free);
aliases = rbcreate(alias_compare);
debug_return;
}