4141#define SCALE_X (0.1 / 1000.0) /* pixels per us */
4242#define SCALE_Y (20.0)
4343
44- #define compare (a , b ) (((a) > (b))? 1 : (((b) > (a))? -1 : 0))
45-
4644#define svg (...) printf(__VA_ARGS__)
4745
4846#define svg_bar (class , x1 , x2 , y ) \
@@ -191,14 +189,12 @@ static int bus_get_unit_property_strv(sd_bus *bus, const char *path, const char
191189 return 0 ;
192190}
193191
194- static int compare_unit_time (const void * a , const void * b ) {
195- return compare (((struct unit_times * )b )-> time ,
196- ((struct unit_times * )a )-> time );
192+ static int compare_unit_time (const struct unit_times * a , const struct unit_times * b ) {
193+ return CMP (b -> time , a -> time );
197194}
198195
199- static int compare_unit_start (const void * a , const void * b ) {
200- return compare (((struct unit_times * )a )-> activating ,
201- ((struct unit_times * )b )-> activating );
196+ static int compare_unit_start (const struct unit_times * a , const struct unit_times * b ) {
197+ return CMP (a -> activating , b -> activating );
202198}
203199
204200static void unit_times_free (struct unit_times * t ) {
@@ -629,7 +625,7 @@ static int analyze_plot(int argc, char *argv[], void *userdata) {
629625 if (n <= 0 )
630626 return n ;
631627
632- qsort (times , n , sizeof ( struct unit_times ) , compare_unit_start );
628+ typesafe_qsort (times , n , compare_unit_start );
633629
634630 width = SCALE_X * (boot -> firmware_time + boot -> finish_time );
635631 if (width < 800.0 )
@@ -854,8 +850,7 @@ static int list_dependencies_get_dependencies(sd_bus *bus, const char *name, cha
854850
855851static Hashmap * unit_times_hashmap ;
856852
857- static int list_dependencies_compare (const void * _a , const void * _b ) {
858- const char * * a = (const char * * ) _a , * * b = (const char * * ) _b ;
853+ static int list_dependencies_compare (char * const * a , char * const * b ) {
859854 usec_t usa = 0 , usb = 0 ;
860855 struct unit_times * times ;
861856
@@ -866,7 +861,7 @@ static int list_dependencies_compare(const void *_a, const void *_b) {
866861 if (times )
867862 usb = times -> activated ;
868863
869- return usb - usa ;
864+ return CMP ( usb , usa ) ;
870865}
871866
872867static bool times_in_range (const struct unit_times * times , const struct boot_times * boot ) {
@@ -891,7 +886,7 @@ static int list_dependencies_one(sd_bus *bus, const char *name, unsigned int lev
891886 if (r < 0 )
892887 return r ;
893888
894- qsort_safe (deps , strv_length (deps ), sizeof ( char * ), list_dependencies_compare );
889+ typesafe_qsort (deps , strv_length (deps ), list_dependencies_compare );
895890
896891 r = acquire_boot_times (bus , & boot );
897892 if (r < 0 )
@@ -1056,7 +1051,7 @@ static int analyze_blame(int argc, char *argv[], void *userdata) {
10561051 if (n <= 0 )
10571052 return n ;
10581053
1059- qsort (times , n , sizeof ( struct unit_times ) , compare_unit_time );
1054+ typesafe_qsort (times , n , compare_unit_time );
10601055
10611056 (void ) pager_open (arg_no_pager , false);
10621057
0 commit comments