[openssl-dev] [openssl.org #4335] ix 'assignment from incompatible type' warning in OBJ_NAME_new_index()
Kaduk, Ben via RT
rt at openssl.org
Mon Feb 22 21:21:14 UTC 2016
On 02/22/2016 11:04 AM, David Woodhouse via RT wrote:
> We are using OPENSSL_strcmp() as the cmp_func, where cmp_func takes
> a pair of (void *) pointers, not (char *). Which is fine; we know we're
> going to pass it strings in this case. So explicitly cast it to avoid
> the resulting compiler warning.
> ---
> crypto/objects/o_names.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/crypto/objects/o_names.c b/crypto/objects/o_names.c
> index 0a07379..1f9f10a 100644
> --- a/crypto/objects/o_names.c
> +++ b/crypto/objects/o_names.c
> @@ -83,7 +83,7 @@ int OBJ_NAME_new_index(unsigned long (*hash_func) (const char *),
> return (0);
> }
> name_funcs->hash_func = lh_strhash;
> - name_funcs->cmp_func = OPENSSL_strcmp;
> + name_funcs->cmp_func = (void *)OPENSSL_strcmp;
> CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_DISABLE);
> sk_NAME_FUNCS_push(name_funcs_stack, name_funcs);
> CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ENABLE);
>
Er, where is the cmp_func that is supposed to take void* pointers? In
master:crypto/objects/o_names.c I see the name_funcs_st with a member
"int (*cmp_func) (const char *a, const char *b);"
(Also, strict C forbids inter-casting between function pointers and
void*, so a cast of (int (*)(void *,void *)) would seem more appropriate
for the stated goal.)
-Ben
--
Ticket here: http://rt.openssl.org/Ticket/Display.html?id=4335
Please log in as guest with password guest if prompted
More information about the openssl-dev
mailing list