> > > I agree and strputmsg() could be changed to take a void * instead of 
 > > > const void *, which would be a safe thing to do. But when calling 
 > > > strputmsg() in line 1267 the same strangeness would apply, casting to 
 > > > 'dlp' a 'void *'.
 > >
 > >Why would you need to cast to a `void *'?
 >
 > Since 'dlp' is a const union DL_primitives type.
 > Is your question why I need to cast at all or to a "void *"?

Yes; it should only be needed when casting away qualifiers (such as const,
which you've done, which is why it's needed).

To the particular issue above: please keep the argument to strputmsg()
`const void *' -- as a general rule, if we have to cast away const, we
should do it as close to the buggy interface as possible, and not let the
disease spread.  Here, putmsg() uses a `struct strbuf', which is also used
by getmsg(), and thus has fields that are not const-qualified.

BTW, I'd recommend casting to `void *' rather than `char *', on the
grounds that we're really trying to express that const is being casted
away, and not that the pointer is being fundamentally changed.  The
compiler can handle the rest of the cast itself.

On a related note, I'm surprised to see that the `databuf' argument to
strputmsg() is also not `const void *'.  Following this oddity up the call
chain, it seems due to a mistake in the prototype for dlpi_send():

    int dlpi_send(dlpi_handle_t dh, const void *daddrp, size_t daddrlen,
         void *msgbuf, size_t msglen, const dlpi_sendinfo_t *sendp);
         ^^^^^^^^^^^^

I'd expect `msgbuf' to be `const void *'; is this an oversight, or have
I forgotten some subtlety here?

-- 
meem
_______________________________________________
networking-discuss mailing list
[email protected]

Reply via email to