]> the.earth.li Git - onak.git/commitdiff
Cleanup various includes
authorJonathan McDowell <noodles@earth.li>
Tue, 9 Apr 2019 13:38:03 +0000 (14:38 +0100)
committerJonathan McDowell <noodles@earth.li>
Tue, 9 Apr 2019 13:38:03 +0000 (14:38 +0100)
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.

27 files changed:
add.c
armor.c
charfuncs.c
cleanup.c
decodekey.c
hashquery.c
keyd.c
keydb.c
keydb.h
keydb_db4.c
keydb_file.c
keydb_fs.c
keydb_hkp.c
keydb_keyd.c
keydb_stacked.c
keyindex.c
ll.c
ll.h
maxpath.c
merge.c
onak-conf.c
onak-conf.h
parsekey.c
photoid.c
stats.c
stripkey.c
wordlist.c

diff --git a/add.c b/add.c
index 877af11f2055aa46d549a2e66b6971e6fc1413a2..3c8c38b44c92711aed527beb84cf37cb8576474b 100644 (file)
--- a/add.c
+++ b/add.c
@@ -17,7 +17,7 @@
  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-#include <errno.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #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 9b61b1acde9ce17832907cfae5a8302771b4089a..8d57c60e05a219da56ed6928e99a6933273bb2eb 100644 (file)
--- 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"
 
index 4b404c9300f16038a91db63ae34524c30939c7c1..04255dc37ffde715be1cfe1fd693a029de500f13 100644 (file)
@@ -19,8 +19,6 @@
 
 #include <stdio.h>
 #include <string.h>
-#include <sys/types.h>
-#include <sys/uio.h>
 #include <unistd.h>
 
 #include "charfuncs.h"
index 97d02c548bec9b27fbae1449bb59579930dc0bee..124c0025a98f3e534dd1dcb4c3718116eca74c17 100644 (file)
--- a/cleanup.c
+++ b/cleanup.c
 
 #include <signal.h>
 #include <stdbool.h>
-#include <stdlib.h>
-#include <string.h>
 
 #include "cleanup.h"
-#include "keydb.h"
 #include "log.h"
 
 static bool should_cleanup = false;
index be80151d2822c31ddef27de3dfe6cfbfc1d42368..fc3844aeefaf26c949011ba0b65eccb82b283795 100644 (file)
@@ -17,7 +17,7 @@
  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-#include <stdbool.h>
+#include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -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;
        }
index 44434c1d257f86adf40e1a28998dafaa71be70dd..2c41598f0df4791decdb832562476cfa50035e8f 100644 (file)
@@ -17,6 +17,7 @@
  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -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 ad06e6aae77037b23697a78ac8835c0f03684bf0..a7b797c538f8b0b154bc10b2ee1b1b8f04e7b4cb 100644 (file)
--- a/keyd.c
+++ b/keyd.c
@@ -20,7 +20,9 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <getopt.h>
+#include <inttypes.h>
 #include <signal.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
diff --git a/keydb.c b/keydb.c
index 354255fecea07fce1b9ca6a2e64aacbdecf9ab7a..3b57463decfedeab7b0877bc6e77180ebdd68859 100644 (file)
--- a/keydb.c
+++ b/keydb.c
@@ -25,6 +25,7 @@
  *     slower than custom functions however.
  */
 
+#include <stdbool.h>
 #include <stdio.h>
 
 #include "decodekey.h"
 #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 d7515c8f7881452b259b6ae8e6ecf30bb1a6149a..29dde7b8dc243a25a9c7aa438d11f06626f24cab 100644 (file)
--- a/keydb.h
+++ b/keydb.h
@@ -21,6 +21,7 @@
 #ifndef __KEYDB_H__
 #define __KEYDB_H__
 
+#include <stdbool.h>
 #include <inttypes.h>
 
 #include "keystructs.h"
index e09d6533c03bd6e18b718158e5fbcc33df70c2f6..25d9183d4bf62c37a512b6db9a64324f347784ca 100644 (file)
@@ -23,6 +23,8 @@
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <inttypes.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -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"
index 69c2b99051b24b199dfcbef0d8e0d252fa8f2a9b..0c9717a5900f9d13b202e30ed68f84b2a750d893 100644 (file)
@@ -22,6 +22,8 @@
 #include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <inttypes.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -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"
 
index 9a7b2ec13132f1717f61f5cb634ae969c11e2edc..78e240cdae6c2f86b8dd7a830849d629269b21e7 100644 (file)
@@ -22,6 +22,8 @@
 #include <sys/stat.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <inttypes.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -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"
index 1465503ed87518be37ea9e045075e8fc07c6dfa1..a65d11b238cb155cf9bc88dbc9eb9a708e2d0be9 100644 (file)
  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
