Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 26 Apr 2019 08:32:55 +0000
From:      "Poul-Henning Kamp" <phk@phk.freebsd.dk>
To:        Alan Somers <asomers@freebsd.org>
Cc:        FreeBSD Hackers <freebsd-hackers@freebsd.org>
Subject:   Re: buf(9) woes: when does bcopy do nothing at all?
Message-ID:  <23438.1556267575@critter.freebsd.dk>
In-Reply-To: <CAOtMX2gdw%2BeQQU_-DC%2BEgimbCyw6ynbX1haGLUmn1dApk4rMZw@mail.gmail.com>
References:  <CAOtMX2gdw%2BeQQU_-DC%2BEgimbCyw6ynbX1haGLUmn1dApk4rMZw@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
--------
In message <CAOtMX2gdw+eQQU_-DC+EgimbCyw6ynbX1haGLUmn1dApk4rMZw@mail.gmail=
.com>, Alan Somers writes:

>How is it possible that bcopy() doesn't affect its output array at all?

That conclusion does not follow from your example:

>bcopy(cp, iov->iov_base, cnt);
>r =3D memcmp(cp, iov->iov_base, cnt);
>if (r)
>    printf("uiomove: miscompare\n");

If [cp:cp+cnt] and [iov_base:iov_base+cnt] overlap the bcopy result
is undefined.

Try memmove instead ?

-- =

Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    =

Never attribute to malice what can adequately be explained by incompetence=
.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?23438.1556267575>