From: Jonathan McDowell <noodles@earth.li>
Date: Tue, 15 Mar 2011 01:58:35 +0000 (-0700)
Subject: Fix delete_key function in keyd backend
X-Git-Url: https://git.sommitrealweird.co.uk/onak.git/commitdiff_plain/38673288bad5b2c0f730021d9311e2df73c74c82?ds=inline

Fix delete_key function in keyd backend

  Need to use keyd_delete_key, not delete_key. Also move function to
  before usage to eliminate need for prototype definition.
---

diff --git a/keydb_keyd.c b/keydb_keyd.c
index 32cf0f0..3f199bd 100644
--- a/keydb_keyd.c
+++ b/keydb_keyd.c
@@ -188,6 +188,27 @@ static int keyd_fetch_key(uint64_t keyid, struct openpgp_publickey **publickey,
 	return (count > 0) ? 1 : 0;
 }
 
+/**
+*	delete_key - Given a keyid delete the key from storage.
+*	@keyid: The keyid to delete.
+*	@intrans: If we're already in a transaction.
+*
+*	This function deletes a public key from whatever storage mechanism we
+*	are using. Returns 0 if the key existed.
+*/
+static int keyd_delete_key(uint64_t keyid, bool intrans)
+{
+	int cmd = KEYD_CMD_DELETE;
+
+	write(keyd_fd, &cmd, sizeof(cmd));
+	read(keyd_fd, &cmd, sizeof(cmd));
+	if (cmd == KEYD_REPLY_OK) {
+		write(keyd_fd, &keyid, sizeof(keyid));
+	}
+
+	return 0;
+}
+
 /**
  *	store_key - Takes a key and stores it.
  *	@publickey: A pointer to the public key to store.
@@ -215,7 +236,7 @@ static int keyd_store_key(struct openpgp_publickey *publickey, bool intrans,
 	keyid = get_keyid(publickey);
 	
 	if (update) {
-		delete_key(keyid, false);
+		keyd_delete_key(keyid, false);
 	}
 
 	write(keyd_fd, &cmd, sizeof(cmd));
@@ -247,27 +268,6 @@ static int keyd_store_key(struct openpgp_publickey *publickey, bool intrans,
 	return 0;
 }
 
-/**
- *	delete_key - Given a keyid delete the key from storage.
- *	@keyid: The keyid to delete.
- *	@intrans: If we're already in a transaction.
- *
- *	This function deletes a public key from whatever storage mechanism we
- *	are using. Returns 0 if the key existed.
- */
-static int keyd_delete_key(uint64_t keyid, bool intrans)
-{
-	int cmd = KEYD_CMD_DELETE;
-
-	write(keyd_fd, &cmd, sizeof(cmd));
-	read(keyd_fd, &cmd, sizeof(cmd));
-	if (cmd == KEYD_REPLY_OK) {
-		write(keyd_fd, &keyid, sizeof(keyid));
-	}
-	
-	return 0;
-}
-
 /**
  *	fetch_key_text - Trys to find the keys that contain the supplied text.
  *	@search: The text to search for.