acassis commented on code in PR #8270:
URL: https://github.com/apache/nuttx/pull/8270#discussion_r1088896123


##########
fs/procfs/fs_procfscpuload.c:
##########
@@ -201,26 +201,46 @@ static ssize_t cpuload_read(FAR struct file *filep, FAR 
char *buffer,
 
   if (filep->f_pos == 0)
     {
-      struct cpuload_s cpuload;
+      uint32_t total = 0;
+      uint32_t active = 0;
       uint32_t intpart;
       uint32_t fracpart;
 
       /* Sample the counts for the IDLE thread.  clock_cpuload should only
        * fail if the PID is not valid.  This, however, should never happen
        * for the IDLE thread.
        */
+#ifdef CONFIG_SMP
+      struct cpuload_s cpuloads[CONFIG_SMP_NCPUS];
+      uint32_t i;
+
+      for (i = 0; i < CONFIG_SMP_NCPUS; i++)
+        {
+          DEBUGVERIFY(clock_cpuload(i, &cpuloads[i]));
+          active += cpuloads[i].active;
+        }
+
+      total = cpuloads[0].total;
+#else
+      struct cpuload_s cpuload;
 
       DEBUGVERIFY(clock_cpuload(0, &cpuload));
+      active = cpuload.active;
+      total = cpuload.total;
+#endif
+
+      if (active > total)
+          active = total;

Review Comment:
   Please add { } even for single line IF



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to