GitLab maintenance scheduled for Tomorrow, 2019-03-26, from 12:00 to 13:00 CDT - Services will be unavailable during this time.

Commit 64d5e7a2 authored by Nicolas Denoyelle's avatar Nicolas Denoyelle

checkpatch

parent 8ea0f2a2
......@@ -8,8 +8,7 @@ static int tleaf_init_with_it(excit_t it,
const ssize_t *arities,
const enum tleaf_it_policy_e policy,
const ssize_t *user_policy,
excit_t levels,
excit_t levels_inverse);
excit_t levels, excit_t levels_inverse);
static int tleaf_it_alloc(excit_t it)
{
......@@ -40,12 +39,12 @@ static void tleaf_it_free(excit_t it)
excit_free(data_it->levels_inverse);
}
static int tleaf_it_size(const excit_t it, ssize_t *size)
{
struct tleaf_it_s *data_it = it->data;
ssize_t i, s=1;
for(i = 0; i < data_it->depth; i++)
ssize_t i, s = 1;
for (i = 0; i < data_it->depth; i++)
s *= data_it->arities[i];
*size = data_it->depth ? s : 0;
return EXCIT_SUCCESS;
......@@ -54,6 +53,7 @@ static int tleaf_it_size(const excit_t it, ssize_t *size)
static int tleaf_it_rewind(excit_t it)
{
struct tleaf_it_s *data_it = it->data;
return excit_rewind(data_it->levels);
}
......@@ -88,9 +88,9 @@ static int tleaf_it_copy(excit_t dst_it, const excit_t src_it)
goto error_with_levels;
}
err = tleaf_init_with_it(dst_it, src->depth + 1, src->arities,
TLEAF_POLICY_USER, src->order, levels, levels_inverse);
TLEAF_POLICY_USER, src->order, levels,
levels_inverse);
if (err != EXCIT_SUCCESS)
goto error_with_levels_inverse;
......@@ -107,12 +107,14 @@ error:
static int tleaf_it_pos(const excit_t it, ssize_t *value)
{
struct tleaf_it_s *data_it = it->data;
return excit_pos(data_it->levels, value);
}
static ssize_t tleaf_it_value(struct tleaf_it_s *it)
{
ssize_t i, acc = 1, val = 0;
for (i = 0; i < it->depth; i++) {
val += acc * it->buf[i];
acc *= it->arities[it->order[i]];
......@@ -163,6 +165,7 @@ int tleaf_it_rank(const excit_t it, const ssize_t *indexes, ssize_t *n)
return err;
ssize_t i, acc = 1, val = 0;
for (i = 0; i < data_it->depth; i++) {
val += acc * data_it->buf[i];
acc *= data_it->arities[data_it->order_inverse[i]];
......@@ -172,13 +175,15 @@ int tleaf_it_rank(const excit_t it, const ssize_t *indexes, ssize_t *n)
return EXCIT_SUCCESS;
}
static int tleaf_add_level(excit_t levels, const ssize_t arity){
static int tleaf_add_level(excit_t levels, const ssize_t arity)
{
excit_t level = excit_alloc(EXCIT_RANGE);
if (level == NULL)
return -EXCIT_ENOMEM;
int err;
err = excit_range_init(level, 0, arity - 1, 1);
int err = excit_range_init(level, 0, arity - 1, 1);
if (err != EXCIT_SUCCESS)
goto error;
......@@ -196,8 +201,7 @@ static int tleaf_init_with_it(excit_t it,
const ssize_t *arities,
const enum tleaf_it_policy_e policy,
const ssize_t *user_policy,
excit_t levels,
excit_t levels_inverse)
excit_t levels, excit_t levels_inverse)
{
if (it == NULL || it->data == NULL)
return -EXCIT_EINVAL;
......@@ -265,9 +269,12 @@ static int tleaf_init_with_it(excit_t it,
goto error_with_buf;
}
for (i = 0; i < data_it->depth; i++){
err = tleaf_add_level(levels, data_it->arities[data_it->order[i]]);
if(err != EXCIT_SUCCESS)
for (i = 0; i < data_it->depth; i++) {
ssize_t l = data_it->order[i];
err = tleaf_add_level(levels,
data_it->arities[l]);
if (err != EXCIT_SUCCESS)
goto error_with_levels;
}
} else {
......@@ -280,9 +287,12 @@ static int tleaf_init_with_it(excit_t it,
err = -EXCIT_ENOMEM;
goto error_with_levels;
}
for (i = 0; i < data_it->depth; i++){
err = tleaf_add_level(levels_inverse, data_it->arities[data_it->order_inverse[i]]);
if(err != EXCIT_SUCCESS)
for (i = 0; i < data_it->depth; i++) {
ssize_t l = data_it->order_inverse[i];
err = tleaf_add_level(levels_inverse,
data_it->arities[l]);
if (err != EXCIT_SUCCESS)
goto error_with_levels_inverse;
}
} else {
......@@ -323,13 +333,16 @@ int excit_tleaf_init(excit_t it,
NULL, NULL);
}
int tleaf_split_levels(excit_t levels, const ssize_t depth, const ssize_t n, excit_t** out){
int tleaf_split_levels(excit_t levels, const ssize_t depth, const ssize_t n,
excit_t **out)
{
*out = malloc(sizeof(**out) * n);
if (*out == NULL)
return -EXCIT_ENOMEM;
int err = excit_product_split_dim(levels, depth, n, *out);
if (err != EXCIT_SUCCESS){
if (err != EXCIT_SUCCESS) {
free(*out);
*out = NULL;
return err;
......@@ -355,10 +368,15 @@ int tleaf_it_split(const excit_t it, const ssize_t depth,
int err;
excit_t *levels, *levels_inverse;
err = tleaf_split_levels(data_it->levels, data_it->order[depth], n, &levels);
if(err != EXCIT_SUCCESS)
err =
tleaf_split_levels(data_it->levels, data_it->order[depth], n,
&levels);
if (err != EXCIT_SUCCESS)
return err;
err = tleaf_split_levels(data_it->levels_inverse, data_it->order_inverse[depth], n, &levels_inverse);
err =
tleaf_split_levels(data_it->levels_inverse,
data_it->order_inverse[depth], n,
&levels_inverse);
if (err != EXCIT_SUCCESS)
goto error_with_levels;
......@@ -367,7 +385,8 @@ int tleaf_it_split(const excit_t it, const ssize_t depth,
data_it->depth + 1,
data_it->arities,
TLEAF_POLICY_USER,
data_it->order, levels[i], levels_inverse[i]);
data_it->order, levels[i],
levels_inverse[i]);
if (err != EXCIT_SUCCESS)
goto error_with_levels_inverse;
}
......
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