Use enum for X509_LOOKUP_TYPE

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>
This commit is contained in:
Rich Salz 2015-05-26 15:42:01 -04:00 committed by Rich Salz
parent d9f1c639d5
commit bca3f06b84
3 changed files with 13 additions and 10 deletions

View File

@ -247,8 +247,8 @@ static int add_cert_dir(BY_DIR *ctx, const char *dir, int type)
return 1; return 1;
} }
static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name, static int get_cert_by_subject(X509_LOOKUP *xl, X509_LOOKUP_TYPE type,
X509_OBJECT *ret) X509_NAME *name, X509_OBJECT *ret)
{ {
BY_DIR *ctx; BY_DIR *ctx;
union { union {

View 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, int X509_STORE_get_by_subject(X509_STORE_CTX *vs, X509_LOOKUP_TYPE type,
X509_OBJECT *ret) X509_NAME *name, X509_OBJECT *ret)
{ {
X509_STORE *ctx = vs->ctx; X509_STORE *ctx = vs->ctx;
X509_LOOKUP *lu; 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) void X509_OBJECT_up_ref_count(X509_OBJECT *a)
{ {
switch (a->type) { switch (a->type) {
default:
break;
case X509_LU_X509: case X509_LU_X509:
CRYPTO_add(&a->data.x509->references, 1, CRYPTO_LOCK_X509); CRYPTO_add(&a->data.x509->references, 1, CRYPTO_LOCK_X509);
break; break;
@ -417,6 +419,8 @@ void X509_OBJECT_free_contents(X509_OBJECT *a)
if (!a) if (!a)
return; return;
switch (a->type) { switch (a->type) {
default:
break;
case X509_LU_X509: case X509_LU_X509:
X509_free(a->data.x509); X509_free(a->data.x509);
break; break;

View File

@ -102,15 +102,14 @@ The X509_STORE then calls a function to actually verify the
certificate chain. certificate chain.
*/ */
# define X509_LU_RETRY -1 typedef enum {
# define X509_LU_FAIL 0 X509_LU_RETRY = -1,
# define X509_LU_X509 1 X509_LU_FAIL, X509_LU_X509, X509_LU_CRL
# define X509_LU_CRL 2 } X509_LOOKUP_TYPE;
# define X509_LU_PKEY 3
typedef struct x509_object_st { typedef struct x509_object_st {
/* one of the above types */ /* one of the above types */
int type; X509_LOOKUP_TYPE type;
union { union {
char *ptr; char *ptr;
X509 *x509; X509 *x509;