Date: Wed, 20 Jan 2016 21:30:44 +1100 (EST) From: Bruce Evans <brde@optusnet.com.au> To: Konstantin Belousov <kostikbel@gmail.com> Cc: Boris Astardzhiev <boris.astardzhiev@gmail.com>, threads@freebsd.org, Jilles Tjoelker <jilles@stack.nl>, net@freebsd.org Subject: Re: Does FreeBSD have sendmmsg or recvmmsg system calls? Message-ID: <20160120205544.Q2305@besplex.bde.org> In-Reply-To: <20160120073154.GB3942@kib.kiev.ua> References: <CAP=KkTwG0SVUmrBuWm33EC-tG4tMTdF5rLZQ_u6G1=-ujnfjkA@mail.gmail.com> <20160113080349.GC72455@kib.kiev.ua> <CAP=KkTxVaqZvigg78Dg%2Bv8kuTCaZyky8x15NHqD9uabuRKRkMw@mail.gmail.com> <20160116195657.GJ3942@kib.kiev.ua> <20160116202534.GK3942@kib.kiev.ua> <20160117211853.GA37847@stack.nl> <20160118044826.GS3942@kib.kiev.ua> <CAP=KkTy3J=k7hokGhohcGXv%2BWLnaxJmiAPxqmX9FHt7k0=Dp7Q@mail.gmail.com> <20160118140811.GW3942@kib.kiev.ua> <CAP=KkTzLCOnJVqt5F3ZuuZUiwkmWcne2Ynpi6-daE2jTzSBtfw@mail.gmail.com> <20160120073154.GB3942@kib.kiev.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 20 Jan 2016, Konstantin Belousov wrote: > 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 ? None of the above. Plain recvmsg() returns ssize_t and its len arg has type size_t. That is excessively typedefed and excessively large with 64-bit ssize_t, but it is silly for the multiple-message variant to use smaller types. Otherwise, all the integer types should be int. recvmsg() is still declared in syscalls.master as returning int, but it seems to be correct internallly. It is like read() and returns ssize_t in td_retval[0]. No wrong prototypes seem to be generated from the wrong retun types in syscalls.master. >> + 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. The errno method (and not checking ret at all) is best if for syscalls that return -1 for a non-error. It is not needed here. Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20160120205544.Q2305>