CV-Bowen opened a new pull request, #22058:
URL: https://github.com/apache/nuttx/pull/22058

   ## Summary
   
   Static analysis cleanups of the rpmsg core (`drivers/rpmsg/rpmsg.c`) and
   the rpmsg virtio transport (`drivers/rpmsg/rpmsg_virtio.c`), found by
   Coverity (HIS metrics and MISRA C-2012), and three fixes to bugs the
   first rework introduced, kept as separate commits in the order they were
   made.
   
   - `use a single exit point` (3 commits, HIS_metric_violation RETURN):
     functions that returned from several places now keep the result in a
     local variable and return once. The `goto again` loop in
     `rpmsg_register_callback()` becomes a `while` loop that restarts the
     walk of the bind list after each match; the `goto err` paths in
     `rpmsg_create_wqueues()` and `rpmsg_virtio_probe_cpuname()` become
     `else` branches.
   - `restart the bind list walk after each match`,
     `fix the check in rpmsg_alloc_buf()`,
     `fix rpmsg_ns_bind() and rpmsg_register_callback()`: fixes to the
     first commit (missing `break`s, an inverted condition, `again` set
     only once, the lock release in `rpmsg_ns_bind()`).
   - `define g_rpmsg_dev_ops / g_rpmsg_virtio_ops in its only user`
     (Rule 8.9): the two ops tables move into the only function that uses
     them, as `static const`.
   - `use unsigned types for ring counts` (Rule 10.4): the vring indices
     and counts in `rpmsg_virtio_buffer_nused()` and
     `rpmsg_virtio_dump_buffer()` are `uint16_t`, printed with `%u`.
   - `initialize variables set through a pointer` (Rule 9.1).
   
   One behaviour change: on master `rpmsg_ns_bind()` returns with
   `g_rpmsg_lock` still read-held when it fails to allocate the bind
   record. After this PR the lock is released on that path too.
   
   The intermediate commits between the first one and its fixes are not
   bisect-safe for the bind paths; the series as a whole is what was
   tested.
   
   ## Impact
   
   No API, Kconfig or behaviour change, except the lock release above on
   an out-of-memory path.
   
   ## Testing
   
   Host: Ubuntu 22.04.5 LTS x86_64, QEMU version 10.2.1, sim: cc (Ubuntu 
13.1.0-8ubuntu1~22.04) 13.1.0, qemu-armv8a: aarch64-none-elf-gcc (Arm GNU 
Toolchain 12.2.Rel1 (Build arm-12.24)) 12.2.1 20221205
   
   Every commit builds sim:rpserver, sim:rpproxy, qemu-armv8a:rpserver and
   qemu-armv8a:rpproxy with no warnings.
   
   sim:rpserver + sim:rpproxy and qemu-armv8a:rpserver + qemu-armv8a:rpproxy
   (unchanged configs), same cases on master and on this PR: the fixed
   rpmsg cases (dump, ping, rpmsgfs mount and read), plus
   `rpmsg ping all 200 2048 3 0` on both nodes and `rpmsg dump all`
   (verbose, walks `rpmsg_virtio_dump()` and `rpmsg_virtio_dump_buffer()`)
   on both nodes.
   
   | | master | this PR |
   |---|---|---|
   | sim cases | 11/11 | 11/11 |
   | qemu-armv8a cases | 11/11 | 11/11 |
   | `rpmsg dump all` output (endpoints, vq state, buffer counts; addresses and 
ring indices masked) | - | identical to master, sim and qemu-armv8a |
   | sim `rpmsg ping all 200 2048 3 0` avg, server / proxy | 9.998 / 9.999 ms | 
9.999 / 9.999 ms |
   
   The name service paths in `rpmsg_ns_bind()` were checked with a
   test-only `syslog()` (not in this PR) on the "no service yet, keep a
   bind record" branch and on the replay branch of
   `rpmsg_register_callback()`: on sim the same three records are kept on
   every boot, on master and on this PR (3 runs each):
   
   ```
   P113 defer rpmsg-ping
   P113 defer rpmsg-ping-rt
   P113 defer rpmsg-test
   ```
   
   Not tested: the replay branch of `rpmsg_register_callback()` (no service
   in these configs registers after its name was announced), and the
   error paths (allocation, `register_driver()`, `rpmsg_init_vdev()` and
   work queue creation failures).
   
   No regression in rpmsg: sim:rpserver/rpproxy and 
qemu-armv8a:rpserver/rpproxy boot and pass the fixed rpmsg cases (dump, ping, 
rpmsgfs; 22/22). qemu-armv8a was built with LIBC_ENVPATH and BINFMT_CHECKEXEC 
disabled, which current master needs for nxinit to start nsh there; unrelated 
to this change.
   


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