You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2026/10/15 11:47:52 UTC

(nuttx-apps) 01/06: logging/nxscope: skip the sample divider when it is disabled

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-apps.git

commit 0932430d44386d2da403af8098ed6144854b5c89
Author: raiden00pl <ra...@railab.me>
AuthorDate: Mon Aug 10 20:30:54 2026 +0200

    logging/nxscope: skip the sample divider when it is disabled
    
    With div == 0 the modulo is always zero, so the counter update and the
    division ran on every sample of every undecimated stream for nothing.
    Guard them; the decimating path is unchanged.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: raiden00pl <ra...@railab.me>
---
 logging/nxscope/nxscope_chan.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/logging/nxscope/nxscope_chan.c b/logging/nxscope/nxscope_chan.c
index 5fb9e9b92..89971479e 100644
--- a/logging/nxscope/nxscope_chan.c
+++ b/logging/nxscope/nxscope_chan.c
@@ -176,11 +176,14 @@ static int nxscope_ch_validate(FAR struct nxscope_s *s, uint8_t ch,
 #ifdef CONFIG_LOGGING_NXSCOPE_DIVIDER
   /* Handle sample rate divider */
 
-  s->cntr[ch] += 1;
-  if (s->cntr[ch] % (s->chinfo[ch].div + 1) != 0)
+  if (s->chinfo[ch].div != 0)
     {
-      ret = -EAGAIN;
-      goto errout;
+      s->cntr[ch] += 1;
+      if (s->cntr[ch] % (s->chinfo[ch].div + 1) != 0)
+        {
+          ret = -EAGAIN;
+          goto errout;
+        }
     }
 #endif