All compare_*() functions (corresponding to the various sort orders)
take void pointers as they are passed to qsort(3), so the usual casting
inside follows.

Yet, as SETORDER() eventually assigns the actual keys, it can also
directly do so from the function arguments instead of an intermediate
structs that are the same inside each function.

No object change.

OK?


Index: machine.c
===================================================================
RCS file: /cvs/src/usr.bin/top/machine.c,v
retrieving revision 1.97
diff -u -p -r1.97 machine.c
--- machine.c   28 Jun 2019 13:35:05 -0000      1.97
+++ machine.c   6 Oct 2019 13:14:57 -0000
@@ -636,11 +636,11 @@ extern int rev_order;
 /* remove one level of indirection and set sort order */
 #define SETORDER do { \
                if (rev_order) { \
-                       p1 = *(struct kinfo_proc **) pp2; \
-                       p2 = *(struct kinfo_proc **) pp1; \
+                       p1 = *(struct kinfo_proc **) v2; \
+                       p2 = *(struct kinfo_proc **) v1; \
                } else { \
-                       p1 = *(struct kinfo_proc **) pp1; \
-                       p2 = *(struct kinfo_proc **) pp2; \
+                       p1 = *(struct kinfo_proc **) v1; \
+                       p2 = *(struct kinfo_proc **) v2; \
                } \
        } while (0)
 
@@ -648,8 +648,6 @@ extern int rev_order;
 static int
 compare_cpu(const void *v1, const void *v2)
 {
-       struct proc **pp1 = (struct proc **) v1;
-       struct proc **pp2 = (struct proc **) v2;
        struct kinfo_proc *p1, *p2;
        int result;
 
@@ -669,8 +667,6 @@ compare_cpu(const void *v1, const void *
 static int
 compare_size(const void *v1, const void *v2)
 {
-       struct proc **pp1 = (struct proc **) v1;
-       struct proc **pp2 = (struct proc **) v2;
        struct kinfo_proc *p1, *p2;
        int result;
 
@@ -690,8 +686,6 @@ compare_size(const void *v1, const void 
 static int
 compare_res(const void *v1, const void *v2)
 {
-       struct proc **pp1 = (struct proc **) v1;
-       struct proc **pp2 = (struct proc **) v2;
        struct kinfo_proc *p1, *p2;
        int result;
 
@@ -711,8 +705,6 @@ compare_res(const void *v1, const void *
 static int
 compare_time(const void *v1, const void *v2)
 {
-       struct proc **pp1 = (struct proc **) v1;
-       struct proc **pp2 = (struct proc **) v2;
        struct kinfo_proc *p1, *p2;
        int result;
 
@@ -732,8 +724,6 @@ compare_time(const void *v1, const void 
 static int
 compare_prio(const void *v1, const void *v2)
 {
-       struct proc   **pp1 = (struct proc **) v1;
-       struct proc   **pp2 = (struct proc **) v2;
        struct kinfo_proc *p1, *p2;
        int result;
 
@@ -752,8 +742,6 @@ compare_prio(const void *v1, const void 
 static int
 compare_pid(const void *v1, const void *v2)
 {
-       struct proc **pp1 = (struct proc **) v1;
-       struct proc **pp2 = (struct proc **) v2;
        struct kinfo_proc *p1, *p2;
        int result;
 
@@ -773,8 +761,6 @@ compare_pid(const void *v1, const void *
 static int
 compare_cmd(const void *v1, const void *v2)
 {
-       struct proc **pp1 = (struct proc **) v1;
-       struct proc **pp2 = (struct proc **) v2;
        struct kinfo_proc *p1, *p2;
        int result;
 

Reply via email to