This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push:
new 15b081f02 nshlib: fix top command sorting result error
15b081f02 is described below
commit 15b081f02dd374b173b983dfdfeba75f229d2d35
Author: yinshengkai <[email protected]>
AuthorDate: Wed Oct 16 20:14:03 2024 +0800
nshlib: fix top command sorting result error
qsort expects the return value to be -1,0,1
Signed-off-by: yinshengkai <[email protected]>
---
nshlib/nsh_proccmds.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/nshlib/nsh_proccmds.c b/nshlib/nsh_proccmds.c
index 8f8da04ed..73f97aa11 100644
--- a/nshlib/nsh_proccmds.c
+++ b/nshlib/nsh_proccmds.c
@@ -780,12 +780,16 @@ static int top_cmpcpuload(FAR const void *item1, FAR
const void *item2)
s2 = status2->td_cpuload;
while (*s1++ != '.');
while (*s2++ != '.');
+ if (*s2 == *s1)
+ {
+ return 0;
+ }
- return *s2 > *s1;
+ return *s2 > *s1 ? 1 : -1;
}
else
{
- return load2 > load1;
+ return load2 > load1 ? 1 : -1;
}
}