ERR: Using union-based "cast" of DynaGetFunction result to avoid warnings about strict aliasing.

This commit is contained in:
Brad King 2003-08-27 17:31:22 -04:00
parent a35d911def
commit 9f8444d7f6

View File

@ -53,14 +53,14 @@
#define _MPRINTF_REPLACE /* use our functions only */ #define _MPRINTF_REPLACE /* use our functions only */
#include <curl/mprintf.h> #include <curl/mprintf.h>
#define DYNA_GET_FUNCTION(type, fnc) \
#define DYNA_GET_FUNCTION(type, fnc) \ { \
{ \ union { void* ptr; type; } u; \
void* dyna_get_res = DynaGetFunction(#fnc); \ u.ptr = DynaGetFunction(#fnc); \
(fnc) = *((type)&dyna_get_res); \ (fnc) = u.fptr; \
if ((fnc) == NULL) { \ if ((fnc) == NULL) { \
return CURLE_FUNCTION_NOT_FOUND; \ return CURLE_FUNCTION_NOT_FOUND; \
} \ } \
} }
/*********************************************************************** /***********************************************************************
@ -166,15 +166,15 @@ CURLcode Curl_ldap(struct connectdata *conn)
/* The types are needed because ANSI C distinguishes between /* The types are needed because ANSI C distinguishes between
* pointer-to-object (data) and pointer-to-function. * pointer-to-object (data) and pointer-to-function.
*/ */
DYNA_GET_FUNCTION(void *(**)(char *, int), ldap_open); DYNA_GET_FUNCTION(void *(*fptr)(char *, int), ldap_open);
DYNA_GET_FUNCTION(int (**)(void *, char *, char *), ldap_simple_bind_s); DYNA_GET_FUNCTION(int (*fptr)(void *, char *, char *), ldap_simple_bind_s);
DYNA_GET_FUNCTION(int (**)(void *), ldap_unbind_s); DYNA_GET_FUNCTION(int (*fptr)(void *), ldap_unbind_s);
DYNA_GET_FUNCTION(int (**)(void *, char *, int, void **), ldap_url_search_s); DYNA_GET_FUNCTION(int (*fptr)(void *, char *, int, void **), ldap_url_search_s);
DYNA_GET_FUNCTION(void *(**)(void *, void *), ldap_first_entry); DYNA_GET_FUNCTION(void *(*fptr)(void *, void *), ldap_first_entry);
DYNA_GET_FUNCTION(void *(**)(void *, void *), ldap_next_entry); DYNA_GET_FUNCTION(void *(*fptr)(void *, void *), ldap_next_entry);
DYNA_GET_FUNCTION(char *(**)(int), ldap_err2string); DYNA_GET_FUNCTION(char *(*fptr)(int), ldap_err2string);
DYNA_GET_FUNCTION(int (**)(void *, char *, void *, void *, char **, char **, int (*)(void *, char *, int), void *, char *, int, unsigned long), ldap_entry2text); DYNA_GET_FUNCTION(int (*fptr)(void *, char *, void *, void *, char **, char **, int (*)(void *, char *, int), void *, char *, int, unsigned long), ldap_entry2text);
DYNA_GET_FUNCTION(int (**)(void *, char *, void *, void *, char **, char **, int (*)(void *, char *, int), void *, char *, int, unsigned long, char *, char *), ldap_entry2html); DYNA_GET_FUNCTION(int (*fptr)(void *, char *, void *, void *, char **, char **, int (*)(void *, char *, int), void *, char *, int, unsigned long, char *, char *), ldap_entry2html);
server = ldap_open(conn->hostname, conn->port); server = ldap_open(conn->hostname, conn->port);
if (server == NULL) { if (server == NULL) {