From 3a4534d82682f69788da3cf4a445e38fbaf6b98e Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 1 Apr 2019 18:12:35 +0200 Subject: [PATCH] gpg: Remove unused arg in a card related function. * g10/call-agent.c (agent_scd_setattr): Remove unused arg serialno. Signed-off-by: Werner Koch --- g10/call-agent.c | 33 +++++++++++++++++---------------- g10/call-agent.h | 5 ++--- g10/card-util.c | 27 +++++++++++++-------------- g10/getkey.c | 2 +- 4 files changed, 33 insertions(+), 34 deletions(-) diff --git a/g10/call-agent.c b/g10/call-agent.c index 83777534e..797faf572 100644 --- a/g10/call-agent.c +++ b/g10/call-agent.c @@ -726,7 +726,10 @@ learn_status_cb (void *opaque, const char *line) return 0; } -/* Call the scdaemon to learn about a smartcard */ + +/* Call the scdaemon to learn about a smartcard. Note that in + * contradiction to the function's name, gpg-agent's LEARN command is + * used and not the low-level "SCD LEARN". */ int agent_scd_learn (struct agent_card_info_s *info, int force) { @@ -876,23 +879,21 @@ agent_scd_getattr (const char *name, struct agent_card_info_s *info) } -/* Send an setattr command to the SCdaemon. SERIALNO is not actually - used here but required by gpg 1.4's implementation of this code in - cardglue.c. */ -int -agent_scd_setattr (const char *name, - const unsigned char *value, size_t valuelen, - const char *serialno) +/* Send an setattr command to the SCdaemon. + * Used by: + * card-util.c + */ +gpg_error_t +agent_scd_setattr (const char *name, const void *value_arg, size_t valuelen) { - int rc; + gpg_error_t err; + const unsigned char *value = value_arg; char line[ASSUAN_LINELENGTH]; char *p; struct default_inq_parm_s parm; memset (&parm, 0, sizeof parm); - (void)serialno; - if (!*name || !valuelen) return gpg_error (GPG_ERR_INV_VALUE); @@ -918,16 +919,16 @@ agent_scd_setattr (const char *name, } *p = 0; - rc = start_agent (NULL, 1); - if (!rc) + err = start_agent (NULL, 1); + if (!err) { parm.ctx = agent_ctx; - rc = assuan_transact (agent_ctx, line, NULL, NULL, + err = assuan_transact (agent_ctx, line, NULL, NULL, default_inq_cb, &parm, NULL, NULL); } - status_sc_op_failure (rc); - return rc; + status_sc_op_failure (err); + return err; } diff --git a/g10/call-agent.h b/g10/call-agent.h index 8619a34f8..4c4fb2d4d 100644 --- a/g10/call-agent.h +++ b/g10/call-agent.h @@ -101,9 +101,8 @@ int agent_keytocard (const char *hexgrip, int keyno, int force, const char *serialno, const char *timestamp); /* Send a SETATTR command to the SCdaemon. */ -int agent_scd_setattr (const char *name, - const unsigned char *value, size_t valuelen, - const char *serialno); +gpg_error_t agent_scd_setattr (const char *name, + const void *value, size_t valuelen); /* Send a WRITECERT command to the SCdaemon. */ int agent_scd_writecert (const char *certidstr, diff --git a/g10/card-util.c b/g10/card-util.c index 08844bae3..f4054a9fd 100644 --- a/g10/card-util.c +++ b/g10/card-util.c @@ -816,7 +816,7 @@ change_name (void) return -1; } - rc = agent_scd_setattr ("DISP-NAME", isoname, strlen (isoname), NULL ); + rc = agent_scd_setattr ("DISP-NAME", isoname, strlen (isoname)); if (rc) log_error ("error setting Name: %s\n", gpg_strerror (rc)); @@ -837,7 +837,7 @@ change_url (void) trim_spaces (url); cpr_kill_prompt (); - rc = agent_scd_setattr ("PUBKEY-URL", url, strlen (url), NULL ); + rc = agent_scd_setattr ("PUBKEY-URL", url, strlen (url)); if (rc) log_error ("error setting URL: %s\n", gpg_strerror (rc)); xfree (url); @@ -995,7 +995,7 @@ change_login (const char *args) n = strlen (data); } - rc = agent_scd_setattr ("LOGIN-DATA", data, n, NULL ); + rc = agent_scd_setattr ("LOGIN-DATA", data, n); if (rc) log_error ("error setting login data: %s\n", gpg_strerror (rc)); xfree (data); @@ -1033,7 +1033,7 @@ change_private_do (const char *args, int nr) n = strlen (data); } - rc = agent_scd_setattr (do_name, data, n, NULL ); + rc = agent_scd_setattr (do_name, data, n); if (rc) log_error ("error setting private DO: %s\n", gpg_strerror (rc)); xfree (data); @@ -1132,7 +1132,7 @@ change_lang (void) return -1; } - rc = agent_scd_setattr ("DISP-LANG", data, strlen (data), NULL ); + rc = agent_scd_setattr ("DISP-LANG", data, strlen (data)); if (rc) log_error ("error setting lang: %s\n", gpg_strerror (rc)); xfree (data); @@ -1168,7 +1168,7 @@ change_sex (void) return -1; } - rc = agent_scd_setattr ("DISP-SEX", str, 1, NULL ); + rc = agent_scd_setattr ("DISP-SEX", str, 1); if (rc) log_error ("error setting salutation: %s\n", gpg_strerror (rc)); xfree (data); @@ -1216,7 +1216,7 @@ change_cafpr (int fprno) rc = agent_scd_setattr (fprno==1?"CA-FPR-1": fprno==2?"CA-FPR-2": - fprno==3?"CA-FPR-3":"x", fpr, fprlen, NULL ); + fprno==3?"CA-FPR-3":"x", fpr, fprlen); if (rc) log_error ("error setting cafpr: %s\n", gpg_strerror (rc)); write_sc_op_status (rc); @@ -1242,7 +1242,7 @@ toggle_forcesig (void) newstate = !info.chv1_cached; agent_release_card_info (&info); - rc = agent_scd_setattr ("CHV-STATUS-1", newstate? "\x01":"", 1, NULL); + rc = agent_scd_setattr ("CHV-STATUS-1", newstate? "\x01":"", 1); if (rc) log_error ("error toggling signature PIN flag: %s\n", gpg_strerror (rc)); write_sc_op_status (rc); @@ -1292,7 +1292,7 @@ check_pin_for_key_operation (struct agent_card_info_s *info, int *forced_chv1) { /* Switch off the forced mode so that during key generation we don't get bothered with PIN queries for each self-signature. */ - rc = agent_scd_setattr ("CHV-STATUS-1", "\x01", 1, info->serialno); + rc = agent_scd_setattr ("CHV-STATUS-1", "\x01", 1); if (rc) { log_error ("error clearing forced signature PIN flag: %s\n", @@ -1323,7 +1323,7 @@ restore_forced_chv1 (int *forced_chv1) if (*forced_chv1) { /* Switch back to forced state. */ - rc = agent_scd_setattr ("CHV-STATUS-1", "", 1, NULL); + rc = agent_scd_setattr ("CHV-STATUS-1", "", 1); if (rc) { log_error ("error setting forced signature PIN flag: %s\n", @@ -1570,7 +1570,7 @@ do_change_keyattr (int keyno, const struct key_attr *key_attr) return gpg_error (GPG_ERR_PUBKEY_ALGO); } - err = agent_scd_setattr ("KEY-ATTR", args, strlen (args), NULL); + err = agent_scd_setattr ("KEY-ATTR", args, strlen (args)); if (err) log_error (_("error changing key attribute for key %d: %s\n"), keyno+1, gpg_strerror (err)); @@ -2116,8 +2116,7 @@ kdf_setup (const char *args) goto leave_error; err = agent_scd_setattr ("KDF", kdf_data, - single ? KDF_DATA_LENGTH_MIN : KDF_DATA_LENGTH_MAX, - NULL); + single ? KDF_DATA_LENGTH_MIN : KDF_DATA_LENGTH_MAX); if (err) goto leave_error; @@ -2169,7 +2168,7 @@ uif (int arg_number, const char *arg_rest) data[1] = 0x20; - err = agent_scd_setattr (name, data, 2, NULL); + err = agent_scd_setattr (name, data, 2); if (err) log_error (_("error for setup UIF: %s\n"), gpg_strerror (err)); } diff --git a/g10/getkey.c b/g10/getkey.c index 9dae879d2..b15fbc13a 100644 --- a/g10/getkey.c +++ b/g10/getkey.c @@ -1315,7 +1315,7 @@ subkey_is_ok (const PKT_public_key *sub) /* Return true if KEYBLOCK has only expired encryption subkyes. Note * that the function returns false if the key has no encryption - * subkeys at all or the subkecys are revoked. */ + * subkeys at all or the subkeys are revoked. */ static int only_expired_enc_subkeys (kbnode_t keyblock) {