buf(9) woes: when does bcopy do nothing at all?
    Poul-Henning Kamp 
    phk at phk.freebsd.dk
       
    Fri Apr 26 08:33:04 UTC 2019
    
    
  
--------
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 ?
-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at 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.
    
    
More information about the freebsd-hackers
mailing list