From: Dr. Stephen Henson Date: Sat, 21 May 2016 15:31:09 +0000 (+0100) Subject: Constify stack and lhash macros. X-Git-Tag: OpenSSL_1_1_0-pre6~745 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=4591e5fb4168eb81d198a236d265d87256bf67c1;p=oweals%2Fopenssl.git Constify stack and lhash macros. RT#4471 Reviewed-by: Tim Hudson --- diff --git a/crypto/stack/stack.c b/crypto/stack/stack.c index 36fc921aa3..0076db139d 100644 --- a/crypto/stack/stack.c +++ b/crypto/stack/stack.c @@ -142,14 +142,14 @@ int OPENSSL_sk_insert(OPENSSL_STACK *st, void *data, int loc) return (st->num); } -void *OPENSSL_sk_delete_ptr(OPENSSL_STACK *st, void *p) +void *OPENSSL_sk_delete_ptr(OPENSSL_STACK *st, const void *p) { int i; for (i = 0; i < st->num; i++) if (st->data[i] == p) - return (OPENSSL_sk_delete(st, i)); - return (NULL); + return OPENSSL_sk_delete(st, i); + return NULL; } void *OPENSSL_sk_delete(OPENSSL_STACK *st, int loc) @@ -174,7 +174,8 @@ void *OPENSSL_sk_delete(OPENSSL_STACK *st, int loc) return (ret); } -static int internal_find(OPENSSL_STACK *st, void *data, int ret_val_options) +static int internal_find(OPENSSL_STACK *st, const void *data, + int ret_val_options) { const void *const *r; int i; @@ -198,12 +199,12 @@ static int internal_find(OPENSSL_STACK *st, void *data, int ret_val_options) return (int)((char **)r - st->data); } -int OPENSSL_sk_find(OPENSSL_STACK *st, void *data) +int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data) { return internal_find(st, data, OBJ_BSEARCH_FIRST_VALUE_ON_MATCH); } -int OPENSSL_sk_find_ex(OPENSSL_STACK *st, void *data) +int OPENSSL_sk_find_ex(OPENSSL_STACK *st, const void *data) { return internal_find(st, data, OBJ_BSEARCH_VALUE_ON_NOMATCH); } diff --git a/include/openssl/lhash.h b/include/openssl/lhash.h index 7c568ac057..e2ccb65d69 100644 --- a/include/openssl/lhash.h +++ b/include/openssl/lhash.h @@ -153,15 +153,15 @@ void OPENSSL_LH_node_usage_stats_bio(const OPENSSL_LHASH *lh, BIO *out); } \ static ossl_inline void lh_##type##_node_stats_bio(const LHASH_OF(type) *lh, BIO *out) \ { \ - OPENSSL_LH_node_stats_bio((OPENSSL_LHASH *)lh, out); \ + OPENSSL_LH_node_stats_bio((const OPENSSL_LHASH *)lh, out); \ } \ static ossl_inline void lh_##type##_node_usage_stats_bio(const LHASH_OF(type) *lh, BIO *out) \ { \ - OPENSSL_LH_node_usage_stats_bio((OPENSSL_LHASH *)lh, out); \ + OPENSSL_LH_node_usage_stats_bio((const OPENSSL_LHASH *)lh, out); \ } \ static ossl_inline void lh_##type##_stats_bio(const LHASH_OF(type) *lh, BIO *out) \ { \ - OPENSSL_LH_stats_bio((OPENSSL_LHASH *)lh, out); \ + OPENSSL_LH_stats_bio((const OPENSSL_LHASH *)lh, out); \ } \ static ossl_inline unsigned long lh_##type##_get_down_load(LHASH_OF(type) *lh) \ { \ diff --git a/include/openssl/safestack.h b/include/openssl/safestack.h index d0af0eba5d..306b3acc57 100644 --- a/include/openssl/safestack.h +++ b/include/openssl/safestack.h @@ -54,7 +54,8 @@ extern "C" { } \ static ossl_inline t2 *sk_##t1##_delete_ptr(STACK_OF(t1) *sk, t2 *ptr) \ { \ - return (t2 *)OPENSSL_sk_delete_ptr((OPENSSL_STACK *)sk, (void *)ptr); \ + return (t2 *)OPENSSL_sk_delete_ptr((OPENSSL_STACK *)sk, \ + (const void *)ptr); \ } \ static ossl_inline int sk_##t1##_push(STACK_OF(t1) *sk, t2 *ptr) \ { \ @@ -86,11 +87,11 @@ extern "C" { } \ static ossl_inline int sk_##t1##_find(STACK_OF(t1) *sk, t2 *ptr) \ { \ - return OPENSSL_sk_find((OPENSSL_STACK *)sk, (void *)ptr); \ + return OPENSSL_sk_find((OPENSSL_STACK *)sk, (const void *)ptr); \ } \ static ossl_inline int sk_##t1##_find_ex(STACK_OF(t1) *sk, t2 *ptr) \ { \ - return OPENSSL_sk_find_ex((OPENSSL_STACK *)sk, (void *)ptr); \ + return OPENSSL_sk_find_ex((OPENSSL_STACK *)sk, (const void *)ptr); \ } \ static ossl_inline void sk_##t1##_sort(STACK_OF(t1) *sk) \ { \ diff --git a/include/openssl/stack.h b/include/openssl/stack.h index 6fab33b759..9bc550fe08 100644 --- a/include/openssl/stack.h +++ b/include/openssl/stack.h @@ -32,9 +32,9 @@ void OPENSSL_sk_pop_free(OPENSSL_STACK *st, void (*func) (void *)); OPENSSL_STACK *OPENSSL_sk_deep_copy(OPENSSL_STACK *, OPENSSL_sk_copyfunc c, OPENSSL_sk_freefunc f); int OPENSSL_sk_insert(OPENSSL_STACK *sk, void *data, int where); void *OPENSSL_sk_delete(OPENSSL_STACK *st, int loc); -void *OPENSSL_sk_delete_ptr(OPENSSL_STACK *st, void *p); -int OPENSSL_sk_find(OPENSSL_STACK *st, void *data); -int OPENSSL_sk_find_ex(OPENSSL_STACK *st, void *data); +void *OPENSSL_sk_delete_ptr(OPENSSL_STACK *st, const void *p); +int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data); +int OPENSSL_sk_find_ex(OPENSSL_STACK *st, const void *data); int OPENSSL_sk_push(OPENSSL_STACK *st, void *data); int OPENSSL_sk_unshift(OPENSSL_STACK *st, void *data); void *OPENSSL_sk_shift(OPENSSL_STACK *st);