> > > The easiest way to avoid the conversions noted above is to have a
> > > union like this:
> > >
> > >         union foo {
> > >                 void *simple;
> > >                 int (*fn)();
> > >         };
> > >
> > > and use it internally.  You put whatever char * you want to convert to
> > > a functino pointer into simple and pull out the function pointer from
> > > fn, and vice versa.
> >
> > That assumes that the conversion the compiler is attempting to prevent
> > can actually be done, which is not, of course, a valid assumption. The
> > only way to do this validly is to make the functions actually take a foo
> > * as their argument, surely? And yes, then you may end up with a memory
> > management problem (though often not, coz I'll bet in most cases you can
> > make the foo static).
> >
> 
> Hmmm. Do we have to use this on every platform, including those that
> handled it before?
> 
> Can't we just have a macro or function that does the conversion? I.e. on
> most platforms it would be a macro which expands to a cast but on VMS it
> would end up calling a function.
It's *not* VMS specific! DEC C 6.2 for Unix issues very similar warning.
Yes, it's just a warning, it's not a fatal error and generated code does
the intended thing. It should also be pointed out that it (Unix version)
does it only if invoked with -std1 flag which stands for maximum
standard compliance! Do we have to use on every platform? Only if we
want to claim that the toolkit is 100% ANSI C:-) For your information
here're other offending casts:

cc: Info: bss_conn.c, line 573: In this statement, "data->info_callback"
of type
 "pointer to function () returning int", is being converted to "pointer
to char"
.  Such a cast is not permitted by the standard. (nonstandcast)
                (void)BIO_set_info_callback(dbio,data->info_callback);
----------------------^
cc: Info: bss_conn.c, line 576: In this statement, "ptr" of type
"pointer to cha
r", is being converted to "pointer to function () returning int".  Such
a cast i
s not permitted by the standard. (nonstandcast)
                data->info_callback=(int (*)())ptr;
-----------------------------------------------^
cc: Info: o_names.c, line 53: In this statement, "strcmp" of type
"pointer to fu
nction (pointer to const char, pointer to const char) returning int", is
being c
onverted to "pointer to char".  Such a cast is not permitted by the
standard. (n
onstandcast)
                sk_push(names_hash,(char *)strcmp);
-------------------------------------------^
cc: Info: o_names.c, line 54: In this statement, "lh_strhash" of type
"pointer t
o function (pointer to const char) returning unsigned long", is being
converted 
to "pointer to char".  Such a cast is not permitted by the standard.
(nonstandca
st)
                sk_push(names_cmp,(char *)lh_strhash);
------------------------------------------^
cc: Info: o_names.c, line 59: In this statement, "hash_func" of type
"pointer to
 function () returning unsigned long", is being converted to "pointer to
char". 
 Such a cast is not permitted by the standard. (nonstandcast)
                sk_set(names_hash,ret,(char *)hash_func);
----------------------------------------------^
cc: Info: o_names.c, line 61: In this statement, "cmp_func" of type
"pointer to 
function () returning int", is being converted to "pointer to char". 
Such a cas
t is not permitted by the standard. (nonstandcast)
                sk_set(names_cmp,ret,(char *)cmp_func);
---------------------------------------------^
cc: Info: o_names.c, line 63: In this statement, "free_func" of type
"pointer to
 function () returning void", is being converted to "pointer to char". 
Such a c
ast is not permitted by the standard. (nonstandcast)
                sk_set(names_free,ret,(char *)free_func);
----------------------------------------------^
cc: Info: o_names.c, line 77: In this statement, "sk_value(...)" of type
"pointe
r to char", is being converted to "pointer to function () returning
int".  Such 
a cast is not permitted by the standard. (nonstandcast)
                        cmp=(int (*)())sk_value(names_cmp,a->type);
---------------------------------------^
cc: Info: o_names.c, line 93: In this statement, "sk_value(...)" of type
"pointe
r to char", is being converted to "pointer to function () returning
unsigned lon
g".  Such a cast is not permitted by the standard. (nonstandcast)
                hash=(unsigned long (*)())sk_value(names_hash,a->type);
