From 562bad603ce0fe2a6556f0f1aae4f08c9c300987 Mon Sep 17 00:00:00 2001 From: gramanas Date: Tue, 17 Apr 2018 12:30:44 +0300 Subject: fix memory leaks, add logo --- src/ck.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'src/ck.c') diff --git a/src/ck.c b/src/ck.c index 61797b4..98190b1 100644 --- a/src/ck.c +++ b/src/ck.c @@ -26,30 +26,24 @@ int main(int argc, char *argv[]) { if (opt.action != CKA_INIT) { if (!db_exists(&opt)) { printf("ck is not initialized in %s.\nRun ck init first.\n", opt.confDir); + free_user_opt(&opt); return 1; } if (!config_file_parse(&conf, &opt)) { + free_user_opt(&opt); return 1; } } - int ok; - switch(opt.action) { -#define X(ACTION) \ - case CKA_##ACTION: \ - ok = run_##ACTION(&opt, &conf); \ - break; - CK_ACTIONS -#undef X - } + /* Run action and print results */ switch(opt.action) { -#define X(ACTION) \ - case CKA_##ACTION: \ - print_##ACTION##_result(ok); \ +#define X(ACTION) \ + case CKA_##ACTION: \ + print_##ACTION##_result(run_##ACTION(&opt, &conf)); \ break; CK_ACTIONS -#undef X +#undef X } free_user_opt(&opt); return 0; -- cgit v1.2.3