Re: Intermediate void* casts

Ben Harris <[email protected]>
Newsgroups gmane.os.netbsd.devel.general
Organization Linux Unlimited
Message-ID <[email protected]>
In article <[email protected]> you write:
>Since we will switch to gcc3.3.1 soon and already had first problems
>with incorrect code due to alias bugs, I think we should have a kind
>of a mini audit for these. Usually gcc 3.3.1 warns about this kind
>of problems, but it shuts up if an intermediate void* cast is involved.
>So I tried to find dubious casts to pointer types after casts to void*.
>
>I found quite a few of them, which was a bit of a suprise to me.

I think they're reasonably common because casting through void * is a way of
telling lint, "I know what I'm doing," usually in the area of pointer
alignment.

> - The (void*) cast can just be removed.
>   A real world example: char *p; some_func((void**)(void*)&p);

This looks much like the kind of thing suggested twice by
<http://www.netbsd.org/developers/lint/>.  You might like to update that
document to suggest passifying lint some other way.

-- 
Ben Harris
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.