Commit 99bfa9e7 authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Move error handling conversion to wrapper.

* This simplifies the caller.
parent 78b400f6
......@@ -1596,38 +1596,52 @@ check_idxvec_get_indices_at_positions(int num_stripes,
xt_idxlist_delete(idxlist);
}
static struct Xt_pos_ext *
get_idxlist_pos_exts_of_index_stripes(
Xt_idxlist idxlist,
size_t num_stripes, const struct Xt_stripe stripes[num_stripes],
size_t *num_ext, int single_match_only)
{
int num_ext_;
struct Xt_pos_ext *pos_ext_;
int retval = xt_idxlist_get_pos_exts_of_index_stripes(
idxlist, (int)num_stripes, stripes, &num_ext_, &pos_ext_,
single_match_only);
if (retval != 0 || num_ext_ < 0)
PUT_ERR("error in xt_idxlist_get_pos_exts_of_index_stripes\n");
*num_ext = (size_t)num_ext_;
return pos_ext_;
}
static void
check_idxlist_stripes_pos_ext(Xt_idxlist idxlist,
size_t num_stripes,
const struct Xt_stripe stripes[num_stripes])
{
int num_ext;
struct Xt_pos_ext *restrict pos_ext;
size_t num_ext;
int single_match_only = 1;
int retval = xt_idxlist_get_pos_exts_of_index_stripes(
idxlist, (int)num_stripes, stripes,
&num_ext, (struct Xt_pos_ext **)&pos_ext,
single_match_only);
struct Xt_pos_ext *restrict pos_ext
= get_idxlist_pos_exts_of_index_stripes(idxlist,
num_stripes, stripes,
&num_ext, single_match_only);
{ // testing of results
if (retval != 0)
PUT_ERR("error in xt_idxlist_get_pos_exts_of_index_stripes\n");
Xt_idxlist intersection
= xt_idxvec_from_stripes_new(stripes, (int)num_stripes);
for (int i = 0, k = 0; i < num_ext; ++i) {
for (size_t i = 0, k = 0; i < num_ext; ++i) {
int abs_pos_ext_size = abs(pos_ext[i].size),
jsign = pos_ext[i].size >= 0 ? 1 : -1;
for (int j = 0; j < abs_pos_ext_size; ++j, ++k) {
Xt_int intersection_index;
xt_idxlist_get_index_at_position(intersection, k,
xt_idxlist_get_index_at_position(intersection, (int)k,
&intersection_index);
int send_pos = pos_ext[i].start + jsign * j;
Xt_int orig_index;
xt_idxlist_get_index_at_position(idxlist, send_pos, &orig_index);
if (intersection_index != orig_index) {
PUT_ERR("error in xt_idxlist_get_pos_exts_of_index_stripes\n");
fprintf(stderr, "intersection pos %d index %"XT_INT_FMT
fprintf(stderr, "intersection pos %zu index %"XT_INT_FMT
" orig pos %d index %"XT_INT_FMT"\n",
k, intersection_index, send_pos, orig_index);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment