This is an automated email from the ASF dual-hosted git repository. michallenc pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 9589e551aef2b8dc783206cab7ceacc0e4b10fb7 Author: Marco Casaroli <[email protected]> AuthorDate: Mon Oct 19 00:19:21 2026 +0200 drivers: Fix the nxstyle errors in 18 files. Fix the older nxstyle errors in these files: indentation, alignment of braces and comments, and the blank line after declarations. This is a layout change only. The C tokens do not change. tools/nxstyle.c reports no error for them now. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- drivers/analog/adc.c | 6 +- drivers/analog/comp.c | 1 + drivers/i2c/i2c_slave_driver.c | 1 + drivers/misc/dev_ascii.c | 1 + drivers/misc/goldfish_pipe.c | 1 + drivers/misc/rpmsgdev.c | 1 + drivers/net/tun.c | 1 + drivers/note/noteram_driver.c | 542 ++++++++++++++++---------------- drivers/pipes/pipe_common.c | 3 + drivers/power/battery/battery_charger.c | 11 + drivers/power/battery/battery_monitor.c | 13 + drivers/serial/pty.c | 2 + drivers/spi/spi_slave_driver.c | 1 + drivers/syslog/ramlog.c | 1 + drivers/timers/timer.c | 308 +++++++++--------- drivers/usrsock/usrsock_rpmsg_server.c | 1 + drivers/video/fb.c | 40 +-- drivers/video/v4l2_cap.c | 6 +- 18 files changed, 495 insertions(+), 445 deletions(-) diff --git a/drivers/analog/adc.c b/drivers/analog/adc.c index 802d1d7c5e5..af71c49676a 100644 --- a/drivers/analog/adc.c +++ b/drivers/analog/adc.c @@ -141,6 +141,7 @@ static int adc_open(FAR struct file *filep) /* Yes.. perform one time hardware initialization. */ irqstate_t flags = enter_critical_section(); + ret = dev->ad_ops->ao_setup(dev); if (ret == OK) { @@ -378,6 +379,7 @@ static ssize_t adc_read(FAR struct file *filep, FAR char *buffer, */ int16_t data16 = data >> 16; + memcpy(&buffer[nread], &data16, 2); } else if (msglen == 3) @@ -808,12 +810,12 @@ int adc_register(FAR const char *path, FAR struct adc_dev_s *dev) { if (alloc_channel) { - kmm_free(fifo->af_channel); + kmm_free(fifo->af_channel); } if (alloc_data) { - kmm_free(fifo->af_data); + kmm_free(fifo->af_data); } nxsem_destroy(&dev->ad_recv.af_sem); diff --git a/drivers/analog/comp.c b/drivers/analog/comp.c index 8955904f9e0..523d1f2e77a 100644 --- a/drivers/analog/comp.c +++ b/drivers/analog/comp.c @@ -221,6 +221,7 @@ static int comp_open(FAR struct file *filep) /* Yes.. perform one time hardware initialization. */ irqstate_t flags = enter_critical_section(); + ret = dev->ad_ops->ao_setup(dev); if (ret == OK) { diff --git a/drivers/i2c/i2c_slave_driver.c b/drivers/i2c/i2c_slave_driver.c index 90b4c5f29ee..d80c54dd2f1 100644 --- a/drivers/i2c/i2c_slave_driver.c +++ b/drivers/i2c/i2c_slave_driver.c @@ -431,6 +431,7 @@ static int i2c_slave_poll(FAR struct file *filep, FAR struct pollfd *fds, else if (fds->priv != NULL) { FAR struct pollfd **slot = fds->priv; + *slot = NULL; fds->priv = NULL; } diff --git a/drivers/misc/dev_ascii.c b/drivers/misc/dev_ascii.c index 5f783012fe8..1713199ee37 100644 --- a/drivers/misc/dev_ascii.c +++ b/drivers/misc/dev_ascii.c @@ -77,6 +77,7 @@ static ssize_t devascii_read(FAR struct file *filep, FAR char *buffer, size_t len) { size_t i; + for (i = 0; i < len; i++) { buffer[i] = PRINTABLE_FIRST + (filep->f_pos + i) % PRINTABLE_COUNT; diff --git a/drivers/misc/goldfish_pipe.c b/drivers/misc/goldfish_pipe.c index a5319dda2b1..3cb639460ce 100644 --- a/drivers/misc/goldfish_pipe.c +++ b/drivers/misc/goldfish_pipe.c @@ -614,6 +614,7 @@ static void goldfish_pipe_write_addr(FAR void *addr, FAR void *portl, FAR void *porth) { uintptr_t paddr = up_addrenv_va_to_pa(addr); + goldfish_pipe_putreg32((paddr >> 16) >> 16, porth); goldfish_pipe_putreg32(paddr, portl); } diff --git a/drivers/misc/rpmsgdev.c b/drivers/misc/rpmsgdev.c index 540ecc07cbd..e9a5dea80c6 100644 --- a/drivers/misc/rpmsgdev.c +++ b/drivers/misc/rpmsgdev.c @@ -695,6 +695,7 @@ static int rpmsgdev_ioctl(FAR struct file *filep, int cmd, unsigned long arg) if (cmd == FIONBIO && ret >= 0) { FAR int *nonblock = (FAR int *)(uintptr_t)arg; + priv->nonblock = *nonblock; } diff --git a/drivers/net/tun.c b/drivers/net/tun.c index bf5f0893ddb..17454d1988c 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -1277,6 +1277,7 @@ static int tun_ioctl(FAR struct file *filep, int cmd, unsigned long arg) else if (cmd == TUNGETIFF) { FAR struct ifreq *ifr = (FAR struct ifreq *)arg; + if (priv == NULL || ifr == NULL) { return -EINVAL; diff --git a/drivers/note/noteram_driver.c b/drivers/note/noteram_driver.c index 8025b4a4256..7c8a74f654b 100644 --- a/drivers/note/noteram_driver.c +++ b/drivers/note/noteram_driver.c @@ -922,9 +922,9 @@ static int noteram_dump_printf(FAR struct lib_outstream_s *s, } } - ret += lib_bsprintf(s, fmt, note->npt_data); - lib_stream_putc(s, '\n'); - ret++; + ret += lib_bsprintf(s, fmt, note->npt_data); + lib_stream_putc(s, '\n'); + ret++; } return ret; @@ -964,315 +964,320 @@ static int noteram_dump_one(FAR uint8_t *p, FAR struct lib_outstream_s *s, switch (note->nc_type) { #ifdef CONFIG_SCHED_INSTRUMENTATION_SWITCH - case NOTE_START: - { - ret += noteram_dump_header(s, note, ctx); - ret += lib_sprintf(s, "sched_wakeup_new: comm=%s pid=%d " - "target_cpu=%d\n", - note_get_taskname(pid, buf, TASK_NAME_SIZE), - get_pid(pid), cpu); - } - break; - - case NOTE_STOP: - { - /* This note informs the task to be stopped. - * Change current task state for the succeeding NOTE_RESUME. - */ + case NOTE_START: + { + ret += noteram_dump_header(s, note, ctx); + ret += lib_sprintf(s, "sched_wakeup_new: comm=%s pid=%d " + "target_cpu=%d\n", + note_get_taskname(pid, buf, TASK_NAME_SIZE), + get_pid(pid), cpu); + } + break; - cctx->current_state = 0; - } - break; + case NOTE_STOP: + { + /* This note informs the task to be stopped. + * Change current task state for the succeeding NOTE_RESUME. + */ - case NOTE_SUSPEND: - { - FAR struct note_suspend_s *nsu = (FAR struct note_suspend_s *)p; + cctx->current_state = 0; + } + break; - /* This note informs the task to be suspended. - * Preserve the information for the succeeding NOTE_RESUME. - */ + case NOTE_SUSPEND: + { + FAR struct note_suspend_s *nsu = (FAR struct note_suspend_s *)p; - cctx->current_state = nsu->nsu_state; - } - break; + /* This note informs the task to be suspended. + * Preserve the information for the succeeding NOTE_RESUME. + */ - case NOTE_RESUME: - { - /* This note informs the task to be resumed. - * The task switch timing depends on the running context. - */ + cctx->current_state = nsu->nsu_state; + } + break; - cctx->next_pid = pid; - cctx->next_priority = note->nc_priority; + case NOTE_RESUME: + { + /* This note informs the task to be resumed. + * The task switch timing depends on the running context. + */ - if (cctx->intr_nest == 0) - { - /* If not in the interrupt context, the task switch is - * executed immediately. - */ + cctx->next_pid = pid; + cctx->next_priority = note->nc_priority; - ret += noteram_dump_header(s, note, ctx); - ret += noteram_dump_sched_switch(s, note, ctx); - } - else - { - /* If in the interrupt context, the task switch is postponed - * until leaving the interrupt handler. - */ - - ret += noteram_dump_header(s, note, ctx); - ret += lib_sprintf(s, "sched_waking: comm=%s " - "pid=%d target_cpu=%d\n", - note_get_taskname(cctx->next_pid, buf, - TASK_NAME_SIZE), - get_pid(cctx->next_pid), cpu); - cctx->pendingswitch = true; - } - } - break; + if (cctx->intr_nest == 0) + { + /* If not in the interrupt context, the task switch is + * executed immediately. + */ + + ret += noteram_dump_header(s, note, ctx); + ret += noteram_dump_sched_switch(s, note, ctx); + } + else + { + /* If in the interrupt context, the task switch is postponed + * until leaving the interrupt handler. + */ + + ret += noteram_dump_header(s, note, ctx); + ret += lib_sprintf(s, "sched_waking: comm=%s " + "pid=%d target_cpu=%d\n", + note_get_taskname(cctx->next_pid, buf, + TASK_NAME_SIZE), + get_pid(cctx->next_pid), cpu); + cctx->pendingswitch = true; + } + } + break; #endif #ifdef CONFIG_SCHED_INSTRUMENTATION_SYSCALL - case NOTE_SYSCALL_ENTER: - { - FAR struct note_syscall_enter_s *nsc; - int i; - uintptr_t arg; + case NOTE_SYSCALL_ENTER: + { + FAR struct note_syscall_enter_s *nsc; + int i; + uintptr_t arg; - nsc = (FAR struct note_syscall_enter_s *)p; - if (nsc->nsc_nr < CONFIG_SYS_RESERVED || - nsc->nsc_nr >= SYS_maxsyscall) - { - break; - } + nsc = (FAR struct note_syscall_enter_s *)p; + if (nsc->nsc_nr < CONFIG_SYS_RESERVED || + nsc->nsc_nr >= SYS_maxsyscall) + { + break; + } - ret += noteram_dump_header(s, note, ctx); - ret += lib_sprintf(s, "sys_%s(", - g_funcnames[nsc->nsc_nr - CONFIG_SYS_RESERVED]); + ret += noteram_dump_header(s, note, ctx); + ret += lib_sprintf(s, "sys_%s(", + g_funcnames[nsc->nsc_nr - CONFIG_SYS_RESERVED]); - for (i = 0; i < nsc->nsc_argc; i++) - { - arg = nsc->nsc_args[i]; - if (i == 0) - { - ret += lib_sprintf(s, "arg%d: 0x%" PRIxPTR, i, arg); - } - else - { - ret += lib_sprintf(s, ", arg%d: 0x%" PRIxPTR, i, arg); - } - } + for (i = 0; i < nsc->nsc_argc; i++) + { + arg = nsc->nsc_args[i]; + if (i == 0) + { + ret += lib_sprintf(s, "arg%d: 0x%" PRIxPTR, i, arg); + } + else + { + ret += lib_sprintf(s, ", arg%d: 0x%" PRIxPTR, i, arg); + } + } - ret += lib_sprintf(s, ")\n"); - } - break; + ret += lib_sprintf(s, ")\n"); + } + break; - case NOTE_SYSCALL_LEAVE: - { - FAR struct note_syscall_leave_s *nsc; - uintptr_t result; + case NOTE_SYSCALL_LEAVE: + { + FAR struct note_syscall_leave_s *nsc; + uintptr_t result; - nsc = (FAR struct note_syscall_leave_s *)p; - if (nsc->nsc_nr < CONFIG_SYS_RESERVED || - nsc->nsc_nr >= SYS_maxsyscall) - { - break; - } + nsc = (FAR struct note_syscall_leave_s *)p; + if (nsc->nsc_nr < CONFIG_SYS_RESERVED || + nsc->nsc_nr >= SYS_maxsyscall) + { + break; + } - ret += noteram_dump_header(s, note, ctx); - result = nsc->nsc_result; - ret += lib_sprintf(s, "sys_%s -> 0x%" PRIxPTR "\n", - g_funcnames[nsc->nsc_nr - CONFIG_SYS_RESERVED], - result); - } - break; + ret += noteram_dump_header(s, note, ctx); + result = nsc->nsc_result; + ret += lib_sprintf(s, "sys_%s -> 0x%" PRIxPTR "\n", + g_funcnames[nsc->nsc_nr - CONFIG_SYS_RESERVED], + result); + } + break; #endif #ifdef CONFIG_SCHED_INSTRUMENTATION_IRQHANDLER - case NOTE_IRQ_ENTER: - { - FAR struct note_irqhandler_s *nih; + case NOTE_IRQ_ENTER: + { + FAR struct note_irqhandler_s *nih; - nih = (FAR struct note_irqhandler_s *)p; - ret += noteram_dump_header(s, note, ctx); - ret += lib_sprintf(s, "irq_handler_entry: irq=%u name=%pS\n", - nih->nih_irq, (FAR void *)nih->nih_handler); - cctx->intr_nest++; - } - break; + nih = (FAR struct note_irqhandler_s *)p; + ret += noteram_dump_header(s, note, ctx); + ret += lib_sprintf(s, "irq_handler_entry: irq=%u name=%pS\n", + nih->nih_irq, (FAR void *)nih->nih_handler); + cctx->intr_nest++; + } + break; - case NOTE_IRQ_LEAVE: - { - FAR struct note_irqhandler_s *nih; + case NOTE_IRQ_LEAVE: + { + FAR struct note_irqhandler_s *nih; - nih = (FAR struct note_irqhandler_s *)p; - ret += noteram_dump_header(s, note, ctx); - ret += lib_sprintf(s, "irq_handler_exit: irq=%u ret=handled\n", - nih->nih_irq); - cctx->intr_nest--; + nih = (FAR struct note_irqhandler_s *)p; + ret += noteram_dump_header(s, note, ctx); + ret += lib_sprintf(s, "irq_handler_exit: irq=%u ret=handled\n", + nih->nih_irq); + cctx->intr_nest--; - if (cctx->intr_nest <= 0) - { - cctx->intr_nest = 0; - if (cctx->pendingswitch) - { - /* If the pending task switch exists, it is executed here */ - - ret += noteram_dump_header(s, note, ctx); - ret += noteram_dump_sched_switch(s, note, ctx); - } - } - } - break; + if (cctx->intr_nest <= 0) + { + cctx->intr_nest = 0; + if (cctx->pendingswitch) + { + /* If the pending task switch exists, it is executed here */ + + ret += noteram_dump_header(s, note, ctx); + ret += noteram_dump_sched_switch(s, note, ctx); + } + } + } + break; #endif #ifdef CONFIG_SCHED_INSTRUMENTATION_WDOG - case NOTE_WDOG_START: - case NOTE_WDOG_CANCEL: - case NOTE_WDOG_ENTER: - case NOTE_WDOG_LEAVE: - { - FAR struct note_wdog_s *nw; - FAR const char *name[] = - { - "start", "cancel", "enter", "leave", - }; - - nw = (FAR struct note_wdog_s *)p; - ret += noteram_dump_header(s, note, ctx); - ret += lib_sprintf(s, "tracing_mark_write: I|%d|wdog: %s-%pS %p\n", - pid, name[note->nc_type - NOTE_WDOG_START], - (FAR void *)nw->handler, (FAR void *)nw->arg); - } - break; + case NOTE_WDOG_START: + case NOTE_WDOG_CANCEL: + case NOTE_WDOG_ENTER: + case NOTE_WDOG_LEAVE: + { + FAR struct note_wdog_s *nw; + FAR const char *name[] = + { + "start", "cancel", "enter", "leave", + }; + + nw = (FAR struct note_wdog_s *)p; + ret += noteram_dump_header(s, note, ctx); + ret += lib_sprintf(s, "tracing_mark_write: I|%d|wdog: %s-%pS %p\n", + pid, name[note->nc_type - NOTE_WDOG_START], + (FAR void *)nw->handler, (FAR void *)nw->arg); + } + break; #endif #ifdef CONFIG_SCHED_INSTRUMENTATION_CSECTION - case NOTE_CSECTION_ENTER: - case NOTE_CSECTION_LEAVE: - { - struct note_csection_s *ncs; - ncs = (FAR struct note_csection_s *)p; - ret += noteram_dump_header(s, &ncs->ncs_cmn, ctx); - ret += lib_sprintf(s, "tracing_mark_write: %c|%d|critical_section\n", - note->nc_type == NOTE_CSECTION_ENTER ? - 'B' : 'E', pid); - } - break; + case NOTE_CSECTION_ENTER: + case NOTE_CSECTION_LEAVE: + { + struct note_csection_s *ncs; + + ncs = (FAR struct note_csection_s *)p; + ret += noteram_dump_header(s, &ncs->ncs_cmn, ctx); + ret += lib_sprintf(s, + "tracing_mark_write: %c|%d|critical_section\n", + note->nc_type == NOTE_CSECTION_ENTER ? + 'B' : 'E', pid); + } + break; #endif #ifdef CONFIG_SCHED_INSTRUMENTATION_PREEMPTION - case NOTE_PREEMPT_LOCK: - case NOTE_PREEMPT_UNLOCK: - { - struct note_preempt_s *npr; - int16_t count; - npr = (FAR struct note_preempt_s *)p; - count = npr->npr_count; - ret += noteram_dump_header(s, &npr->npr_cmn, ctx); - ret += lib_sprintf(s, "tracing_mark_write: " - "%c|%d|sched_lock:%d\n", - note->nc_type == NOTE_PREEMPT_LOCK ? - 'B' : 'E', pid, count); - } - break; + case NOTE_PREEMPT_LOCK: + case NOTE_PREEMPT_UNLOCK: + { + struct note_preempt_s *npr; + int16_t count; + + npr = (FAR struct note_preempt_s *)p; + count = npr->npr_count; + ret += noteram_dump_header(s, &npr->npr_cmn, ctx); + ret += lib_sprintf(s, "tracing_mark_write: " + "%c|%d|sched_lock:%d\n", + note->nc_type == NOTE_PREEMPT_LOCK ? + 'B' : 'E', pid, count); + } + break; #endif #ifdef CONFIG_SCHED_INSTRUMENTATION_DUMP - case NOTE_DUMP_PRINTF: - { - FAR struct note_printf_s *npt; - - npt = (FAR struct note_printf_s *)p; - ret += noteram_dump_header(s, &npt->npt_cmn, ctx); - ret += lib_sprintf(s, "tracing_mark_write: "); - ret += noteram_dump_printf(s, npt); - } - break; - case NOTE_DUMP_BEGIN: - case NOTE_DUMP_END: - { - FAR struct note_event_s *nbi = (FAR struct note_event_s *)p; - char c = note->nc_type == NOTE_DUMP_BEGIN ? 'B' : 'E'; - int len = note->nc_length - SIZEOF_NOTE_EVENT(0); - uintptr_t ip; - - ip = nbi->nev_ip; - ret += noteram_dump_header(s, &nbi->nev_cmn, ctx); - if (len > 0) - { - ret += lib_sprintf(s, "tracing_mark_write: %c|%d|%.*s\n", - c, pid, len, (FAR const char *)nbi->nev_data); - } - else - { - ret += lib_sprintf(s, "tracing_mark_write: %c|%d|%pS\n", - c, pid, (FAR void *)ip); - } - } - break; - case NOTE_DUMP_MARK: - { - FAR struct note_event_s *nbi = (FAR struct note_event_s *)p; - int len = note->nc_length - SIZEOF_NOTE_EVENT(0); - - ret += noteram_dump_header(s, &nbi->nev_cmn, ctx); - ret += lib_sprintf(s, "tracing_mark_write: I|%d|%.*s\n", - pid, len, (FAR const char *)nbi->nev_data); - } - break; + case NOTE_DUMP_PRINTF: + { + FAR struct note_printf_s *npt; + + npt = (FAR struct note_printf_s *)p; + ret += noteram_dump_header(s, &npt->npt_cmn, ctx); + ret += lib_sprintf(s, "tracing_mark_write: "); + ret += noteram_dump_printf(s, npt); + } + break; + case NOTE_DUMP_BEGIN: + case NOTE_DUMP_END: + { + FAR struct note_event_s *nbi = (FAR struct note_event_s *)p; + char c = note->nc_type == NOTE_DUMP_BEGIN ? 'B' : 'E'; + int len = note->nc_length - SIZEOF_NOTE_EVENT(0); + uintptr_t ip; + + ip = nbi->nev_ip; + ret += noteram_dump_header(s, &nbi->nev_cmn, ctx); + if (len > 0) + { + ret += lib_sprintf(s, "tracing_mark_write: %c|%d|%.*s\n", + c, pid, len, + (FAR const char *)nbi->nev_data); + } + else + { + ret += lib_sprintf(s, "tracing_mark_write: %c|%d|%pS\n", + c, pid, (FAR void *)ip); + } + } + break; + case NOTE_DUMP_MARK: + { + FAR struct note_event_s *nbi = (FAR struct note_event_s *)p; + int len = note->nc_length - SIZEOF_NOTE_EVENT(0); + + ret += noteram_dump_header(s, &nbi->nev_cmn, ctx); + ret += lib_sprintf(s, "tracing_mark_write: I|%d|%.*s\n", + pid, len, (FAR const char *)nbi->nev_data); + } + break; case NOTE_DUMP_BINARY: - { - FAR struct note_event_s *nbi = (FAR struct note_event_s *)p; - int len = note->nc_length - SIZEOF_NOTE_EVENT(0); - int i; + { + FAR struct note_event_s *nbi = (FAR struct note_event_s *)p; + int len = note->nc_length - SIZEOF_NOTE_EVENT(0); + int i; - ret += noteram_dump_header(s, &nbi->nev_cmn, ctx); - ret += lib_sprintf(s, "tracing_mark_write: I|%d|", pid); + ret += noteram_dump_header(s, &nbi->nev_cmn, ctx); + ret += lib_sprintf(s, "tracing_mark_write: I|%d|", pid); - for (i = 0; i < len; i++) - { - ret += lib_sprintf(s, "%02x ", nbi->nev_data[i]); - } + for (i = 0; i < len; i++) + { + ret += lib_sprintf(s, "%02x ", nbi->nev_data[i]); + } - lib_stream_putc(s, '\n'); - ret++; - } - break; - case NOTE_DUMP_COUNTER: - { - FAR struct note_event_s *nbi = (FAR struct note_event_s *)p; - FAR struct note_counter_s *counter; - counter = (FAR struct note_counter_s *)nbi->nev_data; - ret += noteram_dump_header(s, &nbi->nev_cmn, ctx); - ret += lib_sprintf(s, "tracing_mark_write: C|%d|%s|%ld\n", - pid, counter->name, counter->value); - } - break; + lib_stream_putc(s, '\n'); + ret++; + } + break; + case NOTE_DUMP_COUNTER: + { + FAR struct note_event_s *nbi = (FAR struct note_event_s *)p; + FAR struct note_counter_s *counter; + + counter = (FAR struct note_counter_s *)nbi->nev_data; + ret += noteram_dump_header(s, &nbi->nev_cmn, ctx); + ret += lib_sprintf(s, "tracing_mark_write: C|%d|%s|%ld\n", + pid, counter->name, counter->value); + } + break; #endif #ifdef CONFIG_SCHED_INSTRUMENTATION_HEAP - case NOTE_HEAP_ADD: - case NOTE_HEAP_REMOVE: - case NOTE_HEAP_ALLOC: - case NOTE_HEAP_FREE: - { - FAR struct note_heap_s *nmm = (FAR struct note_heap_s *)p; - FAR const char *name[] = - { - "add", "remove", "malloc", "free" - }; - - ret += noteram_dump_header(s, &nmm->nhp_cmn, ctx); - ret += lib_sprintf(s, "tracing_mark_write: C|%d|Heap Usage|%d|%s" - ": heap: %p size:%" PRIiPTR ", address: %p\n", - pid, nmm->used, - name[note->nc_type - NOTE_HEAP_ADD], - nmm->heap, nmm->size, nmm->mem); - } - break; + case NOTE_HEAP_ADD: + case NOTE_HEAP_REMOVE: + case NOTE_HEAP_ALLOC: + case NOTE_HEAP_FREE: + { + FAR struct note_heap_s *nmm = (FAR struct note_heap_s *)p; + FAR const char *name[] = + { + "add", "remove", "malloc", "free" + }; + + ret += noteram_dump_header(s, &nmm->nhp_cmn, ctx); + ret += lib_sprintf(s, "tracing_mark_write: C|%d|Heap Usage|%d|%s" + ": heap: %p size:%" PRIiPTR ", address: %p\n", + pid, nmm->used, + name[note->nc_type - NOTE_HEAP_ADD], + nmm->heap, nmm->size, nmm->mem); + } + break; #endif - default: - break; + default: + break; } /* Return the length of the processed note */ @@ -1320,6 +1325,7 @@ static int noteram_crash_dump(FAR struct notifier_block *nb, { FAR struct noteram_driver_s *drv = container_of(nb, struct noteram_driver_s, nb); + if (action == PANIC_KERNEL) { noteram_dump(drv); diff --git a/drivers/pipes/pipe_common.c b/drivers/pipes/pipe_common.c index 1329f43139b..05a4c7b928b 100644 --- a/drivers/pipes/pipe_common.c +++ b/drivers/pipes/pipe_common.c @@ -824,6 +824,7 @@ int pipecommon_ioctl(FAR struct file *filep, int cmd, unsigned long arg) case PIPEIOC_POLLINTHRD: { pipe_ndx_t threshold = (pipe_ndx_t)arg; + if (threshold >= dev->d_bufsize) { ret = -EINVAL; @@ -838,6 +839,7 @@ int pipecommon_ioctl(FAR struct file *filep, int cmd, unsigned long arg) case PIPEIOC_POLLOUTTHRD: { pipe_ndx_t threshold = (pipe_ndx_t)arg; + if (threshold >= dev->d_bufsize) { ret = -EINVAL; @@ -864,6 +866,7 @@ int pipecommon_ioctl(FAR struct file *filep, int cmd, unsigned long arg) case PIPEIOC_SETSIZE: { size_t size = (size_t)arg; + if (size == 0) { ret = -EINVAL; diff --git a/drivers/power/battery/battery_charger.c b/drivers/power/battery/battery_charger.c index 9bfb9e942d5..2b308529f62 100644 --- a/drivers/power/battery/battery_charger.c +++ b/drivers/power/battery/battery_charger.c @@ -308,6 +308,7 @@ static int bat_charger_ioctl(FAR struct file *filep, int cmd, case BATIOC_STATE: { FAR int *ptr = (FAR int *)((uintptr_t)arg); + if (ptr) { ret = dev->ops->state(dev, ptr); @@ -318,6 +319,7 @@ static int bat_charger_ioctl(FAR struct file *filep, int cmd, case BATIOC_HEALTH: { FAR int *ptr = (FAR int *)((uintptr_t)arg); + if (ptr) { ret = dev->ops->health(dev, ptr); @@ -328,6 +330,7 @@ static int bat_charger_ioctl(FAR struct file *filep, int cmd, case BATIOC_ONLINE: { FAR bool *ptr = (FAR bool *)((uintptr_t)arg); + if (ptr) { ret = dev->ops->online(dev, ptr); @@ -339,6 +342,7 @@ static int bat_charger_ioctl(FAR struct file *filep, int cmd, { int volts; FAR int *voltsp = (FAR int *)((uintptr_t)arg); + if (voltsp) { volts = *voltsp; @@ -351,6 +355,7 @@ static int bat_charger_ioctl(FAR struct file *filep, int cmd, { int amps; FAR int *ampsp = (FAR int *)((uintptr_t)arg); + if (ampsp) { amps = *ampsp; @@ -363,6 +368,7 @@ static int bat_charger_ioctl(FAR struct file *filep, int cmd, { int amps; FAR int *ampsp = (FAR int *)((uintptr_t)arg); + if (ampsp) { amps = *ampsp; @@ -374,6 +380,7 @@ static int bat_charger_ioctl(FAR struct file *filep, int cmd, case BATIOC_OPERATE: { FAR int *ptr = (FAR int *)((uintptr_t)arg); + if (ptr) { ret = dev->ops->operate(dev, (uintptr_t)arg); @@ -384,6 +391,7 @@ static int bat_charger_ioctl(FAR struct file *filep, int cmd, case BATIOC_CHIPID: { FAR unsigned int *ptr = (FAR unsigned int *)((uintptr_t)arg); + if (ptr) { ret = dev->ops->chipid(dev, ptr); @@ -394,6 +402,7 @@ static int bat_charger_ioctl(FAR struct file *filep, int cmd, case BATIOC_GET_VOLTAGE: { FAR int *outvoltsp = (FAR int *)((uintptr_t)arg); + if (outvoltsp) { ret = dev->ops->get_voltage(dev, outvoltsp); @@ -404,6 +413,7 @@ static int bat_charger_ioctl(FAR struct file *filep, int cmd, case BATIOC_VOLTAGE_INFO: { FAR int *outvoltsp = (FAR int *)((uintptr_t)arg); + if (outvoltsp) { ret = dev->ops->voltage_info(dev, outvoltsp); @@ -414,6 +424,7 @@ static int bat_charger_ioctl(FAR struct file *filep, int cmd, case BATIOC_GET_PROTOCOL: { FAR int *ptr = (FAR int *)((uintptr_t)arg); + if (ptr) { if (dev->ops->get_protocol) diff --git a/drivers/power/battery/battery_monitor.c b/drivers/power/battery/battery_monitor.c index 83ca80aa2ed..816c0fbb509 100644 --- a/drivers/power/battery/battery_monitor.c +++ b/drivers/power/battery/battery_monitor.c @@ -309,6 +309,7 @@ static int bat_monitor_ioctl(FAR struct file *filep, int cmd, case BATIOC_STATE: { FAR int *ptr = (FAR int *)((uintptr_t)arg); + if (ptr) { ret = dev->ops->state(dev, ptr); @@ -319,6 +320,7 @@ static int bat_monitor_ioctl(FAR struct file *filep, int cmd, case BATIOC_HEALTH: { FAR int *ptr = (FAR int *)((uintptr_t)arg); + if (ptr) { ret = dev->ops->health(dev, ptr); @@ -329,6 +331,7 @@ static int bat_monitor_ioctl(FAR struct file *filep, int cmd, case BATIOC_ONLINE: { FAR bool *ptr = (FAR bool *)((uintptr_t)arg); + if (ptr) { ret = dev->ops->online(dev, ptr); @@ -339,6 +342,7 @@ static int bat_monitor_ioctl(FAR struct file *filep, int cmd, case BATIOC_VOLTAGE: { FAR int *voltsp = (FAR int *)((uintptr_t)arg); + if (voltsp) { ret = dev->ops->voltage(dev, voltsp); @@ -350,6 +354,7 @@ static int bat_monitor_ioctl(FAR struct file *filep, int cmd, { FAR struct battery_monitor_current_s *current = (FAR struct battery_monitor_current_s *)((uintptr_t)arg); + if (current) { ret = dev->ops->current(dev, current); @@ -360,6 +365,7 @@ static int bat_monitor_ioctl(FAR struct file *filep, int cmd, case BATIOC_OPERATE: { FAR int *ptr = (FAR int *)((uintptr_t)arg); + if (ptr) { ret = dev->ops->operate(dev, (uintptr_t)arg); @@ -371,6 +377,7 @@ static int bat_monitor_ioctl(FAR struct file *filep, int cmd, { FAR struct battery_monitor_voltage_s *ptr = (FAR struct battery_monitor_voltage_s *)((uintptr_t)arg); + if (ptr) { ret = dev->ops->cell_voltage(dev, ptr); @@ -382,6 +389,7 @@ static int bat_monitor_ioctl(FAR struct file *filep, int cmd, { FAR struct battery_monitor_balance_s *ptr = (FAR struct battery_monitor_balance_s *)((uintptr_t)arg); + if (ptr) { ret = dev->ops->balance(dev, ptr); @@ -401,6 +409,7 @@ static int bat_monitor_ioctl(FAR struct file *filep, int cmd, { FAR struct battery_monitor_limits_s *ptr = (FAR struct battery_monitor_limits_s *)((uintptr_t)arg); + if (ptr) { ret = dev->ops->setlimits(dev, ptr); @@ -412,6 +421,7 @@ static int bat_monitor_ioctl(FAR struct file *filep, int cmd, { FAR struct battery_monitor_switches_s *ptr = (FAR struct battery_monitor_switches_s *)((uintptr_t)arg); + if (ptr) { ret = dev->ops->chgdsg(dev, ptr); @@ -431,6 +441,7 @@ static int bat_monitor_ioctl(FAR struct file *filep, int cmd, { FAR struct battery_monitor_temperature_s *ptr = (FAR struct battery_monitor_temperature_s *)((uintptr_t)arg); + if (ptr) { ret = dev->ops->temperature(dev, ptr); @@ -441,6 +452,7 @@ static int bat_monitor_ioctl(FAR struct file *filep, int cmd, case BATIOC_COULOMBS: { FAR int *coulombp = (FAR int *)((uintptr_t)arg); + if (coulombp) { ret = dev->ops->coulombs(dev, coulombp); @@ -451,6 +463,7 @@ static int bat_monitor_ioctl(FAR struct file *filep, int cmd, case BATIOC_CHIPID: { FAR unsigned int *ptr = (FAR unsigned int *)((uintptr_t)arg); + if (ptr) { ret = dev->ops->chipid(dev, ptr); diff --git a/drivers/serial/pty.c b/drivers/serial/pty.c index c4f2eab5ce7..636b30678b1 100644 --- a/drivers/serial/pty.c +++ b/drivers/serial/pty.c @@ -757,6 +757,7 @@ static int pty_ioctl(FAR struct file *filep, int cmd, unsigned long arg) case TIOCGPTN: /* Get Pty Number (of pty-mux device): FAR int* */ { FAR int *ptyno = (FAR int *)((uintptr_t)arg); + if (ptyno == NULL) { ret = -EINVAL; @@ -800,6 +801,7 @@ static int pty_ioctl(FAR struct file *filep, int cmd, unsigned long arg) case TIOCGPTLCK: /* Get Pty lock state: FAR int* */ { FAR int *ptr = (FAR int *)((uintptr_t)arg); + if (ptr == NULL) { ret = -EINVAL; diff --git a/drivers/spi/spi_slave_driver.c b/drivers/spi/spi_slave_driver.c index 6e040f4ed18..df4d3231de2 100644 --- a/drivers/spi/spi_slave_driver.c +++ b/drivers/spi/spi_slave_driver.c @@ -656,6 +656,7 @@ static size_t spi_slave_getdata(FAR struct spi_slave_dev_s *dev, { #ifdef CONFIG_SPI_SLAVE_DRIVER_COLORIZE_TX_BUFFER FAR struct spi_slave_driver_s *priv = (FAR struct spi_slave_driver_s *)dev; + *data = priv->tx_buffer; return BYTES2WORDS(CONFIG_SPI_SLAVE_DRIVER_COLORIZE_NUM_BYTES); #else diff --git a/drivers/syslog/ramlog.c b/drivers/syslog/ramlog.c index e35a65ae0a3..562d99f982c 100644 --- a/drivers/syslog/ramlog.c +++ b/drivers/syslog/ramlog.c @@ -250,6 +250,7 @@ static uint32_t ramlog_bufferused(FAR struct ramlog_dev_s *priv, FAR struct ramlog_user_s *upriv) { uint32_t used = priv->rl_header->rl_head - upriv->rl_tail; + return used > priv->rl_bufsize ? priv->rl_bufsize : used; } diff --git a/drivers/timers/timer.c b/drivers/timers/timer.c index 71ff26135e9..8415e4d1b93 100644 --- a/drivers/timers/timer.c +++ b/drivers/timers/timer.c @@ -280,173 +280,173 @@ static int timer_ioctl(FAR struct file *filep, int cmd, unsigned long arg) switch (cmd) { - /* cmd: TCIOC_START - * Description: Start the timer - * Argument: Ignored - */ - - case TCIOC_START: - { - /* Start the timer, resetting the time to the current timeout */ - - ret = TIMER_START(lower); - } - break; - - /* cmd: TCIOC_STOP - * Description: Stop the timer - * Argument: Ignored - */ - - case TCIOC_STOP: - { - /* Stop the timer */ - - ret = TIMER_STOP(lower); - nxsig_cancel_notification(&upper->work); - } - break; - - /* cmd: TCIOC_GETSTATUS - * Description: Get the status of the timer. - * Argument: A writeable pointer to struct timer_status_s. - */ - - case TCIOC_GETSTATUS: - { - FAR struct timer_status_s *status; - - /* Get the current timer status */ - - status = (FAR struct timer_status_s *)((uintptr_t)arg); - if (status) - { - ret = TIMER_GETSTATUS(lower, status); - } - else - { - ret = -EINVAL; - } - } - break; - - case TCIOC_TICK_GETSTATUS: - { - FAR struct timer_status_s *status; - - /* Get the current timer status */ - - status = (FAR struct timer_status_s *)((uintptr_t)arg); - if (status) - { - ret = TIMER_TICK_GETSTATUS(lower, status); - } - else - { - ret = -EINVAL; - } - } - break; - - /* cmd: TCIOC_SETTIMEOUT - * Description: Reset the timeout to this value - * Argument: A 32-bit timeout value in microseconds. - * - * TODO: pass pointer to uint64 ns? Need to determine if these timers - * are 16 or 32 bit... - */ - - case TCIOC_SETTIMEOUT: - { - /* Set a new timeout value (and reset the timer) */ - - ret = TIMER_SETTIMEOUT(lower, (uint32_t)arg); - } - break; - - /* cmd: TCIOC_TICK_SETTIMEOUT - * Description: Reset the timeout to this value - * Argument: A 32-bit timeout value in ticks. - * - * TODO: pass pointer to uint64 ns? Need to determine if these timers - * are 16 or 32 bit... - */ - - case TCIOC_TICK_SETTIMEOUT: - { - /* Set a new timeout value (and reset the timer) */ - - ret = TIMER_TICK_SETTIMEOUT(lower, (uint32_t)arg); - } - break; - - /* cmd: TCIOC_NOTIFICATION - * Description: Notify application via a signal when the timer expires. - * Argument: signal information - */ + /* cmd: TCIOC_START + * Description: Start the timer + * Argument: Ignored + */ + + case TCIOC_START: + { + /* Start the timer, resetting the time to the current timeout */ + + ret = TIMER_START(lower); + } + break; + + /* cmd: TCIOC_STOP + * Description: Stop the timer + * Argument: Ignored + */ + + case TCIOC_STOP: + { + /* Stop the timer */ + + ret = TIMER_STOP(lower); + nxsig_cancel_notification(&upper->work); + } + break; + + /* cmd: TCIOC_GETSTATUS + * Description: Get the status of the timer. + * Argument: A writeable pointer to struct timer_status_s. + */ + + case TCIOC_GETSTATUS: + { + FAR struct timer_status_s *status; + + /* Get the current timer status */ + + status = (FAR struct timer_status_s *)((uintptr_t)arg); + if (status) + { + ret = TIMER_GETSTATUS(lower, status); + } + else + { + ret = -EINVAL; + } + } + break; + + case TCIOC_TICK_GETSTATUS: + { + FAR struct timer_status_s *status; + + /* Get the current timer status */ + + status = (FAR struct timer_status_s *)((uintptr_t)arg); + if (status) + { + ret = TIMER_TICK_GETSTATUS(lower, status); + } + else + { + ret = -EINVAL; + } + } + break; + + /* cmd: TCIOC_SETTIMEOUT + * Description: Reset the timeout to this value + * Argument: A 32-bit timeout value in microseconds. + * + * TODO: pass pointer to uint64 ns? Need to determine if these timers + * are 16 or 32 bit... + */ + + case TCIOC_SETTIMEOUT: + { + /* Set a new timeout value (and reset the timer) */ + + ret = TIMER_SETTIMEOUT(lower, (uint32_t)arg); + } + break; + + /* cmd: TCIOC_TICK_SETTIMEOUT + * Description: Reset the timeout to this value + * Argument: A 32-bit timeout value in ticks. + * + * TODO: pass pointer to uint64 ns? Need to determine if these timers + * are 16 or 32 bit... + */ + + case TCIOC_TICK_SETTIMEOUT: + { + /* Set a new timeout value (and reset the timer) */ + + ret = TIMER_TICK_SETTIMEOUT(lower, (uint32_t)arg); + } + break; + + /* cmd: TCIOC_NOTIFICATION + * Description: Notify application via a signal when the timer expires. + * Argument: signal information + */ #ifndef CONFIG_DISABLE_ALL_SIGNALS - case TCIOC_NOTIFICATION: - { - FAR struct timer_notify_s *notify = - (FAR struct timer_notify_s *)((uintptr_t)arg); - - if (notify != NULL) - { - memcpy(&upper->notify, notify, sizeof(*notify)); - ret = timer_setcallback((FAR void *)upper, timer_notifier, - (FAR void *)upper); - } - else - { - ret = -EINVAL; - } - } - break; + case TCIOC_NOTIFICATION: + { + FAR struct timer_notify_s *notify = + (FAR struct timer_notify_s *)((uintptr_t)arg); + + if (notify != NULL) + { + memcpy(&upper->notify, notify, sizeof(*notify)); + ret = timer_setcallback((FAR void *)upper, timer_notifier, + (FAR void *)upper); + } + else + { + ret = -EINVAL; + } + } + break; #endif - /* cmd: TCIOC_MAXTIMEOUT - * Description: Get the maximum supported timeout value - * Argument: A 32-bit timeout value in microseconds. - */ + /* cmd: TCIOC_MAXTIMEOUT + * Description: Get the maximum supported timeout value + * Argument: A 32-bit timeout value in microseconds. + */ - case TCIOC_MAXTIMEOUT: - { - /* Get the maximum supported timeout value */ + case TCIOC_MAXTIMEOUT: + { + /* Get the maximum supported timeout value */ - ret = TIMER_MAXTIMEOUT(lower, (FAR uint32_t *)arg); - } - break; + ret = TIMER_MAXTIMEOUT(lower, (FAR uint32_t *)arg); + } + break; - /* cmd: TCIOC_TICK_MAXTIMEOUT - * Description: Get the maximum supported timeout value - * Argument: A 32-bit timeout value in ticks. - */ + /* cmd: TCIOC_TICK_MAXTIMEOUT + * Description: Get the maximum supported timeout value + * Argument: A 32-bit timeout value in ticks. + */ - case TCIOC_TICK_MAXTIMEOUT: - { - /* Get the maximum supported timeout value */ + case TCIOC_TICK_MAXTIMEOUT: + { + /* Get the maximum supported timeout value */ - ret = TIMER_TICK_MAXTIMEOUT(lower, (FAR uint32_t *)arg); - } - break; + ret = TIMER_TICK_MAXTIMEOUT(lower, (FAR uint32_t *)arg); + } + break; - /* Any unrecognized IOCTL commands might be platform-specific ioctl - * commands - */ + /* Any unrecognized IOCTL commands might be platform-specific ioctl + * commands + */ - default: - { - tmrinfo("Forwarding unrecognized cmd: %d arg: %ld\n", cmd, arg); + default: + { + tmrinfo("Forwarding unrecognized cmd: %d arg: %ld\n", cmd, arg); - /* An ioctl commands that are not recognized by the "upper-half" - * driver are forwarded to the lower half driver through this - * method. - */ + /* An ioctl commands that are not recognized by the "upper-half" + * driver are forwarded to the lower half driver through this + * method. + */ - ret = TIMER_IOCTL(lower, cmd, arg); - } - break; + ret = TIMER_IOCTL(lower, cmd, arg); + } + break; } nxmutex_unlock(&upper->lock); diff --git a/drivers/usrsock/usrsock_rpmsg_server.c b/drivers/usrsock/usrsock_rpmsg_server.c index cebd88adc34..abb064e27ee 100644 --- a/drivers/usrsock/usrsock_rpmsg_server.c +++ b/drivers/usrsock/usrsock_rpmsg_server.c @@ -595,6 +595,7 @@ static int usrsock_rpmsg_recvfrom_handler(FAR struct rpmsg_endpoint *ept, SOCK_STREAM) { FAR struct socket_conn_s *conn = priv->socks[req->usockid].s_conn; + if (outaddrlen < inaddrlen) { memcpy((FAR void *)(ack + 1) + outaddrlen, diff --git a/drivers/video/fb.c b/drivers/video/fb.c index ca6ebe4a866..dc3d3d6689b 100644 --- a/drivers/video/fb.c +++ b/drivers/video/fb.c @@ -695,33 +695,33 @@ static off_t fb_seek(FAR struct file *filep, off_t offset, int whence) switch (whence) { - case SEEK_CUR: - newpos = filep->f_pos + offset; - break; + case SEEK_CUR: + newpos = filep->f_pos + offset; + break; - case SEEK_SET: - newpos = offset; - break; + case SEEK_SET: + newpos = offset; + break; - case SEEK_END: + case SEEK_END: - /* Get panel info */ + /* Get panel info */ - ret = fb_get_panelinfo(fb, &panelinfo, priv->overlay); + ret = fb_get_panelinfo(fb, &panelinfo, priv->overlay); - if (ret < 0) - { - return ret; - } + if (ret < 0) + { + return ret; + } - newpos = panelinfo.fblen + offset; - break; + newpos = panelinfo.fblen + offset; + break; - default: + default: - /* Return EINVAL if the whence argument is invalid */ + /* Return EINVAL if the whence argument is invalid */ - return -EINVAL; + return -EINVAL; } /* Opengroup.org: @@ -1285,7 +1285,7 @@ static int fb_ioctl(FAR struct file *filep, int cmd, unsigned long arg) varinfo->blue.length = 8; varinfo->transp.length = 8; break; - } + } nxmutex_unlock(&fb->lock); } @@ -1486,6 +1486,7 @@ static int fb_poll(FAR struct file *filep, struct pollfd *fds, bool setup) /* This is a request to tear down the poll. */ FAR struct pollfd **slot = (FAR struct pollfd **)fds->priv; + *slot = NULL; fds->priv = NULL; } @@ -1511,6 +1512,7 @@ static int fb_get_panelinfo(FAR struct fb_chardev_s *fb, if (overlay != FB_NO_OVERLAY) { struct fb_overlayinfo_s oinfo; + DEBUGASSERT(fb->vtable->getoverlayinfo != NULL); memset(&oinfo, 0, sizeof(oinfo)); ret = fb->vtable->getoverlayinfo(fb->vtable, overlay, &oinfo); diff --git a/drivers/video/v4l2_cap.c b/drivers/video/v4l2_cap.c index 6f04c0f7b12..44eee96e4aa 100644 --- a/drivers/video/v4l2_cap.c +++ b/drivers/video/v4l2_cap.c @@ -855,6 +855,7 @@ static void change_capture_state(FAR capture_mng_t *cmng, { FAR vbuf_container_t *container = video_framebuff_get_vacant_container(&cmng->capture_inf.bufinf); + if (container != NULL) { cmng->capture_inf.seqnum = 0; @@ -875,7 +876,7 @@ static void change_capture_state(FAR capture_mng_t *cmng, else if (current_state == CAPTURE_STATE_CAPTURE && next_state != CAPTURE_STATE_CAPTURE) { - stop_capture(cmng, V4L2_BUF_TYPE_VIDEO_CAPTURE); + stop_capture(cmng, V4L2_BUF_TYPE_VIDEO_CAPTURE); } cmng->capture_inf.state = updated_next_state; @@ -1226,6 +1227,7 @@ static void cleanup_streamresources(FAR capture_type_inf_t *type_inf, static void cleanup_scene_parameter(FAR capture_scene_params_t **vsp) { FAR capture_scene_params_t *sp = *vsp; + ASSERT(sp); if (sp->gamma_curve != NULL) @@ -2225,7 +2227,7 @@ static int capture_reqbufs(FAR struct file *filep, { if (imgdata->ops->free) { - imgdata->ops->free(imgdata, type_inf->bufheap); + imgdata->ops->free(imgdata, type_inf->bufheap); } else {