------------------------------------------^
cc: Info: o_names.c, line 163: In this statement, "sk_value(...)" of
type "point
er to char", is being converted to "pointer to function () returning
void".  Suc
h a cast is not permitted by the standard. (nonstandcast)
                        f=(void (*)())sk_value(names_free,ret->type);
--------------------------------------^
cc: Info: o_names.c, line 195: In this statement, "sk_value(...)" of
type "point
er to char", is being converted to "pointer to function () returning
void".  Suc
h a cast is not permitted by the standard. (nonstandcast)
                        f=(void (*)())sk_value(names_free,type);
--------------------------------------^
cc: Info: s3_lib.c, line 641: In this statement, "parg" of type "pointer
to char
", is being converted to "pointer to function (pointer to struct ssl_st,
int, in
t) returning pointer to struct rsa_st".  Such a cast is not permitted by
the sta
ndard. (nonstandcast)
                s->cert->rsa_tmp_cb = (RSA *(*)(SSL *, int, int))parg;
-----------------------------------------------------------------^
cc: Info: s3_lib.c, line 668: In this statement, "parg" of type "pointer
to char
", is being converted to "pointer to function (pointer to struct ssl_st,
int, in
t) returning pointer to struct dh_st".  Such a cast is not permitted by
the stan
dard. (nonstandcast)
                s->cert->dh_tmp_cb = (DH *(*)(SSL *, int, int))parg;
---------------------------------------------------------------^
cc: Info: s3_lib.c, line 724: In this statement, "parg" of type "pointer
to char
", is being converted to "pointer to function (pointer to struct ssl_st,
int, in
t) returning pointer to struct rsa_st".  Such a cast is not permitted by
the sta
ndard. (nonstandcast)
                cert->rsa_tmp_cb=(RSA *(*)(SSL *, int, int))parg;
------------------------------------------------------------^
cc: Info: s3_lib.c, line 751: In this statement, "parg" of type "pointer
to char
", is being converted to "pointer to function (pointer to struct ssl_st,
int, in
t) returning pointer to struct dh_st".  Such a cast is not permitted by
the stan
dard. (nonstandcast)
                cert->dh_tmp_cb=(DH *(*)(SSL *, int, int))parg;
----------------------------------------------------------^
cc: Info: ssl_lib.c, line 1945: In this statement, "cb" of type "pointer
to func
tion (pointer to struct ssl_st, int, int) returning pointer to struct
rsa_st", i
s being converted to "pointer to char".  Such a cast is not permitted by
the sta
ndard. (nonstandcast)
    { SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_RSA_CB,0,(char *)cb); }
---------------------------------------------------------^
cc: Info: ssl_lib.c, line 1951: In this statement, "cb" of type "pointer
to func
tion (pointer to struct ssl_st, int, int) returning pointer to struct
rsa_st", i
s being converted to "pointer to char".  Such a cast is not permitted by
the sta
ndard. (nonstandcast)
    { SSL_ctrl(ssl,SSL_CTRL_SET_TMP_RSA_CB,0,(char *)cb); }
-----------------------------------------------------^
cc: Info: ssl_lib.c, line 1978: In this statement, "dh" of type "pointer
to func
tion (pointer to struct ssl_st, int, int) returning pointer to struct
dh_st", is
 being converted to "pointer to char".  Such a cast is not permitted by
the stan
dard. (nonstandcast)
    { SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH_CB,0,(char *)dh); }
--------------------------------------------------------^
cc: Info: ssl_lib.c, line 1982: In this statement, "dh" of type "pointer
to func
tion (pointer to struct ssl_st, int, int) returning pointer to struct
dh_st", is
 being converted to "pointer to char".  Such a cast is not permitted by
the stan
dard. (nonstandcast)
    { SSL_ctrl(ssl,SSL_CTRL_SET_TMP_DH_CB,0,(char *)dh); }
----------------------------------------------------^
cc: Info: bio_ssl.c, line 447: In this statement, "ptr" of type "pointer
to char
", is being converted to "pointer to function () returning void".  Such
a cast i
s not permitted by the standard. (nonstandcast)
                SSL_set_info_callback(ssl,(void (*)())ptr);
------------------------------------------------------^

Andy.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to