mirror of
https://github.com/apache/nuttx.git
synced 2026-08-09 22:45:08 +00:00
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 <guanyi3@xiaomi.com>
This commit is contained in:
parent
31041f84ea
commit
2d66436185
1 changed files with 6 additions and 2 deletions
|
|
@ -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");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue