Skip to content
Snippets Groups Projects
Commit 9ab88037 authored by Filip Siroky's avatar Filip Siroky Committed by Daniel Salzman
Browse files

dnssec: fix coverity errors

parent ab08ecc8
No related branches found
No related tags found
No related merge requests found
......@@ -25,7 +25,7 @@
_public_
key_state_t dnssec_get_key_state(const dnssec_kasp_key_t *key, time_t moment)
{
if (!key || time <= 0)
if (!key || moment <= 0)
{
return DNSSEC_KEY_STATE_INVALID;
}
......
......@@ -19,13 +19,9 @@
#include <string.h>
#include <stdio.h>
#include "dnssec/keyusage.h"
#include "dnssec/error.h"
#include "dnssec.h"
char *json_path = NULL, *json_file = NULL;
static void test_keyusage_empty(void)
static void test_keyusage_empty(const char *json_file)
{
diag("%s", __func__);
......@@ -75,7 +71,7 @@ static void test_keyusage_basic(void)
dnssec_keyusage_free(k);
}
static void test_keyusage_file(void)
static void test_keyusage_file(const char *json_file)
{
dnssec_keyusage_t *k = NULL;
k = dnssec_keyusage_new();
......@@ -99,23 +95,30 @@ static void test_keyusage_file(void)
dnssec_keyusage_free(k);
}
int main(int argc, char *argv[])
int main(void)
{
plan_lazy();
char *json_path = NULL, *json_file = NULL;
json_path = test_mkdtemp();
asprintf(&json_file, "%s/keyusage.json", json_path ? json_path : "/tmp");
if (!json_path) {
fprintf(stderr, "Failed to create teporary path.");
return -1;
}
test_keyusage_empty();
int r = asprintf(&json_file, "%s/keyusage.json", json_path);
if (r == -1) {
fprintf(stderr, "Failed to create teporary file path.");
return -1;
}
test_keyusage_empty(json_file);
test_keyusage_basic();
test_keyusage_file();
test_keyusage_file(json_file);
remove(json_file);
free(json_file);
if (json_path) {
remove(json_path);
free(json_path);
}
test_rm_rf(json_path);
free(json_path);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment