Hi tech@,

Some of the comparator functions in gprof(1) have incompatible pointer
types and generate compiler warnings. The following diff fixes the
problem. 

Thanks,
Serguey

Index: arcs.c
===================================================================
RCS file: /cvs/src/usr.bin/gprof/arcs.c,v
retrieving revision 1.13
diff -u -p -u -r1.13 arcs.c
--- arcs.c      20 Aug 2015 22:32:41 -0000      1.13
+++ arcs.c      10 Nov 2015 18:41:38 -0000
@@ -95,8 +95,11 @@ addarc(nltype *parentp, nltype *childp, 
 nltype **topsortnlp;
 
 int
-topcmp(nltype **npp1, nltype **npp2)
+topcmp(const void *v1, const void *v2)
 {
+    const nltype **npp1 = (const nltype **)v1;
+    const nltype **npp2 = (const nltype **)v2;
+
     return (*npp1) -> toporder - (*npp2) -> toporder;
 }
 
Index: gprof.h
===================================================================
RCS file: /cvs/src/usr.bin/gprof/gprof.h,v
retrieving revision 1.14
diff -u -p -u -r1.14 gprof.h
--- gprof.h     19 Oct 2013 13:51:40 -0000      1.14
+++ gprof.h     10 Nov 2015 18:41:38 -0000
@@ -281,10 +281,10 @@ void              sortchildren(nltype *);
 void           sortmembers(nltype *);
 void           sortparents(nltype *);
 void           tally(struct rawarc *);
-int            timecmp(nltype **, nltype **);
+int            timecmp(const void *, const void *);
 void           timepropagate(nltype *);
-int            topcmp(nltype **, nltype **);
-int            totalcmp(nltype **, nltype **);
+int            topcmp(const void *, const void *);
+int            totalcmp(const void *, const void *);
 
 #define        LESSTHAN        -1
 #define        EQUALTO         0
Index: printgprof.c
===================================================================
RCS file: /cvs/src/usr.bin/gprof/printgprof.c,v
retrieving revision 1.13
diff -u -p -u -r1.13 printgprof.c
--- printgprof.c        20 Aug 2015 22:32:41 -0000      1.13
+++ printgprof.c        10 Nov 2015 18:41:39 -0000
@@ -35,7 +35,7 @@
 #include "gprof.h"
 #include "pathnames.h"
 
-int namecmp(nltype **, nltype **);
+int namecmp(const void *, const void *);
 
 void
 printprof()
@@ -66,8 +66,10 @@ printprof()
 }
 
 int
-timecmp(nltype **npp1, nltype **npp2)
+timecmp(const void *v1, const void *v2)
 {
+    const nltype **npp1 = (const nltype **)v1;
+    const nltype **npp2 = (const nltype **)v2;
     double     timediff;
     long       calldiff;
 
@@ -233,10 +235,10 @@ printgprof(nltype **timesortnlp)
      * all else being equal, sort by names.
      */
 int
-totalcmp(nltype **npp1, nltype **npp2)
+totalcmp(const void *v1, const void *v2)
 {
-    nltype             *np1 = *npp1;
-    nltype             *np2 = *npp2;
+    const nltype *np1 = *(const nltype **)v1;
+    const nltype *np2 = *(const nltype **)v2;
     double             diff;
 
     diff =    ( np1 -> propself + np1 -> propchild )
@@ -642,8 +644,11 @@ printblurb(const char *blurbname)
 }
 
 int
-namecmp(nltype **npp1, nltype **npp2)
+namecmp(const void *v1, const void *v2)
 {
+    const nltype **npp1 = (const nltype **)v1;
+    const nltype **npp2 = (const nltype **)v2;
+
     return( strcmp( (*npp1) -> name , (*npp2) -> name ) );
 }
 

Reply via email to