1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

s4-torture: use TYPESAFE_QSORT() in smbtorture

This commit is contained in:
Andrew Tridgell 2010-02-13 13:01:08 +11:00
parent f954f522a4
commit 700f464951
4 changed files with 15 additions and 26 deletions

View File

@ -23,6 +23,7 @@
#include "libcli/raw/raw_proto.h"
#include "libcli/libcli.h"
#include "torture/util.h"
#include "lib/util/tsort.h"
#define BASEDIR "\\testsearch"
@ -733,8 +734,7 @@ static bool test_many_files(struct torture_context *tctx,
compare_data_level = search_types[t].data_level;
qsort(result.list, result.count, sizeof(result.list[0]),
QSORT_CAST search_compare);
TYPESAFE_QSORT(result.list, result.count, search_compare);
for (i=0;i<result.count;i++) {
const char *s;
@ -1345,8 +1345,7 @@ static bool test_ea_list(struct torture_context *tctx,
/* we have to sort the result as different servers can return directories
in different orders */
qsort(result.list, result.count, sizeof(result.list[0]),
(comparison_fn_t)ealist_cmp);
TYPESAFE_QSORT(result.list, result.count, ealist_cmp);
CHECK_VALUE(result.count, 3);
CHECK_VALUE(result.list[0].ea_list.eas.num_eas, 2);

View File

@ -26,6 +26,7 @@
#include "system/filesys.h"
#include "libcli/libcli.h"
#include "torture/util.h"
#include "lib/util/tsort.h"
#define BASEDIR "\\teststreams"
@ -106,17 +107,13 @@ static bool check_stream(struct smbcli_state *cli, const char *location,
return true;
}
static int qsort_string(const void *v1, const void *v2)
static int qsort_string(char * const *s1, char * const *s2)
{
char * const *s1 = (char * const *)v1;
char * const *s2 = (char * const *)v2;
return strcmp(*s1, *s2);
}
static int qsort_stream(const void *v1, const void *v2)
static int qsort_stream(const struct stream_struct *s1, const struct stream_struct *s2)
{
const struct stream_struct * s1 = (const struct stream_struct *)v1;
const struct stream_struct * s2 = (const struct stream_struct *)v2;
return strcmp(s1->stream_name.s, s2->stream_name.s);
}
@ -152,7 +149,7 @@ static bool check_stream_list(struct torture_context *tctx,
goto done;
}
qsort(exp_sort, num_exp, sizeof(*exp_sort), qsort_string);
TYPESAFE_QSORT(exp_sort, num_exp, qsort_string);
stream_sort = (struct stream_struct *)talloc_memdup(tmp_ctx,
finfo.stream_info.out.streams,
@ -163,8 +160,7 @@ static bool check_stream_list(struct torture_context *tctx,
goto done;
}
qsort(stream_sort, finfo.stream_info.out.num_streams,
sizeof(*stream_sort), qsort_stream);
TYPESAFE_QSORT(stream_sort, finfo.stream_info.out.num_streams, qsort_stream);
for (i=0; i<num_exp; i++) {
if (strcmp(exp_sort[i], stream_sort[i].stream_name.s) != 0) {

View File

@ -34,6 +34,7 @@
#include "torture/util.h"
#include "system/filesys.h"
#include "lib/util/tsort.h"
#define DNAME "smb2_dir"
#define NFILES 100
@ -808,8 +809,7 @@ static bool test_many_files(struct torture_context *tctx,
compare_data_level = search_types[t].data_level;
level_sort = search_types[t].level;
qsort(result.list, result.count, sizeof(result.list[0]),
QSORT_CAST search_compare);
TYPESAFE_QSORT(result.list, result.count, search_compare);
for (i=0;i<result.count;i++) {
const char *s;

View File

@ -28,6 +28,7 @@
#include "system/filesys.h"
#include "system/locale.h"
#include "lib/util/tsort.h"
#define DNAME "teststreams"
@ -79,19 +80,13 @@
}} while (0)
static int qsort_string(const void *v1,
const void *v2)
static int qsort_string(char * const *s1, char * const *s2)
{
char * const *s1 = v1;
char * const *s2 = v2;
return strcmp(*s1, *s2);
}
static int qsort_stream(const void *v1,
const void *v2)
static int qsort_stream(const struct stream_struct * s1, const struct stream_struct *s2)
{
const struct stream_struct * s1 = v1;
const struct stream_struct * s2 = v2;
return strcmp(s1->stream_name.s, s2->stream_name.s);
}
@ -197,7 +192,7 @@ static bool check_stream_list(struct smb2_tree *tree,
goto fail;
}
qsort(exp_sort, num_exp, sizeof(*exp_sort), qsort_string);
TYPESAFE_QSORT(exp_sort, num_exp, qsort_string);
stream_sort = talloc_memdup(tmp_ctx, finfo.stream_info.out.streams,
finfo.stream_info.out.num_streams *
@ -207,8 +202,7 @@ static bool check_stream_list(struct smb2_tree *tree,
goto fail;
}
qsort(stream_sort, finfo.stream_info.out.num_streams,
sizeof(*stream_sort), qsort_stream);
TYPESAFE_QSORT(stream_sort, finfo.stream_info.out.num_streams, qsort_stream);
for (i=0; i<num_exp; i++) {
if (strcmp(exp_sort[i], stream_sort[i].stream_name.s) != 0) {