#include <sys/types.h>
#include <unistd.h>
+#include <shared/util.h>
+
#include "testsuite.h"
struct mod {
static struct mod *modules;
static bool need_init = true;
-static void parse_retcodes(struct mod *_modules, const char *s)
+static void parse_retcodes(struct mod **_modules, const char *s)
{
const char *p;
if (modname == NULL || modname[0] == '\0')
break;
- modnamelen = strcspn(s, ":");
+ modnamelen = strcspn(p, ":");
if (modname[modnamelen] != ':')
break;
l = strtol(p, &end, 0);
if (end == p || *end != ':')
break;
+
ret = (int) l;
p = end + 1;
mod->name[modnamelen] = '\0';
mod->ret = ret;
mod->errcode = errcode;
- mod->next = _modules;
- _modules = mod;
+ mod->next = *_modules;
+ *_modules = mod;
}
}
struct mod *mod;
for (mod = _modules; mod != NULL; mod = mod->next) {
- if (strcmp(mod->name, modname))
+ if (streq(mod->name, modname))
return mod;
}
static void init_retcodes(void)
{
const char *s;
+ struct mod *mod;
if (!need_init)
return;
need_init = false;
s = getenv(S_TC_DELETE_MODULE_RETCODES);
if (s == NULL) {
- fprintf(stderr, "TRAP delete_module(): missing export %s?\n",
+ ERR("TRAP delete_module(): missing export %s?\n",
S_TC_DELETE_MODULE_RETCODES);
}
- parse_retcodes(modules, s);
+ parse_retcodes(&modules, s);
+
+ for (mod = modules; mod != NULL; mod = mod->next) {
+ LOG("Added module to test delete_module:\n");
+ LOG("\tname=%s ret=%d errcode=%d\n",
+ mod->name, mod->ret, mod->errcode);
+ }
}
TS_EXPORT long delete_module(const char *name, unsigned int flags);