]> granicus.if.org Git - neomutt/commitdiff
drop unused param in pgp_make_key_attachment()
authorRichard Russon <rich@flatcap.org>
Tue, 12 Jun 2018 10:41:22 +0000 (11:41 +0100)
committerRichard Russon <rich@flatcap.org>
Tue, 12 Jun 2018 11:49:43 +0000 (12:49 +0100)
It was unused by any of the callers of the API wrapper:
crypt_pgp_make_key_attachment().

compose.c
ncrypt/crypt_gpgme.c
ncrypt/crypt_gpgme.h
ncrypt/crypt_mod.h
ncrypt/cryptglue.c
ncrypt/ncrypt.h
ncrypt/pgpkey.c
ncrypt/pgpkey.h
send.c

index 5a2c2be33568b4bf1e0fac6ada48ca7d70bd9a20..8522020d203585707e0921d1a581383b4f144a0c 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -1044,7 +1044,7 @@ int mutt_compose_menu(struct Header *msg, char *fcc, size_t fcclen,
         if (!(WithCrypto & APPLICATION_PGP))
           break;
         new = mutt_mem_calloc(1, sizeof(struct AttachPtr));
-        new->content = crypt_pgp_make_key_attachment(NULL);
+        new->content = crypt_pgp_make_key_attachment();
         if (new->content)
         {
           update_idx(menu, actx, new);
index b91a5d4fb701b2249edfeb0db93ed8ef30f1f6bd..d0cf1282d07030696046792b6b985f1b38d3b493 100644 (file)
@@ -640,24 +640,19 @@ static int data_object_to_stream(gpgme_data_t data, FILE *fp)
 /**
  * data_object_to_tempfile - Copy a data object to a temporary file
  *
- * The tempfile name may be optionally passed in.
  * If ret_fp is passed in, the file will be rewound, left open, and returned
  * via that parameter.
  * The tempfile name is returned, and must be freed.
  */
-static char *data_object_to_tempfile(gpgme_data_t data, char *tempf, FILE **ret_fp)
+static char *data_object_to_tempfile(gpgme_data_t data, FILE **ret_fp)
 {
   int err;
-  char tempfb[PATH_MAX];
+  char tempf[PATH_MAX];
   FILE *fp = NULL;
   ssize_t nread = 0;
 
-  if (!tempf)
-  {
-    mutt_mktemp(tempfb, sizeof(tempfb));
-    tempf = tempfb;
-  }
-  fp = mutt_file_fopen(tempf, tempf == tempfb ? "w+" : "a+");
+  mutt_mktemp(tempf, sizeof(tempf));
+  fp = mutt_file_fopen(tempf, "w+");
   if (!fp)
   {
     mutt_perror(_("Can't create temporary file"));
@@ -906,7 +901,7 @@ static char *encrypt_gpgme_object(gpgme_data_t plaintext, gpgme_key_t *rset,
 
   gpgme_release(ctx);
 
-  outfile = data_object_to_tempfile(ciphertext, NULL, NULL);
+  outfile = data_object_to_tempfile(ciphertext, NULL);
   gpgme_data_release(ciphertext);
   return outfile;
 }
@@ -1038,7 +1033,7 @@ static struct Body *sign_message(struct Body *a, int use_smime)
     return NULL;
   }
 
-  sigfile = data_object_to_tempfile(signature, NULL, NULL);
+  sigfile = data_object_to_tempfile(signature, NULL);
   gpgme_data_release(signature);
   if (!sigfile)
   {
@@ -2404,7 +2399,7 @@ static void copy_clearsigned(gpgme_data_t data, struct State *s, char *charset)
   bool complete, armor_header;
   FILE *fp = NULL;
 
-  char *fname = data_object_to_tempfile(data, NULL, &fp);
+  char *fname = data_object_to_tempfile(data, &fp);
   if (!fname)
   {
     mutt_file_fclose(&fp);
@@ -2599,7 +2594,7 @@ int pgp_gpgme_application_handler(struct Body *m, struct State *s)
                               s);
           }
 
-          tmpfname = data_object_to_tempfile(plaintext, NULL, &pgpout);
+          tmpfname = data_object_to_tempfile(plaintext, &pgpout);
           if (!tmpfname)
           {
             mutt_file_fclose(&pgpout);
@@ -4747,7 +4742,7 @@ char *smime_gpgme_find_keys(struct Address *addrlist, bool oppenc_mode)
 /**
  * pgp_gpgme_make_key_attachment - Implements CryptModuleSpecs::pgp_make_key_attachment()
  */
-struct Body *pgp_gpgme_make_key_attachment(char *tempf)
+struct Body *pgp_gpgme_make_key_attachment(void)
 {
 #ifdef HAVE_GPGME_OP_EXPORT_KEYS
   gpgme_ctx_t context = NULL;
@@ -4777,7 +4772,7 @@ struct Body *pgp_gpgme_make_key_attachment(char *tempf)
     goto bail;
   }
 
-  tempf = data_object_to_tempfile(keydata, tempf, NULL);
+  char *tempf = data_object_to_tempfile(keydata, NULL);
   if (!tempf)
     goto bail;
 
index ab263368d82ce660d3d279546422349470b0fc74..e095616cde2163ee57cc2a5836cfab28e8b6525c 100644 (file)
@@ -41,7 +41,7 @@ struct Body *pgp_gpgme_encrypt_message(struct Body *a, char *keylist, int sign);
 char *       pgp_gpgme_find_keys(struct Address *addrlist, bool oppenc_mode);
 void         pgp_gpgme_init(void);
 void         pgp_gpgme_invoke_import(const char *fname);
-struct Body *pgp_gpgme_make_key_attachment(char *tempf);
+struct Body *pgp_gpgme_make_key_attachment(void);
 int          pgp_gpgme_send_menu(struct Header *msg);
 struct Body *pgp_gpgme_sign_message(struct Body *a);
 int          pgp_gpgme_verify_one(struct Body *sigbdy, struct State *s, const char *tempfile);
index 3260160d45bb9f93a182decd94f515666ad22c65..41b7e8bb4c311a9690c178be65de0c9c6aa4a812 100644 (file)
@@ -136,11 +136,10 @@ struct CryptModuleSpecs
   struct Body *(*pgp_encrypt_message)(struct Body *a, char *keylist, int sign);
   /**
    * pgp_make_key_attachment - Generate a public key attachment
-   * @param tempf Filename to use (OPTIONAL)
    * @retval ptr  New Body containing the attachment
    * @retval NULL Error
    */
-  struct Body *(*pgp_make_key_attachment)(char *tempf);
+  struct Body *(*pgp_make_key_attachment)(void);
   /**
    * pgp_check_traditional - Look for inline (non-MIME) PGP content
    * @param fp       File pointer to the current attachment
index a57d839748b23b843d6bdcc1ea44a50f5d3301aa..3aa0de5098db3f0f23eb79aa08cbffc98f4ec6c1 100644 (file)
@@ -250,10 +250,10 @@ struct Body *crypt_pgp_traditional_encryptsign(struct Body *a, int flags, char *
 /**
  * crypt_pgp_make_key_attachment - Wrapper for CryptModuleSpecs::pgp_make_key_attachment()
  */
-struct Body *crypt_pgp_make_key_attachment(char *tempf)
+struct Body *crypt_pgp_make_key_attachment(void)
 {
   if (CRYPT_MOD_CALL_CHECK(PGP, pgp_make_key_attachment))
-    return (CRYPT_MOD_CALL(PGP, pgp_make_key_attachment))(tempf);
+    return (CRYPT_MOD_CALL(PGP, pgp_make_key_attachment))();
 
   return NULL;
 }
index 9a269f800c6db2e10cae27d0eb312db94af28ea4..1351bd3de0e60a1bbcb0e54ffa7a9c053e6f2620 100644 (file)
@@ -148,7 +148,7 @@ int          crypt_pgp_decrypt_mime(FILE *a, FILE **b, struct Body *c, struct Bo
 int          crypt_pgp_encrypted_handler(struct Body *a, struct State *s);
 void         crypt_pgp_extract_keys_from_attachment_list(FILE *fp, int tag, struct Body *top);
 void         crypt_pgp_invoke_getkeys(struct Address *addr);
-struct Body *crypt_pgp_make_key_attachment(char *tempf);
+struct Body *crypt_pgp_make_key_attachment(void);
 int          crypt_pgp_send_menu(struct Header *msg);
 int          crypt_smime_application_handler(struct Body *m, struct State *s);
 int          crypt_smime_decrypt_mime(FILE *a, FILE **b, struct Body *c, struct Body **d);
index c66960ae737b6f4b6407bbfbbd8c324a35e81adf..ebf4f7bea0ba67f6b967406faf11f0301fd1a5cf 100644 (file)
@@ -742,11 +742,11 @@ struct PgpKeyInfo *pgp_ask_for_key(char *tag, char *whatfor, short abilities, en
 /**
  * pgp_class_make_key_attachment - Implements CryptModuleSpecs::pgp_make_key_attachment()
  */
-struct Body *pgp_class_make_key_attachment(char *tempf)
+struct Body *pgp_class_make_key_attachment(void)
 {
   struct Body *att = NULL;
   char buf[LONG_STRING];
-  char tempfb[PATH_MAX], tmp[STRING];
+  char tempf[PATH_MAX], tmp[STRING];
   FILE *tempfp = NULL;
   FILE *devnull = NULL;
   struct stat sb;
@@ -762,13 +762,9 @@ struct Body *pgp_class_make_key_attachment(char *tempf)
   snprintf(tmp, sizeof(tmp), "0x%s", pgp_fpr_or_lkeyid(pgp_principal_key(key)));
   pgp_free_key(&key);
 
-  if (!tempf)
-  {
-    mutt_mktemp(tempfb, sizeof(tempfb));
-    tempf = tempfb;
-  }
+  mutt_mktemp(tempf, sizeof(tempf));
 
-  tempfp = mutt_file_fopen(tempf, tempf == tempfb ? "w" : "a");
+  tempfp = mutt_file_fopen(tempf, "w");
   if (!tempfp)
   {
     mutt_perror(_("Can't create temporary file"));
@@ -780,8 +776,7 @@ struct Body *pgp_class_make_key_attachment(char *tempf)
   {
     mutt_perror(_("Can't open /dev/null"));
     mutt_file_fclose(&tempfp);
-    if (tempf == tempfb)
-      unlink(tempf);
+    unlink(tempf);
     return NULL;
   }
 
index 2ec2e29c7df2e87b26589f9489fadfbe3847048b..bcdcfa8f9a1643fa620bacb3d6e2a152f68fd569 100644 (file)
@@ -36,7 +36,7 @@ enum PgpRing
   PGP_SECRING, /**< Secret keys */
 };
 
-struct Body *pgp_class_make_key_attachment(char *tempf);
+struct Body *pgp_class_make_key_attachment(void);
 
 struct PgpKeyInfo *pgp_ask_for_key(char *tag, char *whatfor, short abilities, enum PgpRing keyring);
 struct PgpKeyInfo *pgp_getkeybyaddr(struct Address *a, short abilities, enum PgpRing keyring, bool oppenc_mode);
diff --git a/send.c b/send.c
index 38647ff2d264819fa673c3570ef40a2b7b36de66..d697a8165faa87f565ce9861db097746d0b25a88 100644 (file)
--- a/send.c
+++ b/send.c
@@ -919,7 +919,7 @@ static int generate_body(FILE *tempfp, struct Header *msg, int flags,
     struct Body *b = NULL;
 
     if (((WithCrypto & APPLICATION_PGP) != 0) &&
-        (b = crypt_pgp_make_key_attachment(NULL)) == NULL)
+        (b = crypt_pgp_make_key_attachment()) == NULL)
     {
       return -1;
     }