diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-03-07 00:28:07 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-03-07 00:28:07 +0100 |
commit | ffcadbff8c678c495af05428de21761cf3956f3b (patch) | |
tree | 28587c91a063b2d97972bb7ba1eac0803580035b /src/exchangedb/exchangedb_signkeys.c | |
parent | 82d7b63ff5c8fc86d5146333943eb4a03a2e6e08 (diff) | |
download | exchange-ffcadbff8c678c495af05428de21761cf3956f3b.tar.xz |
code cleanup (comments, scoping, naming, indentation)
Diffstat (limited to 'src/exchangedb/exchangedb_signkeys.c')
-rw-r--r-- | src/exchangedb/exchangedb_signkeys.c | 52 |
1 files changed, 21 insertions, 31 deletions
diff --git a/src/exchangedb/exchangedb_signkeys.c b/src/exchangedb/exchangedb_signkeys.c index 71ebb5526..beafa1dda 100644 --- a/src/exchangedb/exchangedb_signkeys.c +++ b/src/exchangedb/exchangedb_signkeys.c @@ -1,6 +1,6 @@ /* This file is part of TALER - Copyright (C) 2014, 2015, 2016 Taler Systems SA + Copyright (C) 2014, 2015, 2016, 2020 Taler Systems SA TALER is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -112,15 +112,16 @@ TALER_EXCHANGEDB_signing_keys_iterate (const char *exchange_base_dir, TALER_EXCHANGEDB_SigningKeyIterator it, void *it_cls) { + struct SignkeysIterateContext skc = { + .it = it, + .it_cls = it_cls + }; char *signkey_dir; - struct SignkeysIterateContext skc; int ret; GNUNET_asprintf (&signkey_dir, "%s" DIR_SEPARATOR_STR TALER_EXCHANGEDB_DIR_SIGNING_KEYS, exchange_base_dir); - skc.it = it; - skc.it_cls = it_cls; ret = GNUNET_DISK_directory_scan (signkey_dir, &signkeys_iterate_dir_iter, &skc); @@ -130,30 +131,6 @@ TALER_EXCHANGEDB_signing_keys_iterate (const char *exchange_base_dir, /** - * Obtain the name of the directory we use to store signing - * keys created at time @a start. - * - * @param exchange_directory base director where we store key material - * @param start time at which we create the signing key - * @return name of the directory we should use, basically "$EXCHANGEDIR/$TIME/"; - * (valid until next call to this function) - */ -static char * -get_signkey_file (const char *exchange_directory, - struct GNUNET_TIME_Absolute start) -{ - char *fn; - - GNUNET_asprintf (&fn, - "%s" DIR_SEPARATOR_STR TALER_EXCHANGEDB_DIR_SIGNING_KEYS - DIR_SEPARATOR_STR "%llu", - exchange_directory, - (unsigned long long) start.abs_value_us); - return fn; -} - - -/** * Exports a signing key to the given file. * * @param exchange_base_dir base directory for the keys @@ -171,18 +148,31 @@ TALER_EXCHANGEDB_signing_key_write (const char *exchange_base_dir, char *skf; ssize_t nwrite; - skf = get_signkey_file (exchange_base_dir, - start); + GNUNET_asprintf (&skf, + "%s" DIR_SEPARATOR_STR TALER_EXCHANGEDB_DIR_SIGNING_KEYS + DIR_SEPARATOR_STR "%llu", + exchange_base_dir, + (unsigned long long) start.abs_value_us); if (GNUNET_OK != GNUNET_DISK_directory_create_for_file (skf)) + { + int eno; + + eno = errno; + GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, + "mkdir (for file)", + skf); + errno = eno; return GNUNET_SYSERR; + } nwrite = GNUNET_DISK_fn_write (skf, ski, sizeof (struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP), GNUNET_DISK_PERM_USER_WRITE | GNUNET_DISK_PERM_USER_READ); - if (sizeof (struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP) != nwrite) + if (sizeof (struct TALER_EXCHANGEDB_PrivateSigningKeyInformationP) != + (size_t) nwrite) { GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "write", |