eet_cipher: Fix initialization of opened variable

In the error case we 'goto' the error path directly without passing
through the declaration and initialization of the variable.

This doesn't work so move the declaration/initialization to the start.
See this example (compile with -Wall for the warning):

-----
 #include <stdio.h>

 int main(void)
 {
   goto bar;

   int i = 15;

 bar:
   printf("Foo: %i\n", i);

   return 0;
 }
----

Signed-off-by: Daniel Willmann <d.willmann@samsung.com>
This commit is contained in:
Daniel Willmann 2013-03-19 16:28:37 +00:00
parent a32870c424
commit 1d8f06511c
1 changed files with 2 additions and 1 deletions

View File

@ -1070,6 +1070,7 @@ eet_decipher(const void *data,
unsigned int salt;
int tmp_len;
int tmp = 0;
int opened = 0;
/* At least the salt and an AES block */
if (size < sizeof(unsigned int) + 16)
@ -1129,7 +1130,6 @@ eet_decipher(const void *data,
# else /* ifdef HAVE_GNUTLS */
EVP_CIPHER_CTX ctx;
int opened = 0;
/* Openssl create the corresponding cipher */
EVP_CIPHER_CTX_init(&ctx);
@ -1178,6 +1178,7 @@ on_error:
memset(ik, 0, sizeof (ik));
# ifdef HAVE_GNUTLS
(void)opened;
# else
if (opened)
EVP_CIPHER_CTX_cleanup(&ctx);