I am looking at net/if_tun.c, function tunwrite() (this is 7.4, but 8.2 is nearly the same):

There is a local variable "error" which is initialized to zero and then seemingly never changed, until it is used as a return value if m_uiotombuf() fails:

...
        int             error = 0;
...
        if ((m = m_uiotombuf(uio, M_DONTWAIT, 0, 0, M_PKTHDR)) == NULL) {
                ifp->if_ierrors++;
                return (error);
        }
...
a little further down, we see
...
                if (m->m_len < sizeof(family) &&
                    (m = m_pullup(m, sizeof(family))) == NULL)
                        return (ENOBUFS);
...

As far as I can see, the first return amounts to "drop the packet, but don't tell anything about it", whereas the second amounts to "drop the packet and say it's due to ENOBUFS".

However, the first case is much more like ENOBUFS, so shouldn't we simply say "return (ENOBUFS)" there and remove the "error" variable altogether?

There seem to be other functions in if_tun.c with a similar strange usage of an "error" variable.

Regards,

Martin

_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"

Reply via email to