Re: write-only variables in src/sys/ - possible bugs

From: Christoph Mallon <christoph.mallon_at_gmx.de>
Date: Wed, 04 Feb 2009 15:54:41 +0100
Christian Peron schrieb:
> I started following up on this and ran into an issue for these:
> 
> sys/net/bpf_buffer.c:133: warning: variable 'dst' is never read
> sys/net/bpf_buffer.c:134: warning: variable 'count' is never read
> sys/net/bpf_buffer.c:142: warning: variable 'dst' is never read
> 
> 
> /*
>  * Scatter-gather data copy from an mbuf chain to the current kernel buffer.
>  */
> void
> bpf_buffer_append_mbuf(struct bpf_d *d, caddr_t buf, u_int offset, void *src,
>     u_int len)
> {
>         const struct mbuf *m;
>         u_char *dst;
>         u_int count;
>  
>         m = (struct mbuf *)src;
>         dst = (u_char *)buf + offset;
>         while (len > 0) {
>                 if (m == NULL)
>                         panic("bpf_mcopy");
>                 count = min(m->m_len, len);
>                 bcopy(mtod(m, void *), dst, count);
>                 m = m->m_next;
> [..]
> 
> Does it not consider being passed as an argument to a function as
> being read?

Yes, function arguments are considered being read. The problem is 
different here: mtod() should be a macro, but the macro declaration was 
missing (*cough* hacked build process *cough*). So the parser tried to 
parse this as function call. Then it hit the "void *", which confused it 
- it got a type while parsing an expression. I improved the error 
correction, resolved a few other problems, too, and generated a new list:

http://tron.homeunix.org/unread_variables.log
(The list has a date at the top, if it is missing, you see the old list 
in your browser cache)

The false positives, which you mentioned, are gone now - thanks for 
reporting this. The list now contains about 1.000 entries and about 60 
concern variables named 'error'.
Received on Wed Feb 04 2009 - 13:54:44 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:41 UTC