Rage-cleanup.
While trying to get the unit tests working again I stumbled over all those things that I thought could be better^TM. Now we also know "TODO: why does this make the test fail?" - because the unit tests are brittle AF ... and we have to init the subsystems we use in the test, otherwise the cleanup will fail... BTW. you can now also only run a single test ... or a pattern or so ... you'd have to read how `cmocka_set_test_filter()` works exactly. Signed-off-by: Steffen Jaeckel <s@jaeckel.eu>
This commit is contained in:
@@ -111,7 +111,7 @@ api_register_command(const char* const plugin_name, const char* command_name, in
|
||||
char** synopsis, const char* description, char* arguments[][2], char** examples,
|
||||
void* callback, void (*callback_exec)(PluginCommand* command, gchar** args), void (*callback_destroy)(void* callback))
|
||||
{
|
||||
PluginCommand* command = malloc(sizeof(PluginCommand));
|
||||
PluginCommand* command = calloc(1, sizeof(PluginCommand));
|
||||
command->command_name = strdup(command_name);
|
||||
command->min_args = min_args;
|
||||
command->max_args = max_args;
|
||||
@@ -119,28 +119,22 @@ api_register_command(const char* const plugin_name, const char* command_name, in
|
||||
command->callback_exec = callback_exec;
|
||||
command->callback_destroy = callback_destroy;
|
||||
|
||||
CommandHelp* help = malloc(sizeof(CommandHelp));
|
||||
|
||||
help->tags[0] = NULL;
|
||||
CommandHelp* help = calloc(1, sizeof(CommandHelp));
|
||||
|
||||
int i;
|
||||
for (i = 0; synopsis[i] != NULL; i++) {
|
||||
help->synopsis[i] = strdup(synopsis[i]);
|
||||
}
|
||||
help->synopsis[i] = NULL;
|
||||
|
||||
help->desc = strdup(description);
|
||||
for (i = 0; arguments[i][0] != NULL; i++) {
|
||||
help->args[i][0] = strdup(arguments[i][0]);
|
||||
help->args[i][1] = strdup(arguments[i][1]);
|
||||
}
|
||||
help->args[i][0] = NULL;
|
||||
help->args[i][1] = NULL;
|
||||
|
||||
for (i = 0; examples[i] != NULL; i++) {
|
||||
help->examples[i] = strdup(examples[i]);
|
||||
}
|
||||
help->examples[i] = NULL;
|
||||
|
||||
command->help = help;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user