> > DEC C for VMS is getting really mean. Version 6.2
          ^^^^^^^ It has nothing to do with VMS. It complains about
casts between (*) and * even on Unix.
> 
> > It's especially visible in all the places where lh_doall_arg() gets a
> > casted function pointer as last argument (for example, see
> > CRYPTO_mem_leaks_cb() in crypto/mem_dbg.c)...
> >
> > I can imagine using silly things like a struct around the function
> > pointer to get rid of that warning.
> 
> The function pointer *must* be inside a data object to make such constructs
> legal,
But that's what Richard (subconsciously?) attempted to do in first
place:

static void (*mem_cb)()=NULL;

void CRYPTO_mem_leaks_cb(void (*cb)())
        {
        ...
        mem_cb=cb;
        lh_doall_arg(mh,(void (*)())cb_leak,(char *)mem_cb);
        mem_cb=NULL;
        ...
        }

I mean someting has prevented him from just "lh_doall_arg(mh,(void
(*)())cb_leak,(char *)cb)," hasn't it?
> so this is not silly at all.  An alternative would be to use
> unions of a function pointer
Why structures/unions? "lh_doall_arg(mh,(void (*)())cb_leak,(void
*)&mem_cb)" should do... Of course provided that it's appropriately
derefenced in cb_leak! And I fail to understand why mem_cb has to be
declared static? It can be perfectly declared in CRYPTO_mem_leaks_cb
scope which also makes it multi-thead safe, doesn't it? To summarize:

typedef void (*cb_t) ();

static void cb_leak(MEM *m, void *cb)
        {
        void (*mem_callback)()=*((cb_t *)cb);
        mem_callback(m->order,m->file,m->line,m->num,m->addr);
        }

void CRYPTO_mem_leaks_cb(void (*cb)())
        {
        void (*mem_cb)() = cb;
        if (mh == NULL) return;
        CRYPTO_w_lock(CRYPTO_LOCK_MALLOC2);
        lh_doall_arg(mh,(void (*)())cb_leak,(void *)(&mem_cb));
        CRYPTO_w_unlock(CRYPTO_LOCK_MALLOC2);
        }

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

Reply via email to