set(CMAKE_POSITION_INDEPENDENT_CODE ON)
TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
+include(CheckCSourceCompiles)
+check_c_source_compiles(
+ "
+ #include <stdlib.h>
+ static void f(__attribute__((unused))) {}
+ int main(void) { f(); return 0;}
+ "
+ HAVE___ATTRIBUTE__UNUSED
+)
+if (HAVE___ATTRIBUTE__UNUSED)
+ set(UNUSED_ATTRIB "__attribute__((unused))")
+else()
+ set(UNUSED_ATTRIB "")
+endif()
+
# Pick up a git based version number for development builds
find_package(Git)
if (GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
#cmakedefine HAVE_SYSTEMD 1
#cmakedefine WORDS_BIGENDIAN 1
+#define __unused @UNUSED_ATTRIB@
+
#endif /* __CONFIG_H__ */
#include <stdint.h>
#include <unistd.h>
+#include "build-config.h"
#include "charfuncs.h"
#include "cleanup.h"
#include "keydb.h"
exit(EXIT_FAILURE);
}
-int main(int argc, char *argv[])
+int main(__unused int argc, __unused char *argv[])
{
char *request_method, *env;
int count, found, i;
char *search, uint64_t keyid,
struct openpgp_fingerprint *fingerprint,
bool ishex, bool isfp, bool dispfp, bool skshash,
- bool exact, bool verbose, bool mrhkp)
+ __unused bool exact, bool verbose, bool mrhkp)
{
struct openpgp_publickey *publickey = NULL;
int count = 0;
#include <string.h>
#include <unistd.h>
+#include "build-config.h"
#include "charfuncs.h"
/*
/*
* Gets a char from stdin.
*/
-int stdin_getchar(void *ctx, size_t count, void *c)
+int stdin_getchar(__unused void *ctx, size_t count, void *c)
{
return (fread(c, 1, count, stdin) != count);
}
/*
* Puts a char to stdout.
*/
-int stdout_putchar(void *ctx, size_t count, void *c)
+int stdout_putchar(__unused void *ctx, size_t count, void *c)
{
return (fwrite(c, 1, count, stdout) != count);
}
#include <db.h>
+#include "build-config.h"
#include "charfuncs.h"
#include "keyarray.h"
#include "keydb.h"
#if (DB_VERSION_MAJOR == 4) && (DB_VERSION_MINOR < 3)
static void db4_errfunc(const char *errpfx, const char *errmsg)
#else
-static void db4_errfunc(const DB_ENV *edbenv, const char *errpfx,
+static void db4_errfunc(__unused const DB_ENV *edbenv, const char *errpfx,
const char *errmsg)
#endif
{
#include <string.h>
#include <unistd.h>
+#include "build-config.h"
#include "charfuncs.h"
#include "key-store.h"
#include "keydb.h"
*
* This is just a no-op for flat file access.
*/
-static bool file_starttrans(struct onak_dbctx *dbctx)
+static bool file_starttrans(__unused struct onak_dbctx *dbctx)
{
return true;
}
*
* This is just a no-op for flat file access.
*/
-static void file_endtrans(struct onak_dbctx *dbctx)
+static void file_endtrans(__unused struct onak_dbctx *dbctx)
{
return;
}
static int file_fetch_key_id(struct onak_dbctx *dbctx,
uint64_t keyid,
struct openpgp_publickey **publickey,
- bool intrans)
+ __unused bool intrans)
{
char *db_dir = (char *) dbctx->priv;
struct openpgp_packet_list *packets = NULL;
* the file.
*/
static int file_store_key(struct onak_dbctx *dbctx,
- struct openpgp_publickey *publickey, bool intrans,
- bool update)
+ struct openpgp_publickey *publickey, __unused bool intrans,
+ __unused bool update)
{
char *db_dir = (char *) dbctx->priv;
struct openpgp_packet_list *packets = NULL;
* are using. Returns 0 if the key existed.
*/
static int file_delete_key(struct onak_dbctx *dbctx,
- struct openpgp_fingerprint *fp, bool intrans)
+ struct openpgp_fingerprint *fp, __unused bool intrans)
{
char *db_dir = (char *) dbctx->priv;
char keyfile[1024];
*
* TODO: Write for flat file access. Some sort of grep?
*/
-static int file_fetch_key_text(struct onak_dbctx *dbctx,
- const char *search,
- struct openpgp_publickey **publickey)
+static int file_fetch_key_text(__unused struct onak_dbctx *dbctx,
+ __unused const char *search,
+ __unused struct openpgp_publickey **publickey)
{
return 0;
}
*
* This is just a no-op for flat file access.
*/
-struct onak_dbctx *keydb_file_init(struct onak_db_config *dbcfg, bool readonly)
+struct onak_dbctx *keydb_file_init(struct onak_db_config *dbcfg,
+ __unused bool readonly)
{
struct onak_dbctx *dbctx;
*
* Returns the number of keys we iterated over.
*/
-static int fs_iterate_keys(struct onak_dbctx *dbctx,
- void (*iterfunc)(void *ctx,
- struct openpgp_publickey *key), void *ctx)
+static int fs_iterate_keys(__unused struct onak_dbctx *dbctx,
+ __unused void (*iterfunc)(void *ctx,
+ struct openpgp_publickey *key),
+ __unused void *ctx)
{
return 0;
}
static int hkp_fetch_key_url(struct onak_dbctx *dbctx,
char *url,
struct openpgp_publickey **publickey,
- bool intrans)
+ __unused bool intrans)
{
struct onak_hkp_dbctx *privctx = (struct onak_hkp_dbctx *) dbctx->priv;
struct openpgp_packet_list *packets = NULL;
static int hkp_fetch_key_fp(struct onak_dbctx *dbctx,
struct openpgp_fingerprint *fingerprint,
struct openpgp_publickey **publickey,
- bool intrans)
+ __unused bool intrans)
{
struct onak_hkp_dbctx *privctx = (struct onak_hkp_dbctx *) dbctx->priv;
char keyurl[1024];
*
*/
static int hkp_store_key(struct onak_dbctx *dbctx,
- struct openpgp_publickey *publickey, bool intrans,
- bool update)
+ struct openpgp_publickey *publickey,
+ __unused bool intrans,
+ __unused bool update)
{
struct onak_hkp_dbctx *privctx = (struct onak_hkp_dbctx *) dbctx->priv;
struct openpgp_packet_list *packets = NULL;
*
* No op for HKP.
*/
-static int hkp_delete_key(struct onak_dbctx *dbctx,
- struct openpgp_fingerprint *fp, bool intrans)
+static int hkp_delete_key(__unused struct onak_dbctx *dbctx,
+ __unused struct openpgp_fingerprint *fp, __unused bool intrans)
{
return -1;
}
*
* Not applicable for HKP backend.
*/
-static int hkp_iterate_keys(struct onak_dbctx *dbctx,
- void (*iterfunc)(void *ctx, struct openpgp_publickey *key),
- void *ctx)
+static int hkp_iterate_keys(__unused struct onak_dbctx *dbctx,
+ __unused void (*iterfunc)(void *ctx, struct openpgp_publickey *key),
+ __unused void *ctx)
{
return 0;
}
*
* This is just a no-op for HKP access.
*/
-static bool hkp_starttrans(struct onak_dbctx *dbctx)
+static bool hkp_starttrans(__unused struct onak_dbctx *dbctx)
{
return true;
}
*
* This is just a no-op for HKP access.
*/
-static void hkp_endtrans(struct onak_dbctx *dbctx)
+static void hkp_endtrans(__unused struct onak_dbctx *dbctx)
{
return;
}
*
* We initialize CURL here.
*/
-struct onak_dbctx *keydb_hkp_init(struct onak_db_config *dbcfg, bool readonly)
+struct onak_dbctx *keydb_hkp_init(struct onak_db_config *dbcfg,
+ __unused bool readonly)
{
struct onak_dbctx *dbctx;
struct onak_hkp_dbctx *privctx;
#include <sys/un.h>
#include <unistd.h>
+#include "build-config.h"
#include "charfuncs.h"
#include "keyd.h"
#include "keydb.h"
* operations on the database to help speed it all up, or if we want
* something to only succeed if all relevant operations are successful.
*/
-static bool keyd_starttrans(struct onak_dbctx *dbctx)
+static bool keyd_starttrans(__unused struct onak_dbctx *dbctx)
{
return true;
}
*
* Ends a transaction.
*/
-static void keyd_endtrans(struct onak_dbctx *dbctx)
+static void keyd_endtrans(__unused struct onak_dbctx *dbctx)
{
return;
}
static int keyd_fetch_key(struct onak_dbctx *dbctx,
struct openpgp_fingerprint *fingerprint,
struct openpgp_publickey **publickey,
- bool intrans)
+ __unused bool intrans)
{
int keyd_fd = (intptr_t) dbctx->priv;
struct buffer_ctx keybuf;
static int keyd_fetch_key_fp(struct onak_dbctx *dbctx,
struct openpgp_fingerprint *fingerprint,
struct openpgp_publickey **publickey,
- bool intrans)
+ __unused bool intrans)
{
int keyd_fd = (intptr_t) dbctx->priv;
struct buffer_ctx keybuf;
static int keyd_fetch_key_id(struct onak_dbctx *dbctx,
uint64_t keyid,
struct openpgp_publickey **publickey,
- bool intrans)
+ __unused bool intrans)
{
int keyd_fd = (intptr_t) dbctx->priv;
struct buffer_ctx keybuf;
* are using. Returns 0 if the key existed.
*/
static int keyd_delete_key(struct onak_dbctx *dbctx,
- struct openpgp_fingerprint *fp, bool intrans)
+ struct openpgp_fingerprint *fp,
+ __unused bool intrans)
{
int keyd_fd = (intptr_t) dbctx->priv;
* it?
*/
static int keyd_store_key(struct onak_dbctx *dbctx,
- struct openpgp_publickey *publickey, bool intrans,
+ struct openpgp_publickey *publickey,
+ __unused bool intrans,
bool update)
{
int keyd_fd = (intptr_t) dbctx->priv;
* this file are called in order to allow the DB to be initialized ready
* for access.
*/
-struct onak_dbctx *keydb_keyd_init(struct onak_db_config *dbcfg, bool readonly)
+struct onak_dbctx *keydb_keyd_init(struct onak_db_config *dbcfg,
+ __unused bool readonly)
{
struct sockaddr_un sock;
uint32_t cmd = KEYD_CMD_UNKNOWN;
#include <string.h>
#include <unistd.h>
+#include "build-config.h"
#include "charfuncs.h"
#include "keyarray.h"
#include "keydb.h"
*
* This is just a no-op for keyring file access.
*/
-static bool keyring_starttrans(struct onak_dbctx *dbctx)
+static bool keyring_starttrans(__unused struct onak_dbctx *dbctx)
{
return true;
}
*
* This is just a no-op for keyring file access.
*/
-static void keyring_endtrans(struct onak_dbctx *dbctx)
+static void keyring_endtrans(__unused struct onak_dbctx *dbctx)
{
return;
}
static int keyring_fetch_key(struct onak_dbctx *dbctx,
struct openpgp_fingerprint *fingerprint,
struct openpgp_publickey **publickey,
- bool intrans)
+ __unused bool intrans)
{
struct onak_keyring_dbctx *privctx =
(struct onak_keyring_dbctx *) dbctx->priv;
static int keyring_fetch_key_id(struct onak_dbctx *dbctx,
uint64_t keyid,
struct openpgp_publickey **publickey,
- bool intrans)
+ __unused bool intrans)
{
struct onak_keyring_dbctx *privctx =
(struct onak_keyring_dbctx *) dbctx->priv;
*
* We don't support storing keys into a keyring file.
*/
-static int keyring_store_key(struct onak_dbctx *dbctx,
- struct openpgp_publickey *publickey, bool intrans,
- bool update)
+static int keyring_store_key(__unused struct onak_dbctx *dbctx,
+ __unused struct openpgp_publickey *publickey,
+ __unused bool intrans,
+ __unused bool update)
{
return 0;
}
*
* We don't support removing keys from a keyring file.
*/
-static int keyring_delete_key(struct onak_dbctx *dbctx,
- struct openpgp_fingerprint *fp, bool intrans)
+static int keyring_delete_key(__unused struct onak_dbctx *dbctx,
+ __unused struct openpgp_fingerprint *fp, __unused bool intrans)
{
return 1;
}
*
* TODO: Write for flat file access. Some sort of grep?
*/
-static int keyring_fetch_key_text(struct onak_dbctx *dbctx,
- const char *search,
- struct openpgp_publickey **publickey)
+static int keyring_fetch_key_text(__unused struct onak_dbctx *dbctx,
+ __unused const char *search,
+ __unused struct openpgp_publickey **publickey)
{
return 0;
}
return count;
}
-static int keyring_update_keys(struct onak_dbctx *dbctx,
- struct openpgp_publickey **keys,
- struct keyarray *blacklist,
- bool updateonly,
- bool sendsync)
+static int keyring_update_keys(__unused struct onak_dbctx *dbctx,
+ __unused struct openpgp_publickey **keys,
+ __unused struct keyarray *blacklist,
+ __unused bool updateonly,
+ __unused bool sendsync)
{
return 0;
}
* This is just a no-op for flat file access.
*/
struct onak_dbctx *keydb_keyring_init(struct onak_db_config *dbcfg,
- bool readonly)
+ __unused bool readonly)
{
struct onak_keyring_dbctx *privctx;
struct onak_dbctx *dbctx;
#include <string.h>
#include <unistd.h>
+#include "build-config.h"
#include "hash.h"
#include "keydb.h"
#include "keyid.h"
* this file are called in order to allow the DB to be initialized ready
* for access.
*/
-struct onak_dbctx *keydb_pg_init(struct onak_db_config *dbcfg, bool readonly)
+struct onak_dbctx *keydb_pg_init(struct onak_db_config *dbcfg,
+ __unused bool readonly)
{
struct onak_dbctx *dbctx;
PGconn *dbconn;
static onak_status_t onak_parse_key_material(struct openpgp_packet *pk,
struct onak_key_material *key)
{
- int i, len, ofs;
+ int len, ofs;
enum onak_oid oid;
mpz_t x, y;
onak_status_t ret = ONAK_E_OK;
struct dsa_signature dsasig;
uint8_t sigkeytype;
uint8_t edsig[64];
- uint64_t keyid;
int len, ofs;
mpz_t s;
uint8_t keyheader[5];
uint8_t packetheader[5];
uint8_t trailer[10];
- int i;
uint64_t keyid;
onak_status_t res;