From 816bee1fa0d833ac72ea4e7d52465e6e1da2645d Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 10 Aug 2011 14:11:30 +0200 Subject: [PATCH] Fixed set but unused variable bugs --- agent/ChangeLog | 8 ++++++++ agent/command-ssh.c | 2 -- agent/genkey.c | 4 ++-- agent/gpg-agent.c | 3 +-- common/ChangeLog | 10 ++++++++++ common/estream.c | 6 ++---- common/pka.c | 4 +--- common/signal.c | 16 +++++++--------- common/t-exechelp.c | 11 +++++------ common/t-timestuff.c | 3 +-- g10/ChangeLog | 11 +++++++++++ g10/build-packet.c | 24 ++++++++++++------------ g10/export.c | 26 +++++++++++++------------- g10/import.c | 2 +- g10/keyedit.c | 2 -- g10/sig-check.c | 3 --- kbx/keybox-openpgp.c | 9 +-------- scd/apdu.c | 3 +-- scd/pcsc-wrapper.c | 3 +-- scd/scdaemon.c | 3 +-- sm/ChangeLog | 6 ++++++ sm/gpgsm.c | 3 --- sm/keydb.c | 2 -- 23 files changed, 84 insertions(+), 80 deletions(-) diff --git a/agent/ChangeLog b/agent/ChangeLog index b4a333a71..ec2dca219 100644 --- a/agent/ChangeLog +++ b/agent/ChangeLog @@ -1,3 +1,11 @@ +2011-08-10 Werner Koch + + * genkey.c (check_passphrase_pattern): Use gpg_strerror instead of + strerror. + * command-ssh.c (ssh_receive_mpint_list): Remove unused var + ELEMS_PUBLIC_N. + * gpg-agent.c (main): Remove unused var MAY_COREDUMP. + 2011-08-09 Ben Kibbey * command.c (option_handler): Have option s2k-count match the diff --git a/agent/command-ssh.c b/agent/command-ssh.c index ae193ec94..7b4d47924 100644 --- a/agent/command-ssh.c +++ b/agent/command-ssh.c @@ -933,7 +933,6 @@ static gpg_error_t ssh_receive_mpint_list (estream_t stream, int secret, ssh_key_type_spec_t key_spec, gcry_mpi_t **mpi_list) { - unsigned int elems_public_n; const char *elems_public; unsigned int elems_n; const char *elems; @@ -952,7 +951,6 @@ ssh_receive_mpint_list (estream_t stream, int secret, elems_n = strlen (elems); elems_public = key_spec.elems_key_public; - elems_public_n = strlen (elems_public); mpis = xtrycalloc (elems_n + 1, sizeof *mpis ); if (!mpis) diff --git a/agent/genkey.c b/agent/genkey.c index e01a7bcb6..09f1c72aa 100644 --- a/agent/genkey.c +++ b/agent/genkey.c @@ -106,7 +106,7 @@ check_passphrase_pattern (ctrl_t ctrl, const char *pw) if (!infp) { err = gpg_error_from_syserror (); - log_error (_("error creating temporary file: %s\n"), strerror (errno)); + log_error (_("error creating temporary file: %s\n"), gpg_strerror (err)); return 1; /* Error - assume password should not be used. */ } @@ -114,7 +114,7 @@ check_passphrase_pattern (ctrl_t ctrl, const char *pw) { err = gpg_error_from_syserror (); log_error (_("error writing to temporary file: %s\n"), - strerror (errno)); + gpg_strerror (err)); fclose (infp); return 1; /* Error - assume password should not be used. */ } diff --git a/agent/gpg-agent.c b/agent/gpg-agent.c index a5486647e..061687550 100644 --- a/agent/gpg-agent.c +++ b/agent/gpg-agent.c @@ -568,7 +568,6 @@ main (int argc, char **argv ) { ARGPARSE_ARGS pargs; int orig_argc; - int may_coredump; char **orig_argv; FILE *configfp = NULL; char *configname = NULL; @@ -642,7 +641,7 @@ main (int argc, char **argv ) setup_libgcrypt_logging (); gcry_control (GCRYCTL_USE_SECURE_RNDPOOL); - may_coredump = disable_core_dumps (); + disable_core_dumps (); /* Set default options. */ parse_rereadable_options (NULL, 0); /* Reset them to default values. */ diff --git a/common/ChangeLog b/common/ChangeLog index c56bc4d8f..95aef653c 100644 --- a/common/ChangeLog +++ b/common/ChangeLog @@ -1,3 +1,13 @@ +2011-08-10 Werner Koch + + * t-exechelp.c (test_close_all_fds): Don't use the DUMMY_FD var. + + * pka.c (get_pka_info): Remove unused var. + + * signal.c (got_fatal_signal): Remove unused var. + + * estream.c (es_fread, es_fwrite): Remove unused var. + 2011-07-20 Werner Koch * ssh-utils.c, ssh-utils.h: New. diff --git a/common/estream.c b/common/estream.c index 5b5567426..8087a6287 100644 --- a/common/estream.c +++ b/common/estream.c @@ -3425,12 +3425,11 @@ es_fread (void *ES__RESTRICT ptr, size_t size, size_t nitems, estream_t ES__RESTRICT stream) { size_t ret, bytes; - int err; if (size * nitems) { ESTREAM_LOCK (stream); - err = es_readn (stream, ptr, size * nitems, &bytes); + es_readn (stream, ptr, size * nitems, &bytes); ESTREAM_UNLOCK (stream); ret = bytes / size; @@ -3447,12 +3446,11 @@ es_fwrite (const void *ES__RESTRICT ptr, size_t size, size_t nitems, estream_t ES__RESTRICT stream) { size_t ret, bytes; - int err; if (size * nitems) { ESTREAM_LOCK (stream); - err = es_writen (stream, ptr, size * nitems, &bytes); + es_writen (stream, ptr, size * nitems, &bytes); ESTREAM_UNLOCK (stream); ret = bytes / size; diff --git a/common/pka.c b/common/pka.c index 7ac70d9c4..89761f5a5 100644 --- a/common/pka.c +++ b/common/pka.c @@ -175,7 +175,7 @@ get_pka_info (const char *address, unsigned char *fpr) #else /*!USE_ADNS*/ unsigned char answer[PACKETSZ]; int anslen; - int qdcount, ancount, nscount, arcount; + int qdcount, ancount; int rc; unsigned char *p, *pend; const char *domain; @@ -212,8 +212,6 @@ get_pka_info (const char *address, unsigned char *fpr) qdcount = ntohs (header.qdcount); ancount = ntohs (header.ancount); - nscount = ntohs (header.nscount); - arcount = ntohs (header.arcount); if (!ancount) return NULL; /* Got no answer. */ diff --git a/common/signal.c b/common/signal.c index 9f11b9922..28b2acc2e 100644 --- a/common/signal.c +++ b/common/signal.c @@ -89,8 +89,6 @@ get_signal_name( int signum ) static RETSIGTYPE got_fatal_signal (int sig) { - /* Dummy result variable to suppress gcc warning. */ - int res; const char *s; if (caught_fatal_sig) @@ -100,14 +98,14 @@ got_fatal_signal (int sig) if (cleanup_fnc) cleanup_fnc (); /* Better don't translate these messages. */ - res = write (2, "\n", 1 ); + (void)write (2, "\n", 1 ); s = log_get_prefix (NULL); if (s) - res = write(2, s, strlen (s)); - res = write (2, ": signal ", 9 ); + (void)write(2, s, strlen (s)); + (void)write (2, ": signal ", 9 ); s = get_signal_name(sig); if (s) - res = write (2, s, strlen(s) ); + (void) write (2, s, strlen(s) ); else { /* We are in a signal handler so we can't use any kind of printf @@ -117,7 +115,7 @@ got_fatal_signal (int sig) things are messed up because we modify its value. Although this is a bug in that system, we will protect against it. */ if (sig < 0 || sig >= 100000) - res = write (2, "?", 1); + (void)write (2, "?", 1); else { int i, value, any=0; @@ -126,7 +124,7 @@ got_fatal_signal (int sig) { if (value >= i || ((any || i==1) && !(value/i))) { - res = write (2, "0123456789"+(value/i), 1); + (void)write (2, "0123456789"+(value/i), 1); if ((value/i)) any = 1; value %= i; @@ -134,7 +132,7 @@ got_fatal_signal (int sig) } } } - res = write (2, " caught ... exiting\n", 20); + (void)write (2, " caught ... exiting\n", 20); /* Reset action to default action and raise signal again */ init_one_signal (sig, SIG_DFL, 0); diff --git a/common/t-exechelp.c b/common/t-exechelp.c index e4c88d126..19079d331 100644 --- a/common/t-exechelp.c +++ b/common/t-exechelp.c @@ -76,7 +76,6 @@ test_close_all_fds (void) int max_fd = get_max_fds (); int *array; int fd; - int dummy_fd; int initial_count, count, n; #if 0 char buffer[100]; @@ -93,10 +92,10 @@ test_close_all_fds (void) free (array); /* Some dups to get more file descriptors and close one. */ - dummy_fd = dup (1); - dummy_fd = dup (1); + dup (1); + dup (1); fd = dup (1); - dummy_fd = dup (1); + dup (1); close (fd); array = xget_all_open_fds (); @@ -137,14 +136,14 @@ test_close_all_fds (void) int except[] = { 20, 23, 24, -1 }; for (n=initial_count; n < 31; n++) - dummy_fd = dup (1); + dup (1); array = xget_all_open_fds (); if (verbose) print_open_fds (array); free (array); for (n=0; n < 5; n++) { - dummy_fd = dup (1); + dup (1); array = xget_all_open_fds (); if (verbose) print_open_fds (array); diff --git a/common/t-timestuff.c b/common/t-timestuff.c index c9c8fe5b8..8e5fa65ee 100644 --- a/common/t-timestuff.c +++ b/common/t-timestuff.c @@ -81,10 +81,9 @@ test_timegm (void) }; int tidx; - time_t now, atime, counter; + time_t now, atime; struct tm tbuf, tbuf2, *tp; - counter = 0; for (tidx=0; tidx < DIM (tvalues); tidx++) { if (tvalues[tidx].year == -1) diff --git a/g10/ChangeLog b/g10/ChangeLog index 6de122fb8..8ab0db53d 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,14 @@ +2011-08-10 Werner Koch + + * export.c (transfer_format_to_openpgp): Don't parse unneeded CSUM. + + * import.c (import_secret_one): Use arg OPTIONS instead of global + import options var. + + * sig-check.c (do_check): Remove unused var CTX. + + * build-packet.c (do_user_id): Return value. + 2011-07-29 Werner Koch * tdbio.c (open_db): Do not print read-only warning in quiet mode. diff --git a/g10/build-packet.c b/g10/build-packet.c index f2ef69161..159b783ed 100644 --- a/g10/build-packet.c +++ b/g10/build-packet.c @@ -242,19 +242,19 @@ write_fake_data (IOBUF out, gcry_mpi_t a) static int do_user_id( IOBUF out, int ctb, PKT_user_id *uid ) { - int rc; + int rc; - if( uid->attrib_data ) - { - write_header(out, ctb, uid->attrib_len); - rc = iobuf_write( out, uid->attrib_data, uid->attrib_len ); - } - else - { - write_header2( out, ctb, uid->len, 2 ); - rc = iobuf_write( out, uid->name, uid->len ); - } - return 0; + if (uid->attrib_data) + { + write_header(out, ctb, uid->attrib_len); + rc = iobuf_write( out, uid->attrib_data, uid->attrib_len ); + } + else + { + write_header2( out, ctb, uid->len, 2 ); + rc = iobuf_write( out, uid->name, uid->len ); + } + return rc; } diff --git a/g10/export.c b/g10/export.c index 1b575dd9e..7deee6b02 100644 --- a/g10/export.c +++ b/g10/export.c @@ -377,7 +377,6 @@ transfer_format_to_openpgp (gcry_sexp_t s_pgp, PKT_public_key *pk) u32 s2k_count = 0; size_t npkey, nskey; gcry_mpi_t skey[10]; /* We support up to 9 parameters. */ - u16 desired_csum; int skeyidx = 0; struct seckey_info *ski; @@ -509,20 +508,21 @@ transfer_format_to_openpgp (gcry_sexp_t s_pgp, PKT_public_key *pk) skey[skeyidx++] = NULL; gcry_sexp_release (list); - list = gcry_sexp_find_token (top_list, "csum", 0); - if (list) - { - string = gcry_sexp_nth_string (list, 1); - if (!string) - goto bad_seckey; - desired_csum = strtoul (string, NULL, 10); - xfree (string); - } - else - desired_csum = 0; + /* We have no need for the CSUM valuel thus we don't parse it. */ + /* list = gcry_sexp_find_token (top_list, "csum", 0); */ + /* if (list) */ + /* { */ + /* string = gcry_sexp_nth_string (list, 1); */ + /* if (!string) */ + /* goto bad_seckey; */ + /* desired_csum = strtoul (string, NULL, 10); */ + /* xfree (string); */ + /* } */ + /* else */ + /* desired_csum = 0; */ + /* gcry_sexp_release (list); list = NULL; */ - gcry_sexp_release (list); list = NULL; gcry_sexp_release (top_list); top_list = NULL; /* log_debug ("XXX is_v4=%d\n", is_v4); */ diff --git a/g10/import.c b/g10/import.c index ffbcf168f..b48f12636 100644 --- a/g10/import.c +++ b/g10/import.c @@ -1596,7 +1596,7 @@ import_secret_one (ctrl_t ctrl, const char *fname, KBNODE keyblock, public key block, and below we will output another one for the secret keys. FIXME? */ import_one (ctrl, fname, pub_keyblock, stats, - NULL, NULL, opt.import_options, 1); + NULL, NULL, options, 1); /* Fixme: We should check for an invalid keyblock and cancel the secret key import in this case. */ diff --git a/g10/keyedit.c b/g10/keyedit.c index 973fa8d3f..62b193a81 100644 --- a/g10/keyedit.c +++ b/g10/keyedit.c @@ -2683,7 +2683,6 @@ show_key_with_all_names (KBNODE keyblock, int only_marked, int with_revoker, KBNODE node; int i; int do_warn = 0; - byte pk_version = 0; PKT_public_key *primary = NULL; if (opt.with_colons) @@ -2719,7 +2718,6 @@ show_key_with_all_names (KBNODE keyblock, int only_marked, int with_revoker, do_warn = 1; } - pk_version = pk->version; primary = pk; } diff --git a/g10/sig-check.c b/g10/sig-check.c index 531497e81..134bcfa90 100644 --- a/g10/sig-check.c +++ b/g10/sig-check.c @@ -263,7 +263,6 @@ do_check( PKT_public_key *pk, PKT_signature *sig, gcry_md_hd_t digest, { gcry_mpi_t result = NULL; int rc = 0; - struct cmp_help_context_s ctx; if( (rc=do_check_messages(pk,sig,r_expired,r_revoked)) ) return rc; @@ -316,8 +315,6 @@ do_check( PKT_public_key *pk, PKT_signature *sig, gcry_md_hd_t digest, result = encode_md_value (pk, digest, sig->digest_algo ); if (!result) return G10ERR_GENERAL; - ctx.sig = sig; - ctx.md = digest; rc = pk_verify( pk->pubkey_algo, result, sig->data, pk->pkey ); gcry_mpi_release (result); diff --git a/kbx/keybox-openpgp.c b/kbx/keybox-openpgp.c index 4306ed1b0..37e2771a8 100644 --- a/kbx/keybox-openpgp.c +++ b/kbx/keybox-openpgp.c @@ -170,7 +170,6 @@ parse_key (const unsigned char *data, size_t datalen, const unsigned char *data_start = data; int i, version, algorithm; size_t n; - unsigned long timestamp, expiredate; int npkey; unsigned char hashbuffer[768]; const unsigned char *mpi_n = NULL; @@ -184,21 +183,15 @@ parse_key (const unsigned char *data, size_t datalen, if (version < 2 || version > 4 ) return gpg_error (GPG_ERR_INV_PACKET); /* Invalid version. */ - timestamp = ((data[0]<<24)|(data[1]<<16)|(data[2]<<8)|(data[3])); + /*timestamp = ((data[0]<<24)|(data[1]<<16)|(data[2]<<8)|(data[3]));*/ data +=4; datalen -=4; if (version < 4) { - unsigned short ndays; - if (datalen < 2) return gpg_error (GPG_ERR_INV_PACKET); - ndays = ((data[0]<<8)|(data[1])); data +=2; datalen -= 2; - expiredate = ndays? (timestamp + ndays * 86400L) : 0; } - else - expiredate = 0; /* This is stored in the self-signature. */ if (!datalen) return gpg_error (GPG_ERR_INV_PACKET); diff --git a/scd/apdu.c b/scd/apdu.c index 176ab914b..ac563adef 100644 --- a/scd/apdu.c +++ b/scd/apdu.c @@ -1602,7 +1602,7 @@ open_pcsc_reader_wrapped (const char *portstr) unsigned char msgbuf[9]; int err; unsigned int dummy_status; - int sw = SW_HOST_CARD_IO_ERROR; + /* Note that we use the constant and not the fucntion because this code won't be be used under Windows. */ const char *wrapperpgm = GNUPG_LIBEXECDIR "/gnupg-pcsc-wrapper"; @@ -1746,7 +1746,6 @@ open_pcsc_reader_wrapped (const char *portstr) if (err) { log_error ("PC/SC OPEN failed: %s\n", pcsc_error_string (err)); - sw = pcsc_error_to_sw (err); goto command_failed; } diff --git a/scd/pcsc-wrapper.c b/scd/pcsc-wrapper.c index f2f6d52bc..ee974ac7b 100644 --- a/scd/pcsc-wrapper.c +++ b/scd/pcsc-wrapper.c @@ -384,7 +384,7 @@ handle_open (unsigned char *argbuf, size_t arglen) long err; const char * portstr; char *list = NULL; - unsigned long nreader, listlen, atrlen; + unsigned long nreader, atrlen; char *p; unsigned long card_state, card_protocol; unsigned char atr[33]; @@ -431,7 +431,6 @@ handle_open (unsigned char *argbuf, size_t arglen) return; } - listlen = nreader; p = list; while (nreader) { diff --git a/scd/scdaemon.c b/scd/scdaemon.c index 57023958a..0999847ef 100644 --- a/scd/scdaemon.c +++ b/scd/scdaemon.c @@ -375,7 +375,6 @@ main (int argc, char **argv ) ARGPARSE_ARGS pargs; int orig_argc; gpg_error_t err; - int may_coredump; char **orig_argv; FILE *configfp = NULL; char *configname = NULL; @@ -442,7 +441,7 @@ main (int argc, char **argv ) setup_libgcrypt_logging (); gcry_control (GCRYCTL_USE_SECURE_RNDPOOL); - may_coredump = disable_core_dumps (); + disable_core_dumps (); /* Set default options. */ opt.allow_admin = 1; diff --git a/sm/ChangeLog b/sm/ChangeLog index 9e6d92ffd..aee3efcf0 100644 --- a/sm/ChangeLog +++ b/sm/ChangeLog @@ -1,3 +1,9 @@ +2011-08-10 Werner Koch + + * keydb.c (keydb_add_resource): Remove unsued var CREATED_FNAME. + + * gpgsm.c (main): Remove unused var FNAME. + 2011-07-21 Werner Koch * call-dirmngr.c (get_cached_cert, get_cached_cert_data_cb): New. diff --git a/sm/gpgsm.c b/sm/gpgsm.c index c6732fce9..f08e0f80f 100644 --- a/sm/gpgsm.c +++ b/sm/gpgsm.c @@ -862,7 +862,6 @@ main ( int argc, char **argv) ARGPARSE_ARGS pargs; int orig_argc; char **orig_argv; - const char *fname; /* char *username;*/ int may_coredump; strlist_t sl, remusr= NULL, locusr=NULL; @@ -1635,8 +1634,6 @@ main ( int argc, char **argv) if (log_get_errorcount(0)) gpgsm_exit(1); /* Must stop for invalid recipients. */ - fname = argc? *argv : NULL; - /* Dispatch command. */ switch (cmd) { diff --git a/sm/keydb.c b/sm/keydb.c index d3b911efd..fe5d0e741 100644 --- a/sm/keydb.c +++ b/sm/keydb.c @@ -82,7 +82,6 @@ keydb_add_resource (const char *url, int force, int secret, int *auto_created) int rc = 0; FILE *fp; KeydbResourceType rt = KEYDB_RESOURCE_TYPE_NONE; - const char *created_fname = NULL; if (auto_created) *auto_created = 0; @@ -194,7 +193,6 @@ keydb_add_resource (const char *url, int force, int secret, int *auto_created) if (!opt.quiet) log_info (_("keybox `%s' created\n"), filename); - created_fname = filename; if (auto_created) *auto_created = 1; }