gpgme-1.0.3: local variable used before set
bob.dunlop at xyzzy.org.uk
Thu Sep 21 09:05:52 CEST 2006
On Wed, Sep 20 at 05:53, Ales Nosek wrote:
> David Binderman wrote:
> I just tried to compile package gpgme-1.0.3-9 with the Intel C compiler.
> It said
> keylist.c(370): warning #592: variable "key" is used before its value is set
> The source code is
> DEBUG3 ("keylist_colon_handler ctx = %p, key = %p, line = %s\n",
> ctx, key, line ? line : "(null)");
> I agree with the compiler. Suggest initialise local variable "key"
> before first use.
I agree with the comiler and the error also, but I don't think I agree
with your fix.
Key is uninitialised at this point and isi in fact initialised 8 lines
key = opd->tmp_key;
Your nulling of the variable is spurious in the non-debug case and the
displaying of the value by the DEBUG statement is misleading. It implies
that the value has a use at this point. Better in my opinion to remove
the display of the spurious key value from the DEBUG statement.
--- keylist.c-orig 2004-12-07 20:42:12.000000000 +0000
+++ keylist.c 2006-09-21 07:55:59.000000000 +0100
@@ -367,8 +367,8 @@
gpgme_subkey_t subkey = NULL;
gpgme_key_sig_t keysig = NULL;
- DEBUG3 ("keylist_colon_handler ctx = %p, key = %p, line = %s\n",
- ctx, key, line ? line : "(null)");
+ DEBUG2 ("keylist_colon_handler ctx = %p, line = %s\n",
+ ctx, line ? line : "(null)");
err = _gpgme_op_data_lookup (ctx, OPDATA_KEYLIST, &hook, -1, NULL);
opd = hook;
More information about the Gnupg-devel