casaroli opened a new pull request, #21527:
URL: https://github.com/apache/nuttx/pull/21527

   ## Summary
   
   POSIX says that `id_t` can hold a `pid_t`, a `uid_t` or a `gid_t`. NuttX has 
`int`. glibc and musl have `unsigned int`, the type of `uid_t` and `gid_t`. A 
program that uses a `uid_t` as an `id_t`, and that checks with a static 
assertion that the types are the same, does not build.
   
   This PR makes `id_t` an `unsigned int`.
   
   ## Impact
   
   **This changes a type of the flat-build API: `id_t` in `<sys/types.h>`.** 
The size does not change. A program that compares an `id_t` with a negative 
value gets a different result, and `-Wsign-compare` can warn. Nothing in nuttx 
or apps does this.
   
   Users, read in the tree: `getpriority()` and `setpriority()` compare `who` 
with 0 and pass it on as a `pid_t`. `waitid()` converts `id` to a `pid_t`. The 
`waitid` system call passes it through `uintptr_t` and back to `id_t`. The only 
user in apps is a cast in `testing/ostest/waitpid.c`. A value of -1 keeps its 
bits, and it converts back to -1 as a `pid_t`. No Documentation change: 
`Documentation/reference/user/03_task_control.rst` has only the `waitid()` 
prototype.
   
   ## Testing
   
   Test program: `id_t`, `uid_t` and `gid_t` are the same type 
(`__builtin_types_compatible_p`), and an `id_t` holds `UINT_MAX - 1` and a 
`pid_t`. It is not in apps; a regression guard would need an apps PR.
   
   | Config | master bf029a2ef5d | this branch |
   |---|---|---|
   | `qemu-armv8a:nsh` (flat), HVF | same FAIL, holds FAIL; ostest status 0 | 2 
PASS; ostest status 0 |
   | `qemu-armv8a:knsh` (kernel), HVF | same FAIL, holds FAIL; ostest status 0 
| 2 PASS; ostest status 0 |
   | `mps2-an500:knsh` (protected), TCG | same FAIL, holds FAIL; ostest status 
0 | 2 PASS; ostest status 0 |
   
   ostest has the `waitid()` case. One earlier protected run of this branch 
stopped because the console did not take the `ostest` command; the test had 
passed by then, and the run above is a new boot of the same commit. Compilers: 
aarch64 GCC 14.2, arm-none-eabi GCC 15.3. Not built: other compilers and the 
other architectures. The type has no architecture dependency.
   
   `tools/checkpatch.sh -c -u -m -g` passes.
   


-- 
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]

Reply via email to