Remove meth_num in ex_data_impl.c.

It's unnecessary and Windows was unhappy about the signed/unsigned
comparisons.

Change-Id: If2c4a20de48a2cddb0a4e0ca01e84eef91b155db
Reviewed-on: https://boringssl-review.googlesource.com/1863
Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
David Benjamin 2014-09-30 19:56:11 -04:00 committed by Adam Langley
parent 775b75f9de
commit 357fd0a878

View File

@ -130,8 +130,6 @@ typedef struct crypto_ex_data_func_st {
typedef struct st_ex_class_item { typedef struct st_ex_class_item {
STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth; STACK_OF(CRYPTO_EX_DATA_FUNCS) *meth;
int class_value; int class_value;
/* TODO(fork): isn't |meth_num| just the length of |meth|? */
int meth_num;
} EX_CLASS_ITEM; } EX_CLASS_ITEM;
static LHASH_OF(EX_CLASS_ITEM) *global_classes = NULL; static LHASH_OF(EX_CLASS_ITEM) *global_classes = NULL;
@ -215,7 +213,6 @@ static EX_CLASS_ITEM *get_class(int class_value) {
class_item = OPENSSL_malloc(sizeof(EX_CLASS_ITEM)); class_item = OPENSSL_malloc(sizeof(EX_CLASS_ITEM));
if (class_item) { if (class_item) {
class_item->class_value = class_value; class_item->class_value = class_value;
class_item->meth_num = 0;
class_item->meth = sk_CRYPTO_EX_DATA_FUNCS_new_null(); class_item->meth = sk_CRYPTO_EX_DATA_FUNCS_new_null();
if (class_item->meth != NULL) { if (class_item->meth != NULL) {
EX_CLASS_ITEM *old_data; EX_CLASS_ITEM *old_data;
@ -265,17 +262,14 @@ static int get_new_index(int class_value, long argl, void *argp,
funcs->free_func = free_func; funcs->free_func = free_func;
CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA); CRYPTO_w_lock(CRYPTO_LOCK_EX_DATA);
/* TODO(fork): this loop appears to only ever run once. */
while (sk_CRYPTO_EX_DATA_FUNCS_num(item->meth) <= item->meth_num) { if (!sk_CRYPTO_EX_DATA_FUNCS_push(item->meth, funcs)) {
if (!sk_CRYPTO_EX_DATA_FUNCS_push(item->meth, NULL)) { OPENSSL_PUT_ERROR(CRYPTO, get_new_index, ERR_R_MALLOC_FAILURE);
OPENSSL_PUT_ERROR(CRYPTO, get_new_index, ERR_R_MALLOC_FAILURE); OPENSSL_free(funcs);
OPENSSL_free(funcs); goto err;
goto err;
}
} }
ret = item->meth_num++; ret = sk_CRYPTO_EX_DATA_FUNCS_num(item->meth) - 1;
(void)sk_CRYPTO_EX_DATA_FUNCS_set(item->meth, ret, funcs);
err: err:
CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA); CRYPTO_w_unlock(CRYPTO_LOCK_EX_DATA);