+#include <inttypes.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #include <curl/curl.h>
 
 #include "armor.h"
index 7d3754a837693d26e610b3e2150471c9ce06aeae..acbdcff14cb2d96fbbeaad66caa19cc27642a48a 100644 (file)
@@ -19,6 +19,8 @@
 
 #include <errno.h>
 #include <fcntl.h>
+#include <stdbool.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -34,6 +36,7 @@
 #include "keystructs.h"
 #include "log.h"
 #include "mem.h"
+#include "onak.h"
 #include "onak-conf.h"
 #include "parsekey.h"
 
index fdd05b1e4411795d1dd7b346f352ff22bd2fc4db..699552bc9c1828c6ae4989c6c73f803a8d5f0a38 100644 (file)
  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
+#include <stdbool.h>
+#include <stdint.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 
 #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;
index 13a2ccdb2cb19917bf6f13364536b0c9acebeb16..340a85e69583ff609ec46fbc97528d2b6a08403e 100644 (file)
 
 #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 d39acb316b520755f6da271e5b3668057ebf9e25..70603b40cfd233bd4022d8a742bef500f0fc2580 100644 (file)
--- a/ll.c
+++ b/ll.c
  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
+#include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 
 #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 8360eabf4c4fb5e66b6d1ed2fdb4316e4ee4ca91..995bcc9ecea7ada0dcf7040b17e30a68181e0b81 100644 (file)
--- a/ll.h
+++ b/ll.h
@@ -21,6 +21,8 @@
 #ifndef __LL_H__
 #define __LL_H__
 
+#include <stdlib.h>
+
 /**
  * @brief Take a packet and add it to a linked list
  */
index 0e5d632c6d150ba8ed66239ada32b523ea5859e5..d128e9c65e51583c75bed8e7e8c74336e4836c0c 100644 (file)
--- a/maxpath.c
+++ b/maxpath.c
  */
 
 #include <getopt.h>
+#include <inttypes.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include "stats.h"
 #include "hash.h"
 #include "keydb.h"
 #include "ll.h"
diff --git a/merge.c b/merge.c
index 353a844e6de9a1d346e7f102d7872b4378206137..67144c28525842524b75da851a5cf4326dc48264 100644 (file)
--- a/merge.c
+++ b/merge.c
  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
+#include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
 #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;
index 58940aaffb5edd784741f788953dc6a1ea104b67..5b84e5acdac9e271a1cae7733f75015b9aa9a2c5 100644 (file)
@@ -23,6 +23,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <strings.h>
 
 #include "ll.h"
 #include "log.h"
index 4cf9bfc2be2b89e9ba99fef6159d980375afcdb8..8d469e98f5af368963c1c302bc488b3504c884eb 100644 (file)
@@ -21,7 +21,9 @@
 #ifndef __ONAK_CONF_H_
 #define __ONAK_CONF_H_
 
-#include "keydb.h"
+#include <stdbool.h>
+
+#include "ll.h"
 
 /**
  * @brief Backend database configuration.
index d152166181577213b413a1e0463b76284b18a7d8..3c781e560d148528bfc5fbc8dc98e00f53376a53 100644 (file)
@@ -22,7 +22,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "keyid.h"
 #include "keystructs.h"
 #include "ll.h"
 #include "mem.h"
index 2501f4a10629557e41e6817d8aa98ccc5f801046..983d6a84716101ffe476100a04630f3b5f14734c 100644 (file)
--- a/photoid.c
+++ b/photoid.c
  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-#include <inttypes.h>
-#include <stdbool.h>
-#include <stdio.h>
 #include <stdlib.h>
 
-#include "keyid.h"
-#include "keyindex.h"
 #include "keystructs.h"
 #include "onak.h"
 #include "photoid.h"
diff --git a/stats.c b/stats.c
index a65650854b45f13365b08da95e0c6e4d5b1c8d69..2e810bb0ebc86a0d6417048d678b740324b3ea57 100644 (file)
--- a/stats.c
+++ b/stats.c
@@ -17,6 +17,7 @@
  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -25,7 +26,6 @@
 #include "hash.h"
 #include "keydb.h"
 #include "ll.h"
-#include "onak-conf.h"
 #include "stats.h"
 
 /**
index e0fb5e38a56957699c70b7630ca1e7291b2e2a48..8aed81005bee3b8e37f16dc72830380752b8177d 100644 (file)
  * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
-#include <getopt.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <fcntl.h>
 
-#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) {
index b594253951d95ba7ace86347c7fca7d4cbb493df..e40fe82dc080736120e7c2cb581a8f17aee0643e 100644 (file)
 
 #include <ctype.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 
 #include "ll.h"
 #include "decodekey.h"
-#include "log.h"
+#include "keystructs.h"
 #include "wordlist.h"
 
 /**