]> granicus.if.org Git - openssl/commitdiff
Use enum for X509_LOOKUP_TYPE
authorRich Salz <rsalz@akamai.com>
Tue, 26 May 2015 19:42:01 +0000 (15:42 -0400)
committerRich Salz <rsalz@openssl.org>
Thu, 28 May 2015 16:54:27 +0000 (12:54 -0400)
Using an enum with -Wswitch means all lookup routines handle
all cases.  Remove X509_LU_PKEY which was never used.

Reviewed-by: Richard Levitte <levitte@openssl.org>
crypto/x509/by_dir.c
crypto/x509/x509_lu.c
include/openssl/x509_vfy.h

index ffd101c00f9b3cc983c3f0cb250e244b5a56e00a..cc91db84bc850d5bf814a9a01cae7304e80124a1 100644 (file)
@@ -247,8 +247,8 @@ static int add_cert_dir(BY_DIR *ctx, const char *dir, int type)
     return 1;
 }
 
-static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
-                               X509_OBJECT *ret)
+static int get_cert_by_subject(X509_LOOKUP *xl, X509_LOOKUP_TYPE type,
+                               X509_NAME *name, X509_OBJECT *ret)
 {
     BY_DIR *ctx;
     union {
index 20862253e6c9792718b6a7080956d766d95394fc..ae46df8449278bd9ad0185a7b8bdc460c57f075e 100644 (file)
@@ -294,8 +294,8 @@ X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m)
     }
 }
 
-int X509_STORE_get_by_subject(X509_STORE_CTX *vs, int type, X509_NAME *name,
-                              X509_OBJECT *ret)
+int X509_STORE_get_by_subject(X509_STORE_CTX *vs, X509_LOOKUP_TYPE type,
+                              X509_NAME *name, X509_OBJECT *ret)
 {
     X509_STORE *ctx = vs->ctx;
     X509_LOOKUP *lu;
@@ -403,6 +403,8 @@ int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x)
 void X509_OBJECT_up_ref_count(X509_OBJECT *a)
 {
     switch (a->type) {
+    default:
+        break;
     case X509_LU_X509:
         CRYPTO_add(&a->data.x509->references, 1, CRYPTO_LOCK_X509);
         break;
@@ -417,6 +419,8 @@ void X509_OBJECT_free_contents(X509_OBJECT *a)
     if (!a)
         return;
     switch (a->type) {
+    default:
+        break;
     case X509_LU_X509:
         X509_free(a->data.x509);
         break;
index 0be9b5a844fff88b078eb8d25566ee0f571e2e04..4ad20296f8818d7eff5b480f05630bbcf7d37f1e 100644 (file)
@@ -102,15 +102,14 @@ The X509_STORE then calls a function to actually verify the
 certificate chain.
 */
 
-# define X509_LU_RETRY           -1
-# define X509_LU_FAIL            0
-# define X509_LU_X509            1
-# define X509_LU_CRL             2
-# define X509_LU_PKEY            3
+typedef enum {
+    X509_LU_RETRY = -1,
+    X509_LU_FAIL, X509_LU_X509, X509_LU_CRL
+} X509_LOOKUP_TYPE;
 
 typedef struct x509_object_st {
     /* one of the above types */
-    int type;
+    X509_LOOKUP_TYPE type;
     union {
         char *ptr;
         X509 *x509;