On Tue, Jan 19, 2016 at 01:58:27PM +0200, Boris Astardzhiev wrote:
> +int
> +recvmmsg(int s, struct mmsghdr *msgvec, unsigned int vlen, int flags)
> +{
> +     int i, ret, rcvd;
Shouldn't i and rcvd be unsigned as well ?  Shouldn't return value
also be unsigned ?
> +
> +     if (vlen > VLEN_MAX)
> +             vlen = VLEN_MAX;
Why is this restriction needed ?

> +
> +     rcvd = 0;
> +     for (i = 0; i < vlen; i++) {
> +             errno = 0;
> +             ret = __sys_recvmsg(s, &msgvec[i].msg_hdr, flags);
> +             if (ret < 0 || errno != 0) {
I do not see why do you need to clear errno before, and then do this test.
Just check ret == -1, in which case errno was set from the immediate syscall.

> +                     if (rcvd != 0) {
> +                             /* We've received messages. Let caller know. */
> +                             errno = 0;
This cleaning is not needed as well.  For successfull functions returns,
errno value is undefined.

> +                             return (rcvd);
> +                     }
> +                     return (-1);
> +             }
> +
> +             /* Save received bytes */
> +             msgvec[i].msg_len = ret;
> +
Extra empty line.
> +             rcvd++;
> +     }
> +
> +     return (rcvd);
> +}
_______________________________________________
freebsd-net@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-net
To unsubscribe, send any mail to "freebsd-net-unsubscr...@freebsd.org"

Reply via email to