1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-24 13:57:43 +03:00

s4-rpcserver: use TYPESAFE_QSORT() in rpc servers

This commit is contained in:
Andrew Tridgell 2010-02-13 13:00:55 +11:00
parent e5c83e1adb
commit f954f522a4
3 changed files with 19 additions and 24 deletions

View File

@ -31,6 +31,7 @@
#include "../libcli/drsuapi/drsuapi.h" #include "../libcli/drsuapi/drsuapi.h"
#include "libcli/security/security.h" #include "libcli/security/security.h"
#include "lib/util/binsearch.h" #include "lib/util/binsearch.h"
#include "lib/util/tsort.h"
/* /*
build a DsReplicaObjectIdentifier from a ldb msg build a DsReplicaObjectIdentifier from a ldb msg
@ -506,7 +507,7 @@ static int linked_attribute_compare(const struct drsuapi_DsReplicaLinkedAttribut
/* /*
sort the objects we send by tree order sort the objects we send by tree order
*/ */
static int site_res_cmp_parent_order(const struct ldb_message **m1, const struct ldb_message **m2) static int site_res_cmp_parent_order(struct ldb_message **m1, struct ldb_message **m2)
{ {
return ldb_dn_compare((*m2)->dn, (*m1)->dn); return ldb_dn_compare((*m2)->dn, (*m1)->dn);
} }
@ -514,7 +515,7 @@ static int site_res_cmp_parent_order(const struct ldb_message **m1, const struct
/* /*
sort the objects we send first by uSNChanged sort the objects we send first by uSNChanged
*/ */
static int site_res_cmp_usn_order(const struct ldb_message **m1, const struct ldb_message **m2) static int site_res_cmp_usn_order(struct ldb_message **m1, struct ldb_message **m2)
{ {
unsigned usnchanged1, usnchanged2; unsigned usnchanged1, usnchanged2;
unsigned cn1, cn2; unsigned cn1, cn2;
@ -841,24 +842,21 @@ WERROR dcesrv_drsuapi_DsGetNCChanges(struct dcesrv_call_state *dce_call, TALLOC_
} }
if (req8->replica_flags & DRSUAPI_DRS_GET_ANC) { if (req8->replica_flags & DRSUAPI_DRS_GET_ANC) {
qsort(getnc_state->site_res->msgs, TYPESAFE_QSORT(getnc_state->site_res->msgs,
getnc_state->site_res->count, getnc_state->site_res->count,
sizeof(getnc_state->site_res->msgs[0]), site_res_cmp_parent_order);
(comparison_fn_t)site_res_cmp_parent_order);
} else { } else {
qsort(getnc_state->site_res->msgs, TYPESAFE_QSORT(getnc_state->site_res->msgs,
getnc_state->site_res->count, getnc_state->site_res->count,
sizeof(getnc_state->site_res->msgs[0]), site_res_cmp_usn_order);
(comparison_fn_t)site_res_cmp_usn_order);
} }
getnc_state->uptodateness_vector = talloc_steal(getnc_state, req8->uptodateness_vector); getnc_state->uptodateness_vector = talloc_steal(getnc_state, req8->uptodateness_vector);
if (getnc_state->uptodateness_vector) { if (getnc_state->uptodateness_vector) {
/* make sure its sorted */ /* make sure its sorted */
qsort(getnc_state->uptodateness_vector->cursors, TYPESAFE_QSORT(getnc_state->uptodateness_vector->cursors,
getnc_state->uptodateness_vector->count, getnc_state->uptodateness_vector->count,
sizeof(getnc_state->uptodateness_vector->cursors[0]), drsuapi_DsReplicaCursor_compare);
(comparison_fn_t)drsuapi_DsReplicaCursor_compare);
} }
} }

View File

@ -28,6 +28,7 @@
#include "librpc/gen_ndr/ndr_drsblobs.h" #include "librpc/gen_ndr/ndr_drsblobs.h"
#include "librpc/gen_ndr/ndr_lsa.h" #include "librpc/gen_ndr/ndr_lsa.h"
#include "../lib/crypto/crypto.h" #include "../lib/crypto/crypto.h"
#include "lib/util/tsort.h"
/* /*
this type allows us to distinguish handle types this type allows us to distinguish handle types
@ -1637,8 +1638,7 @@ static NTSTATUS dcesrv_lsa_EnumTrustDom(struct dcesrv_call_state *dce_call, TALL
} }
/* sort the results by name */ /* sort the results by name */
qsort(entries, count, sizeof(*entries), TYPESAFE_QSORT(entries, count, compare_DomainInfo);
(comparison_fn_t)compare_DomainInfo);
if (*r->in.resume_handle >= count) { if (*r->in.resume_handle >= count) {
*r->out.resume_handle = -1; *r->out.resume_handle = -1;
@ -1733,8 +1733,7 @@ static NTSTATUS dcesrv_lsa_EnumTrustedDomainsEx(struct dcesrv_call_state *dce_ca
} }
/* sort the results by name */ /* sort the results by name */
qsort(entries, count, sizeof(*entries), TYPESAFE_QSORT(entries, count, compare_TrustDomainInfoInfoEx);
(comparison_fn_t)compare_TrustDomainInfoInfoEx);
if (*r->in.resume_handle >= count) { if (*r->in.resume_handle >= count) {
*r->out.resume_handle = -1; *r->out.resume_handle = -1;

View File

@ -37,6 +37,7 @@
#include "rpc_server/samr/proto.h" #include "rpc_server/samr/proto.h"
#include "../lib/util/util_ldb.h" #include "../lib/util/util_ldb.h"
#include "param/param.h" #include "param/param.h"
#include "lib/util/tsort.h"
/* these query macros make samr_Query[User|Group|Alias]Info a bit easier to read */ /* these query macros make samr_Query[User|Group|Alias]Info a bit easier to read */
@ -1168,8 +1169,7 @@ static NTSTATUS dcesrv_samr_EnumDomainGroups(struct dcesrv_call_state *dce_call,
} }
/* sort the results by rid */ /* sort the results by rid */
qsort(entries, count, sizeof(struct samr_SamEntry), TYPESAFE_QSORT(entries, count, compare_SamEntry);
(comparison_fn_t)compare_SamEntry);
/* find the first entry to return */ /* find the first entry to return */
for (first=0; for (first=0;
@ -1529,8 +1529,7 @@ static NTSTATUS dcesrv_samr_EnumDomainUsers(struct dcesrv_call_state *dce_call,
} }
/* sort the results by rid */ /* sort the results by rid */
qsort(entries, num_filtered_entries, sizeof(struct samr_SamEntry), TYPESAFE_QSORT(entries, num_filtered_entries, compare_SamEntry);
(comparison_fn_t)compare_SamEntry);
/* find the first entry to return */ /* find the first entry to return */
for (first=0; for (first=0;
@ -1739,8 +1738,7 @@ static NTSTATUS dcesrv_samr_EnumDomainAliases(struct dcesrv_call_state *dce_call
} }
/* sort the results by rid */ /* sort the results by rid */
qsort(entries, count, sizeof(struct samr_SamEntry), TYPESAFE_QSORT(entries, count, compare_SamEntry);
(comparison_fn_t)compare_SamEntry);
/* find the first entry to return */ /* find the first entry to return */
for (first=0; for (first=0;