From 0c120d1895d25b59abe338862189be1b87447569 Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Tue, 9 Apr 2019 14:38:03 +0100 Subject: [PATCH] Cleanup various includes Run include-what-you-use and do some cleanups based on its suggestions. Pull out some logging dependencies that don't need to be there in the process. --- add.c | 4 +--- armor.c | 1 - charfuncs.c | 2 -- cleanup.c | 3 --- decodekey.c | 10 +++------- hashquery.c | 3 ++- keyd.c | 2 ++ keydb.c | 4 +++- keydb.h | 1 + keydb_db4.c | 4 ++++ keydb_file.c | 4 +++- keydb_fs.c | 3 +++ keydb_hkp.c | 3 ++- keydb_keyd.c | 3 +++ keydb_stacked.c | 12 ++++-------- keyindex.c | 2 -- ll.c | 8 +++----- ll.h | 2 ++ maxpath.c | 3 ++- merge.c | 10 +++++----- onak-conf.c | 1 + onak-conf.h | 4 +++- parsekey.c | 1 - photoid.c | 5 ----- stats.c | 2 +- stripkey.c | 12 +----------- wordlist.c | 3 ++- 27 files changed, 51 insertions(+), 61 deletions(-) diff --git a/add.c b/add.c index 877af11..3c8c38b 100644 --- a/add.c +++ b/add.c @@ -17,7 +17,7 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include +#include #include #include #include @@ -28,10 +28,8 @@ #include "charfuncs.h" #include "getcgi.h" #include "keydb.h" -#include "keystructs.h" #include "log.h" #include "mem.h" -#include "merge.h" #include "onak-conf.h" #include "parsekey.h" diff --git a/armor.c b/armor.c index 9b61b1a..8d57c60 100644 --- a/armor.c +++ b/armor.c @@ -22,7 +22,6 @@ #include "armor.h" #include "keystructs.h" -#include "onak-conf.h" #include "parsekey.h" #include "version.h" diff --git a/charfuncs.c b/charfuncs.c index 4b404c9..04255dc 100644 --- a/charfuncs.c +++ b/charfuncs.c @@ -19,8 +19,6 @@ #include #include -#include -#include #include #include "charfuncs.h" diff --git a/cleanup.c b/cleanup.c index 97d02c5..124c002 100644 --- a/cleanup.c +++ b/cleanup.c @@ -19,11 +19,8 @@ #include #include -#include -#include #include "cleanup.h" -#include "keydb.h" #include "log.h" static bool should_cleanup = false; diff --git a/decodekey.c b/decodekey.c index be80151..fc3844a 100644 --- a/decodekey.c +++ b/decodekey.c @@ -17,7 +17,7 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include +#include #include #include #include @@ -28,7 +28,6 @@ #include "keyid.h" #include "keystructs.h" #include "ll.h" -#include "log.h" #include "openpgp.h" /* @@ -51,7 +50,7 @@ onak_status_t parse_subpackets(unsigned char *data, size_t len, int length = 0; int packetlen = 0; - log_assert(data != NULL); + assert(data != NULL); /* Make sure we actually have the 2 byte length field */ if (len < 2) { @@ -162,11 +161,8 @@ onak_status_t parse_subpackets(unsigned char *data, size_t len, * 7 is set in which case we log a major error. */ if (data[offset] & 0x80) { - logthing(LOGTHING_CRITICAL, - "Critical subpacket type not parsed: 0x%X", - data[offset]); + return ONAK_E_UNSUPPORTED_FEATURE; } - } offset += packetlen; } diff --git a/hashquery.c b/hashquery.c index 44434c1..2c41598 100644 --- a/hashquery.c +++ b/hashquery.c @@ -17,6 +17,7 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include #include #include @@ -25,7 +26,7 @@ #include "charfuncs.h" #include "cleanup.h" -#include "keyid.h" +#include "keydb.h" #include "log.h" #include "marshal.h" #include "mem.h" diff --git a/keyd.c b/keyd.c index ad06e6a..a7b797c 100644 --- a/keyd.c +++ b/keyd.c @@ -20,7 +20,9 @@ #include #include #include +#include #include +#include #include #include #include diff --git a/keydb.c b/keydb.c index 354255f..3b57463 100644 --- a/keydb.c +++ b/keydb.c @@ -25,6 +25,7 @@ * slower than custom functions however. */ +#include #include #include "decodekey.h" @@ -32,11 +33,12 @@ #include "keydb.h" #include "keyid.h" #include "keystructs.h" +#include "ll.h" #include "mem.h" #include "merge.h" #include "openpgp.h" -#include "parsekey.h" #include "sendsync.h" +#include "stats.h" #ifdef NEED_KEYID2UID /** diff --git a/keydb.h b/keydb.h index d7515c8..29dde7b 100644 --- a/keydb.h +++ b/keydb.h @@ -21,6 +21,7 @@ #ifndef __KEYDB_H__ #define __KEYDB_H__ +#include #include #include "keystructs.h" diff --git a/keydb_db4.c b/keydb_db4.c index e09d653..25d9183 100644 --- a/keydb_db4.c +++ b/keydb_db4.c @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include #include @@ -37,7 +39,9 @@ #include "decodekey.h" #include "keystructs.h" #include "mem.h" +#include "ll.h" #include "log.h" +#include "onak.h" #include "onak-conf.h" #include "parsekey.h" #include "wordlist.h" diff --git a/keydb_file.c b/keydb_file.c index 69c2b99..0c9717a 100644 --- a/keydb_file.c +++ b/keydb_file.c @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include #include #include @@ -31,9 +33,9 @@ #include "keydb.h" #include "keyid.h" #include "keystructs.h" -#include "ll.h" #include "log.h" #include "mem.h" +#include "onak.h" #include "onak-conf.h" #include "parsekey.h" diff --git a/keydb_fs.c b/keydb_fs.c index 9a7b2ec..78e240c 100644 --- a/keydb_fs.c +++ b/keydb_fs.c @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include #include #include @@ -36,6 +38,7 @@ #include "keystructs.h" #include "ll.h" #include "mem.h" +#include "onak.h" #include "onak-conf.h" #include "parsekey.h" #include "log.h" diff --git a/keydb_hkp.c b/keydb_hkp.c index 1465503..a65d11b 100644 --- a/keydb_hkp.c +++ b/keydb_hkp.c @@ -17,10 +17,11 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include +#include #include #include #include -#include #include #include "armor.h" diff --git a/keydb_keyd.c b/keydb_keyd.c index 7d3754a..acbdcff 100644 --- a/keydb_keyd.c +++ b/keydb_keyd.c @@ -19,6 +19,8 @@ #include #include +#include +#include #include #include #include @@ -34,6 +36,7 @@ #include "keystructs.h" #include "log.h" #include "mem.h" +#include "onak.h" #include "onak-conf.h" #include "parsekey.h" diff --git a/keydb_stacked.c b/keydb_stacked.c index fdd05b1..699552b 100644 --- a/keydb_stacked.c +++ b/keydb_stacked.c @@ -17,22 +17,18 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include +#include #include +#include #include #include "cleankey.h" -#include "decodekey.h" -#include "hash.h" #include "keydb.h" -#include "keyid.h" #include "keystructs.h" +#include "ll.h" #include "log.h" -#include "mem.h" -#include "merge.h" #include "onak-conf.h" -#include "openpgp.h" -#include "parsekey.h" -#include "sendsync.h" struct onak_stacked_dbctx { struct ll *backends; diff --git a/keyindex.c b/keyindex.c index 13a2ccd..340a85e 100644 --- a/keyindex.c +++ b/keyindex.c @@ -26,14 +26,12 @@ #include "decodekey.h" #include "getcgi.h" -#include "hash.h" #include "keydb.h" #include "keyid.h" #include "keyindex.h" #include "keystructs.h" #include "log.h" #include "onak.h" -#include "onak-conf.h" #include "openpgp.h" /* diff --git a/ll.c b/ll.c index d39acb3..70603b4 100644 --- a/ll.c +++ b/ll.c @@ -17,11 +17,11 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include #include #include "ll.h" -#include "log.h" struct ll *lladd(struct ll *curll, void *object) { @@ -45,8 +45,6 @@ struct ll *lladdend(struct ll *curll, void *object) struct ll *cur; if ((new = malloc(sizeof(struct ll))) == NULL) { - logthing(LOGTHING_ERROR, - "Couldn't allocate memory in lladdend()"); return NULL; } @@ -72,7 +70,7 @@ struct ll *lldel(struct ll *curll, void *object, struct ll *cur = NULL; struct ll *old = NULL; - log_assert(objectcmp != NULL); + assert(objectcmp != NULL); cur = curll; if (cur == NULL) { @@ -99,7 +97,7 @@ struct ll *llfind(struct ll *curll, void *object, { struct ll *cur; - log_assert(objectcmp != NULL); + assert(objectcmp != NULL); cur = curll; while (cur != NULL && (*objectcmp)(cur->object, object)) { diff --git a/ll.h b/ll.h index 8360eab..995bcc9 100644 --- a/ll.h +++ b/ll.h @@ -21,6 +21,8 @@ #ifndef __LL_H__ #define __LL_H__ +#include + /** * @brief Take a packet and add it to a linked list */ diff --git a/maxpath.c b/maxpath.c index 0e5d632..d128e9c 100644 --- a/maxpath.c +++ b/maxpath.c @@ -18,11 +18,12 @@ */ #include +#include +#include #include #include #include -#include "stats.h" #include "hash.h" #include "keydb.h" #include "ll.h" diff --git a/merge.c b/merge.c index 353a844..67144c2 100644 --- a/merge.c +++ b/merge.c @@ -17,18 +17,18 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include #include #include #include "decodekey.h" -#include "keydb.h" #include "keyid.h" #include "keystructs.h" #include "ll.h" -#include "log.h" #include "mem.h" #include "merge.h" +#include "onak.h" /** * compare_packets - Check to see if 2 OpenPGP packets are the same. @@ -210,7 +210,7 @@ int merge_packet_sigs(struct openpgp_signedpacket_list *old, struct openpgp_packet_list *curpacket = NULL; struct openpgp_packet_list *nextpacket = NULL; - log_assert(compare_packets(old->packet, new->packet) == 0); + assert(compare_packets(old->packet, new->packet) == 0); curpacket = new->sigs; while (curpacket != NULL) { @@ -230,7 +230,7 @@ int merge_packet_sigs(struct openpgp_signedpacket_list *old, if (lastpacket != NULL) { lastpacket->next = curpacket->next; } else { - log_assert(curpacket == new->sigs); + assert(curpacket == new->sigs); new->sigs = curpacket->next; } curpacket->next = NULL; @@ -362,7 +362,7 @@ int merge_keys(struct openpgp_publickey *a, struct openpgp_publickey *b) if (lastpacket != NULL) { lastpacket->next = curpacket->next; } else { - log_assert(curpacket == b->sigs); + assert(curpacket == b->sigs); b->sigs = curpacket->next; } curpacket->next = NULL; diff --git a/onak-conf.c b/onak-conf.c index 58940aa..5b84e5a 100644 --- a/onak-conf.c +++ b/onak-conf.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "ll.h" #include "log.h" diff --git a/onak-conf.h b/onak-conf.h index 4cf9bfc..8d469e9 100644 --- a/onak-conf.h +++ b/onak-conf.h @@ -21,7 +21,9 @@ #ifndef __ONAK_CONF_H_ #define __ONAK_CONF_H_ -#include "keydb.h" +#include + +#include "ll.h" /** * @brief Backend database configuration. diff --git a/parsekey.c b/parsekey.c index d152166..3c781e5 100644 --- a/parsekey.c +++ b/parsekey.c @@ -22,7 +22,6 @@ #include #include -#include "keyid.h" #include "keystructs.h" #include "ll.h" #include "mem.h" diff --git a/photoid.c b/photoid.c index 2501f4a..983d6a8 100644 --- a/photoid.c +++ b/photoid.c @@ -17,13 +17,8 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include -#include -#include #include -#include "keyid.h" -#include "keyindex.h" #include "keystructs.h" #include "onak.h" #include "photoid.h" diff --git a/stats.c b/stats.c index a656508..2e810bb 100644 --- a/stats.c +++ b/stats.c @@ -17,6 +17,7 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +#include #include #include @@ -25,7 +26,6 @@ #include "hash.h" #include "keydb.h" #include "ll.h" -#include "onak-conf.h" #include "stats.h" /** diff --git a/stripkey.c b/stripkey.c index e0fb5e3..8aed810 100644 --- a/stripkey.c +++ b/stripkey.c @@ -17,26 +17,16 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -#include +#include #include #include -#include -#include -#include -#include "armor.h" #include "charfuncs.h" #include "cleankey.h" -#include "keydb.h" #include "keyid.h" -#include "keyindex.h" #include "keystructs.h" -#include "log.h" #include "mem.h" -#include "merge.h" -#include "onak-conf.h" #include "parsekey.h" -#include "photoid.h" #include "decodekey.h" int main(int argc, char** argv) { diff --git a/wordlist.c b/wordlist.c index b594253..e40fe82 100644 --- a/wordlist.c +++ b/wordlist.c @@ -19,11 +19,12 @@ #include #include +#include #include #include "ll.h" #include "decodekey.h" -#include "log.h" +#include "keystructs.h" #include "wordlist.h" /** -- 2.39.5