Page MenuHomeFreeBSD

msdosfs: use mem{cpy,move,set} instead of bcopy,bzero
ClosedPublic

Authored by emaste on May 31 2017, 7:08 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 5 2024, 9:16 PM
Unknown Object (File)
Feb 8 2024, 10:15 AM
Unknown Object (File)
Dec 20 2023, 7:05 PM
Unknown Object (File)
Dec 20 2023, 2:56 AM
Unknown Object (File)
Dec 18 2023, 8:36 AM
Unknown Object (File)
Dec 8 2023, 6:16 AM
Unknown Object (File)
Nov 28 2023, 2:52 AM
Unknown Object (File)
Nov 26 2023, 1:39 PM
Subscribers

Details

Summary

This somewhat simplifies use of msdosfs code in userland (for makefs), and is standard C as of C89.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

There is no memcpy() in libkern. You change work because compiler inlines the function.
The common saying is that FreeBSD kernel traditionally uses bcopy().

I do not have much opinion there, but know that bde has.

In D11014#228066, @kib wrote:

The common saying is that FreeBSD kernel traditionally uses bcopy().

Indeed - but I was surprised:

% find sys -name '*.c' | xargs cat | grep -w -c memcpy
3056
% find sys -name '*.c' | xargs cat | grep -w -c bcopy
2894

A quick grep turns up memcpy in sys/fs/ext2fs, sys/fs/devfs, sys/fs/unionfs, sys/fs/smbfs, sys/fs/cuse, sys/fs/cd9660, sys/fs/nandfs, sys/fs/autofs, sys/fs/fuse, sys/fs/tmpfs.

sys/fs/ext2fs, sys/fs/devfs, sys/fs/unionfs, sys/fs/smbfs, sys/fs/cuse, sys/fs/cd9660, sys/fs/nandfs, sys/fs/autofs, sys/fs/fuse, sys/fs/tmpfs.

Most of this comes from NetBSD, perhaps except devfs and autofs. And for devfs I can see an alien code where it is used.

Anyway, I do not have opinion on this replace, as I stated.

At least one of these (bcopy(slot + WIN_CHARS, slot + count, nbp->nb_len);) has overlapping src and dst, and would have to be memmove instead.

emaste retitled this revision from msdosfs: use memcpy instead of bcopy to msdosfs: use memcpy/memmove instead of bcopy.
emaste added a subscriber: kp.

Replace bcopy instance that may have overlapping arguments with memmove, not memcpy.

Most of this comes from NetBSD

Our msdosfs as well, so I'll try to move this ahead.

This may unfortunately involve rehashing the memmove/memcpy symbols in kernel issue -- e.g. https://lists.freebsd.org/pipermail/freebsd-arch/2009-February/009009.html

emaste retitled this revision from msdosfs: use memcpy/memmove instead of bcopy to msdosfs: use mem{cpy,move,set} instead of bcopy,bzero.

also bzero -> memset for more NetBSD diff reduction

also switch an unrolled memset(..., 0xff, ...)

imp added a subscriber: imp.

There's no problem with either memcpy or memmove in the kernel. They just work. For like at least decade....

bcopy has 'overlapping works' semantics on at least some of our platforms, so changing to memmove is good.

While tradition is good, it's a tradition that's been more in the lapse than its observance of late.

This revision is now accepted and ready to land.Jun 2 2017, 6:06 PM
This revision was automatically updated to reflect the committed changes.