s3: convert registry and printing code to TYPESAFE_QSORT()
authorAndrew Tridgell <tridge@samba.org>
Sat, 13 Feb 2010 23:02:19 +0000 (10:02 +1100)
committerAndrew Tridgell <tridge@samba.org>
Sun, 14 Feb 2010 07:44:21 +0000 (18:44 +1100)
source3/printing/printing.c
source3/registry/reg_backend_db.c
source3/registry/regfio.c

index b5b8a56dd01291d003fbcbad8ff648fb8b3f1e5a..a239fb2c54a65adfe67fc09461727bbf73a89642 100644 (file)
@@ -1158,8 +1158,7 @@ static void print_queue_update_internal( const char *sharename,
        /* Sort the queue by submission time otherwise they are displayed
           in hash order. */
 
-       qsort(queue, qcount, sizeof(print_queue_struct),
-               QSORT_CAST(printjob_comp));
+       TYPESAFE_QSORT(queue, qcount, printjob_comp);
 
        /*
          any job in the internal database that is marked as spooled
@@ -2736,7 +2735,7 @@ static bool get_stored_queue_info(struct tdb_print_db *pdb, int snum, int *pcoun
        /* Sort the queue by submission time otherwise they are displayed
           in hash order. */
 
-       qsort(queue, total_count, sizeof(print_queue_struct), QSORT_CAST(printjob_comp));
+       TYPESAFE_QSORT(queue, total_count, printjob_comp);
 
        DEBUG(5,("get_stored_queue_info: total_count = %u\n", (unsigned int)total_count));
 
index fe15b4e46185c845be7c0f07e7ef595194384db9..c8241755275c494d7c228a464db001d5891a5ae3 100644 (file)
@@ -1177,9 +1177,9 @@ done:
  * recreated on demand.
  */
 
-static int cmp_keynames(const void *p1, const void *p2)
+static int cmp_keynames(char **p1, char **p2)
 {
-       return StrCaseCmp(*((char **)p1), *((char **)p2));
+       return StrCaseCmp(*p1, *p2);
 }
 
 struct create_sorted_subkeys_context {
@@ -1248,7 +1248,7 @@ static NTSTATUS create_sorted_subkeys_action(struct db_context *db,
                len += strlen(sorted_subkeys[i])+1;
        }
 
-       qsort(sorted_subkeys, num_subkeys, sizeof(char *), cmp_keynames);
+       TYPESAFE_QSORT(sorted_subkeys, num_subkeys, cmp_keynames);
 
        buf = talloc_array(ctr, char, len);
        if (buf == NULL) {
index c3873a894bba41960bcbd8634d1789cd2d1c6c97..fa7dc7dfe9c2a92ca2750c885df772d067090776 100644 (file)
@@ -1767,8 +1767,7 @@ static int hashrec_cmp( REGF_HASH_REC *h1, REGF_HASH_REC *h2 )
                parent->subkey_index++;
 
                /* sort the list by keyname */
-
-               qsort( parent->subkeys.hashes, parent->subkey_index, sizeof(REGF_HASH_REC), QSORT_CAST hashrec_cmp );
+               TYPESAFE_QSORT(parent->subkeys.hashes, parent->subkey_index, hashrec_cmp);
 
                if ( !hbin_prs_lf_records( "lf_rec", parent->subkeys.hbin, 0, parent ) )
                        return False;