STORE: simplify store_loader_cmp()
authorRichard Levitte <levitte@openssl.org>
Thu, 29 Jun 2017 19:46:02 +0000 (21:46 +0200)
committerRichard Levitte <levitte@openssl.org>
Thu, 29 Jun 2017 19:48:12 +0000 (21:48 +0200)
We have already made sure that the loader scheme isn't NULL, so
checking if they are NULL or not when comparing registered loaders
is redundant.  We still soft assert it, just to be entirely sure.

Reviewed-by: Ben Kaduk <kaduk@mit.edu>
(Merged from https://github.com/openssl/openssl/pull/3805)

crypto/store/store_register.c

index bde190e78eb7af15765266cfdd402f63820e9b93..c7feec39d6085be5db91f72a875e5194d664b847 100644 (file)
@@ -123,11 +123,8 @@ static unsigned long store_loader_hash(const OSSL_STORE_LOADER *v)
 static int store_loader_cmp(const OSSL_STORE_LOADER *a,
                             const OSSL_STORE_LOADER *b)
 {
-    if (a->scheme != NULL && b->scheme != NULL)
-        return strcmp(a->scheme, b->scheme);
-    else if (a->scheme == b->scheme)
-        return 0;
-    return a->scheme == NULL ? -1 : 1;
+    assert(a->scheme != NULL && b->scheme != NULL);
+    return strcmp(a->scheme, b->scheme);
 }
 
 static LHASH_OF(OSSL_STORE_LOADER) *loader_register = NULL;