s3-smbd: convert lanman and notify code to TYPESAFE_QSORT()
authorAndrew Tridgell <tridge@samba.org>
Sat, 13 Feb 2010 23:03:12 +0000 (10:03 +1100)
committerAndrew Tridgell <tridge@samba.org>
Sun, 14 Feb 2010 07:44:21 +0000 (18:44 +1100)
source3/smbd/lanman.c
source3/smbd/notify_internal.c

index 4df1cea8d1b42b40a8139c2c441dd14af758e2ae..4c947749bae9ad54904a7dc80af0ee839a3195b9 100644 (file)
@@ -1439,9 +1439,7 @@ static bool api_RNetServerEnum2(connection_struct *conn, uint16 vuid,
        data_len = fixed_len = string_len = 0;
        missed = 0;
 
-       if (total > 0) {
-               qsort(servers,total,sizeof(servers[0]),QSORT_CAST srv_comp);
-       }
+       TYPESAFE_QSORT(servers, total, srv_comp);
 
        {
                char *lastname=NULL;
@@ -1616,9 +1614,7 @@ static bool api_RNetServerEnum3(connection_struct *conn, uint16 vuid,
        data_len = fixed_len = string_len = 0;
        missed = 0;
 
-       if (total > 0) {
-               qsort(servers,total,sizeof(servers[0]),QSORT_CAST srv_comp);
-       }
+       TYPESAFE_QSORT(servers, total, srv_comp);
 
        if (first_name[0] != '\0') {
                struct srv_info_struct *first_server = NULL;
index db165f71cc10bcf951b10532eff40a0cb4810d92..0467e672c1610e5cd749aed3f72100fc0c364722 100644 (file)
@@ -200,10 +200,8 @@ static NTSTATUS notify_load(struct notify_context *notify, struct db_record *rec
 /*
   compare notify entries for sorting
 */
-static int notify_compare(const void *p1, const void *p2)
+static int notify_compare(const struct notify_entry *e1, const struct notify_entry *e2)
 {
-       const struct notify_entry *e1 = (const struct notify_entry *)p1;
-       const struct notify_entry *e2 = (const struct notify_entry *)p2;
        return strcmp(e1->path, e2->path);
 }
 
@@ -339,9 +337,7 @@ static NTSTATUS notify_add_array(struct notify_context *notify, struct db_record
        d->max_mask |= e->filter;
        d->max_mask_subdir |= e->subdir_filter;
 
-       if (d->num_entries > 1) {
-               qsort(d->entries, d->num_entries, sizeof(d->entries[0]), notify_compare);
-       }
+       TYPESAFE_QSORT(d->entries, d->num_entries, notify_compare);
 
        /* recalculate the maximum masks */
        d->max_mask = 0;