On Mon, Apr 03, 2017 at 09:45:06PM +0200, Otto Moerbeek wrote:
> On Mon, Apr 03, 2017 at 09:27:52AM +0000, Luke Small wrote:
>
> > I'm sure you know more about it than I do. Probably the simplest answer
> > would be to get rid of the example in the man page. You can google a
> > correct answer. It is in several places using the same message='F'; Unless
> > y'all desire the programmer to be able to read the man page because they
> > may not have internet. If you want to keep an example though, I think that
> > the one I supplied would be good.
> >
> > http://marc.info/?l=openbsd-bugs&m=149094667431995&w=2
> >
> > On Mon, Apr 3, 2017 at 3:58 AM Stuart Henderson <[email protected]>
> > wrote:
> >
> > > On 2017/04/02 13:15, Luke Small wrote:
> > > (quote word-wrapped and trimmed)
> > > > Can the code be fixed to not
> > > > cause problems when msg.msg_iov is zero? At first blush, that would
> > > > seem like a simple fix to me. I assume that such a fix wouldn't break
> > > > POSIX or some RFC.
> > >
> > > POSIX or some RFC are irrelevant. Existing code has been written against
> > > real-world OS not specs (and any new portable code still has to work on
> > > other systems with the existing behaviour). Maybe some of it works "by
> > > mistake" _because_ of this behaviour and changing it would break it.
> > > Fancy doing that audit across the ports tree?
> > >
> > >
>
> I added a caveat to recv(2) and fixed the example. Thanks for noting
> the problem.
>
> -Otto
BTW, the code in your example is neglecting alignment constraints that
might exists on some platforms. That's the reason a union is used in
CMSG_DATA(3).
-Otto