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

   ## Summary
   
   POSIX defines `WEXITSTATUS()` only when `WIFEXITED()` is true 
([`wait()`](https://pubs.opengroup.org/onlinepubs/9799919799/functions/wait.html)):
 "If the value of WIFEXITED(stat_val) is non-zero, this macro shall evaluate to 
the low-order 8 bits of the status argument that the child process passed to 
_exit() or exit(), or the value the child process returned from main()." For a 
child that a signal ended, the value of `WEXITSTATUS()` is not an exit code, 
and it can be 0.
   
   Two places in nuttx-apps used `WEXITSTATUS()` without `WIFEXITED()`:
   
   - `games/NXDoom/textscreen/txt_fileselect.c`: the file selector took the 
output of its child as the result when `WEXITSTATUS()` was 0. It now takes it 
only if the child exited and its exit status is 0.
   - `testing/ostest/waitpid.c`: three checks compared `WEXITSTATUS()` with the 
expected exit code. They now check `WIFEXITED()` first, and an error prints the 
whole status.
   
   The other users in nuttx-apps already check `WIFEXITED()` first.
   
   Two small commits come first, so that the style check passes on the whole 
files: two older nxstyle errors in `txt_fileselect.c` (a blank line, braces for 
an empty `for` loop), and a spelling error in a message of `waitpid.c`.
   
   ## Impact
   
   None for a child that exits normally. A child that a signal ends is no 
longer taken as a success by the NXDoom file selector or by the ostest waitpid 
checks.
   
   ## Testing
   
   ostest exits with status 0 on `qemu-armv8a:knsh` and `qemu-armv8a:nsh` (QEMU 
with HVF), with this PR. On `qemu-armv8a:nsh` (with `CONFIG_SCHED_WAITPID` and 
`CONFIG_SCHED_CHILD_STATUS`) the three changed waitpid checks run and pass 
(`stat_loc=0e00`, exit status 14). `raspberrypi-4b:nxdoom` (arm64) builds with 
this PR, so `txt_fileselect.c` compiles.
   
   `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