This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 2d66436185df293ca3832c2e326067892e0fcebc
Author: guanyi3 <[email protected]>
AuthorDate: Fri Mar 13 16:41:23 2026 +0800

    drivers/devfreq: guard backtrace code with CONFIG_LIBC_BACKTRACE_DEPTH
    
    
    When CONFIG_LIBC_BACKTRACE_DEPTH is not set or <= 0, backtrace_get()
    is a macro that always sets depth to 0, making the for-loop body
    unreachable (Coverity CID 8405332 DEADCODE).
    
    Wrap backtrace_get() call, the loop, and related variable declarations
    with #if CONFIG_LIBC_BACKTRACE_DEPTH > 0 to eliminate the dead code
    and avoid unused variable warnings.
    
    Signed-off-by: guanyi3 <[email protected]>
---
 drivers/devfreq/devfreq_procfs.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/devfreq/devfreq_procfs.c b/drivers/devfreq/devfreq_procfs.c
index 99f92d50ac2..d97b2f3deb1 100644
--- a/drivers/devfreq/devfreq_procfs.c
+++ b/drivers/devfreq/devfreq_procfs.c
@@ -169,8 +169,10 @@ static ssize_t devfreq_read(FAR struct file *filep,
   FAR struct devfreq_s *devfreq = devfreq_procfs->devfreq;
 #ifdef CONFIG_DEVFREQ_PROCFS_QOS
   FAR struct qos_request_s *qos;
-  void **stack;
+#if defined(CONFIG_LIBC_BACKTRACE_BUFFSIZE) && CONFIG_LIBC_BACKTRACE_BUFFSIZE 
> 0
+  FAR void **stack;
   int depth;
+#endif
 #endif
   off_t offset = filep->f_pos;
   size_t i;
@@ -209,14 +211,16 @@ static ssize_t devfreq_read(FAR struct file *filep,
                  " qos_list(min, max, backtrace):\n");
   plist_for_each_entry(qos, &devfreq->constraints.min_requests, min_req)
     {
-      stack = backtrace_get(qos->backtrace, &depth);
       procfs_sprintf(buffer, buflen, &offset,
                      " %"PRIu32", %"PRIu32",",
                      qos->min_req.prio, qos->max_req.prio);
+#if defined(CONFIG_LIBC_BACKTRACE_BUFFSIZE) && CONFIG_LIBC_BACKTRACE_BUFFSIZE 
> 0
+      stack = backtrace_get(qos->backtrace, &depth);
       for (i = 0; i < depth; i++)
         {
           procfs_sprintf(buffer, buflen, &offset, " %p", stack[i]);
         }
+#endif
 
       procfs_sprintf(buffer, buflen, &offset, "\n");
     }

Reply via email to