This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit c31e6a93f3f4d068c1b490a521ffec24df119a2f Author: Bowen Wang <[email protected]> AuthorDate: Mon Sep 8 17:13:23 2025 +0800 drivers/rpmsg: define g_rpmsg_dev_ops in its only user MISRA C-2012 Rule 8.9: an object should be declared at block scope if its identifier only appears in a single function. g_rpmsg_dev_ops is only used by rpmsg_register(), so move it there as a static const. MISRA C-2012 Rule 10.4: compare the uint16_t nrx with an unsigned constant in rpmsg_init_workrx(). No functional change. Signed-off-by: Bowen Wang <[email protected]> --- drivers/rpmsg/rpmsg.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/rpmsg/rpmsg.c b/drivers/rpmsg/rpmsg.c index 535832de563..e43ca5090ce 100644 --- a/drivers/rpmsg/rpmsg.c +++ b/drivers/rpmsg/rpmsg.c @@ -115,16 +115,6 @@ static struct list_node g_rpmsg = LIST_INITIAL_VALUE(g_rpmsg); static rw_semaphore_t g_rpmsg_lock = RWSEM_INITIALIZER; -static const struct file_operations g_rpmsg_dev_ops = -{ - NULL, /* open */ - NULL, /* close */ - NULL, /* read */ - NULL, /* write */ - NULL, /* seek */ - rpmsg_dev_ioctl, /* ioctl */ -}; - #if CONFIG_RPMSG_POOL_COUNT > 0 MEMPOOL_DEFINE(g_rpmsg_pool, CONFIG_RPMSG_POOL_SIZE, CONFIG_RPMSG_POOL_COUNT, CONFIG_RPMSG_POOL_COUNT, 0); @@ -255,7 +245,7 @@ static int rpmsg_init_workrx(FAR struct rpmsg_s *rpmsg, uint16_t nrx) uint16_t i; int ret = OK; - if (nrx != 0) + if (nrx != 0u) { workrx = kmm_zalloc(nrx * sizeof(struct rpmsg_work_s)); if (workrx != NULL) @@ -829,6 +819,16 @@ void rpmsg_device_destroy(FAR struct rpmsg_s *rpmsg) int rpmsg_register(FAR const char *path, FAR struct rpmsg_s *rpmsg, FAR const struct rpmsg_ops_s *ops, uint16_t nrx) { + static const struct file_operations g_rpmsg_dev_ops = + { + NULL, /* open */ + NULL, /* close */ + NULL, /* read */ + NULL, /* write */ + NULL, /* seek */ + rpmsg_dev_ioctl, /* ioctl */ + }; + struct metal_init_params params = METAL_INIT_DEFAULTS; int ret;
