buf(9) woes: when does bcopy do nothing at all?

Mark Millard marklmi at yahoo.com
Fri Apr 26 18:41:24 UTC 2019


On 2019-Apr-26, at 01:32, Poul-Henning Kamp <phk at phk.freebsd.dk> wrote:

> --------
> In message <CAOtMX2gdw+eQQU_-DC+EgimbCyw6ynbX1haGLUmn1dApk4rMZw at 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 = 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 ?

I only see a bcopy man page bcopy(3) but it says:

DESCRIPTION
     The bcopy() function copies len bytes from string src to string dst.  The
     two strings may overlap.  If len is zero, no bytes are copied.

Is a kernel bcopy likely to be any different?

===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)



More information about the freebsd-hackers mailing list