Move MODP_CUSTOM va_arg fetching out of loop
authorMartin Willi <martin@revosec.ch>
Thu, 2 Aug 2012 10:06:51 +0000 (12:06 +0200)
committerMartin Willi <martin@revosec.ch>
Thu, 2 Aug 2012 10:08:27 +0000 (12:08 +0200)
It seems problematic at least on PPC with gcc 4.3, fixes #208.

src/libstrongswan/crypto/crypto_factory.c

index d368ae3..58118d9 100644 (file)
@@ -359,29 +359,25 @@ METHOD(crypto_factory_t, create_dh, diffie_hellman_t*,
 {
        enumerator_t *enumerator;
        entry_t *entry;
+       va_list args;
+       chunk_t g, p;
        diffie_hellman_t *diffie_hellman = NULL;
 
+       if (group == MODP_CUSTOM)
+       {
+               va_start(args, group);
+               g = va_arg(args, chunk_t);
+               p = va_arg(args, chunk_t);
+               va_end(args);
+       }
+
        this->lock->read_lock(this->lock);
        enumerator = this->dhs->create_enumerator(this->dhs);
        while (enumerator->enumerate(enumerator, &entry))
        {
                if (entry->algo == group)
                {
-                       if (group == MODP_CUSTOM)
-                       {
-                               va_list args;
-                               chunk_t g, p;
-
-                               va_start(args, group);
-                               g = va_arg(args, chunk_t);
-                               p = va_arg(args, chunk_t);
-                               va_end(args);
-                               diffie_hellman = entry->create_dh(MODP_CUSTOM, g, p);
-                       }
-                       else
-                       {
-                               diffie_hellman = entry->create_dh(group);
-                       }
+                       diffie_hellman = entry->create_dh(group, g, p);
                        if (diffie_hellman)
                        {
                                break;