jingfei195887 opened a new pull request, #22287:
URL: https://github.com/apache/nuttx/pull/22287
## Summary
- **fs/userfs: clean up userfs implementation.** Style only, no change in
behaviour, in `fs/userfs/fs_userfs.c` and `libs/libc/userfs/lib_userfs.c`:
1. Remove unneeded casts such as `(int)nsent`, `(int)nrecvd`,
`(unsigned int)nrecvd`, `(intmax_t)filep->f_pos`,
`(unsigned long)offset` and `(FAR void *)priv`, and print `ssize_t`
with `%zd` and `off_t` with `PRIdOFF`.
2. Merge multi-line `DEBUGASSERT()` calls into a more compact form.
3. Replace `sizeof(struct xxx)` with `sizeof(*variable)` or
`sizeof(variable)`, e.g. `sizeof(*req)`, `sizeof(resp)`,
`sizeof(priv->server)`, `sizeof(info->client)`, so the size follows
the variable's type.
4. Remove the duplicate forward declaration of `userfs_read()`.
## Impact
- New feature / API change: NO.
- Behavior: NO. Every `sizeof` replacement names a variable of the same
type as the struct it replaces.
- Build, hardware, documentation, security, compatibility: NO.
## Testing
Host: Ubuntu 22.04 x86_64, gcc 13.1.0. Base: master c68c0bfbc1.
Every changed `sizeof()` was checked against the line it replaces: the new
expression has the same type as the `struct` it names (154 pairs in the
two files, no mismatch).
`sim:nsh` with `CONFIG_FS_USERFS`, `CONFIG_FS_LINKS`, `CONFIG_FS_NOTIFY`
and local/UDP loopback networking. A test app runs a userfs daemon and
exercises it: long relative paths against the daemon's `mxwrite`, record
locks and inotify forwarding, and syncfs. The output before and after this
change is identical:
```
userfslen open("abcdefg") len=7 mxwrite=8: fd=-1 errno=2 server got "abcdefg"
userfslen open("abcdefgh") len=8 mxwrite=8: fd=-1 errno=7 server got ""
userfslen open("abcdefghi") len=9 mxwrite=8: fd=-1 errno=7 server got ""
userfsfwd: F_SETLK ret=0 errno=0
userfsfwd: F_GETLK ret=0 errno=0
userfsfwd: daemon saw lock ioctl=0 setlk=1 getlk=1
userfsfwd: add_watch wd=1 errno=0; daemon ADD=1 path="f"
userfsfwd: inject ret=0 events=1
userfsfwd: daemon RM=1
userfslink /mnt/ufl: syncfs ret=0 errno=0
```
- `./tools/checkpatch.sh -m -g master..HEAD`: all checks pass.
- `sim:nsh` with the options above: Make and CMake builds pass with no
warnings in the changed files; `ostest` exits with status 0.
- Verified on sim only.
## PR verification Self-Check
* [x] This PR introduces only one functional change.
* [x] I have updated all required description fields above.
* [x] My PR adheres to Contributing Guidelines and Documentation (git commit
title and message, coding standard, etc).
* [ ] My PR is still work in progress (not ready for review).
* [x] My PR is ready for review and can be safely merged into a codebase.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]