Skip to content

Commit

Permalink
Cleanup the LCOV comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cjdrake committed Feb 26, 2015
1 parent a68a932 commit 312ef34
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 161 deletions.
12 changes: 3 additions & 9 deletions extension/boolexpr/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,14 @@ BoolExprArray_New(size_t length, BoolExpr **items)
BoolExprArray *array;

array = (BoolExprArray *) malloc(sizeof(BoolExprArray));

/* LCOV_EXCL_START */
if (array == NULL)
return NULL;
/* LCOV_EXCL_STOP */
return NULL; // LCOV_EXCL_LINE

array->items = (BoolExpr **) malloc(length * sizeof(BoolExpr *));

/* LCOV_EXCL_START */
if (array->items == NULL) {
free(array);
return NULL;
free(array); // LCOV_EXCL_LINE
return NULL; // LCOV_EXCL_LINE
}
/* LCOV_EXCL_STOP */

array->length = length;

Expand Down
28 changes: 7 additions & 21 deletions extension/boolexpr/array2.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,14 @@ BoolExprArray2_New(size_t length, size_t *lengths, BoolExpr ***items)
BoolExprArray2 *array2;

array2 = (BoolExprArray2 *) malloc(sizeof(BoolExprArray2));

/* LCOV_EXCL_START */
if (array2 == NULL)
return NULL;
/* LCOV_EXCL_STOP */
return NULL; // LCOV_EXCL_LINE

array2->items = (BoolExprArray **) malloc(length * sizeof(BoolExprArray *));

/* LCOV_EXCL_START */
if (array2->items == NULL) {
free(array2);
return NULL;
free(array2); // LCOV_EXCL_LINE
return NULL; // LCOV_EXCL_LINE
}
/* LCOV_EXCL_STOP */

array2->length = length;

Expand Down Expand Up @@ -73,25 +67,20 @@ _multiply(BoolExprArray *a, BoolExprArray *b, BoolExprType t)
BoolExprArray *prod;

items = (BoolExpr **) malloc(length * sizeof(BoolExpr *));

/* LCOV_EXCL_START */
if (items == NULL)
return NULL;
/* LCOV_EXCL_STOP */
return NULL; // LCOV_EXCL_LINE

for (size_t i = 0, index = 0; i < a->length; ++i) {
for (size_t j = 0; j < b->length; ++j, ++index) {

items[index] = _opn_new(t, 2, a->items[i], b->items[j]);

/* LCOV_EXCL_START */
if (items[index] == NULL) {
/* LCOV_EXCL_START */
for (size_t k = 0; k < index; ++k)
BoolExpr_DecRef(items[k]);
free(items);
return NULL;
/* LCOV_EXCL_STOP */
}
/* LCOV_EXCL_STOP */
}
}

Expand All @@ -117,11 +106,8 @@ _product(BoolExprArray2 *array2, BoolExprType t, size_t n)
BoolExprArray *prod;

prev = _product(array2, t, n-1);

/* LCOV_EXCL_START */
if (prev == NULL)
return NULL;
/* LCOV_EXCL_STOP */
return NULL; // LCOV_EXCL_LINE

prod = _multiply(array2->items[n-1], prev, t);

Expand Down
11 changes: 4 additions & 7 deletions extension/boolexpr/binary.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,30 +70,27 @@ _eq_binify(BoolExpr *op)

for (size_t i = 0, index = 0; i < (op->data.xs->length - 1); ++i) {
for (size_t j = i+1; j < op->data.xs->length; ++j, ++index) {

xs[index] = EqualN(2, op->data.xs->items[i],
op->data.xs->items[j]);

/* LCOV_EXCL_START */
if (xs[index] == NULL) {
/* LCOV_EXCL_START */
for (size_t k = 0; k < index; ++k)
BoolExpr_DecRef(xs[k]);
free(xs);
return NULL;
/* LCOV_EXCL_STOP */
}
/* LCOV_EXCL_STOP */
}
}

temp = And(length, xs);

/* LCOV_EXCL_START */
if (temp == NULL) {
/* LCOV_EXCL_START */
for (size_t i = 0; i < length; ++i)
BoolExpr_DecRef(xs[i]);
free(xs);
/* LCOV_EXCL_STOP */
}
/* LCOV_EXCL_STOP */

for (size_t i = 0; i < length; ++i)
BoolExpr_DecRef(xs[i]);
Expand Down
29 changes: 7 additions & 22 deletions extension/boolexpr/boolexpr.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,19 @@ BoolExprIter_New(BoolExpr *ex)
BoolExprIter *it;

it = (BoolExprIter *) malloc(sizeof(BoolExprIter));

/* LCOV_EXCL_START */
if (it == NULL)
return NULL;
/* LCOV_EXCL_STOP */
return NULL; // LCOV_EXCL_LINE

it->done = false;
it->ex = ex;

if (IS_OP(ex)) {
it->index = 0;
it->it = BoolExprIter_New(ex->data.xs->items[0]);

/* LCOV_EXCL_START */
if (it->it == NULL) {
free(it);
return NULL;
free(it); // LCOV_EXCL_LINE
return NULL; // LCOV_EXCL_LINE
}
/* LCOV_EXCL_STOP */
}

return it;
Expand Down Expand Up @@ -124,11 +118,8 @@ _lit_new(BoolExprVector *lits, long uniqid)
BoolExpr *lit;

lit = (BoolExpr *) malloc(sizeof(BoolExpr));

/* LCOV_EXCL_START */
if (lit == NULL)
return NULL;
/* LCOV_EXCL_STOP */
return NULL; // LCOV_EXCL_LINE

lit->refcount = 1;
lit->type = uniqid < 0 ? COMP : VAR;
Expand All @@ -155,20 +146,14 @@ _op_new(BoolExprType t, size_t n, BoolExpr **xs)
BoolExpr *op;

op = (BoolExpr *) malloc(sizeof(BoolExpr));

/* LCOV_EXCL_START */
if (op == NULL)
return NULL;
/* LCOV_EXCL_STOP */
return NULL; // LCOV_EXCL_LINE

op->data.xs = BoolExprArray_New(n, xs);

/* LCOV_EXCL_START */
if (op->data.xs == NULL) {
free(op);
return NULL;
free(op); // LCOV_EXCL_LINE
return NULL; // LCOV_EXCL_LINE
}
/* LCOV_EXCL_STOP */

op->refcount = 1;
op->type = t;
Expand Down
8 changes: 4 additions & 4 deletions extension/boolexpr/boolexpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ do { \


/* Category checks */
#define IS_ATOM(ex) (((ex)->type) >> 3 == 0x0) // 0000_0***
#define IS_CONST(ex) (((ex)->type) >> 2 == 0x0) // 0000_00**
#define IS_LIT(ex) (((ex)->type) >> 1 == 0x2) // 0000_010*
#define IS_OP(ex) (((ex)->type) >> 3 == 0x1) // 0000_1***
#define IS_ATOM(ex) (((ex)->type) >> 3 == 0x0) // 0***
#define IS_CONST(ex) (((ex)->type) >> 2 == 0x0) // 00**
#define IS_LIT(ex) (((ex)->type) >> 1 == 0x2) // 010*
#define IS_OP(ex) (((ex)->type) >> 3 == 0x1) // 1***


/* Flag definitions */
Expand Down
29 changes: 8 additions & 21 deletions extension/boolexpr/dict.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,14 @@ BoolExprDict_New(size_t (*prehash)(BoolExpr *))
size_t width = _primes[pridx];

dict = (BoolExprDict *) malloc(sizeof(BoolExprDict));

/* LCOV_EXCL_START */
if (dict == NULL)
return NULL;
/* LCOV_EXCL_STOP */
return NULL; // LCOV_EXCL_LINE

dict->items = (BoolExprDictItem **) malloc(width * sizeof(BoolExprDictItem *));

/* LCOV_EXCL_START */
if (dict->items == NULL) {
free(dict);
return NULL;
free(dict); // LCOV_EXCL_LINE
return NULL; // LCOV_EXCL_LINE
}
/* LCOV_EXCL_STOP */

for (size_t i = 0; i < width; ++i)
dict->items[i] = (BoolExprDictItem *) NULL;
Expand Down Expand Up @@ -181,11 +175,8 @@ _insert(BoolExprDict *dict, BoolExpr *key, BoolExpr *val)
}

item = (BoolExprDictItem *) malloc(sizeof(BoolExprDictItem));

/* LCOV_EXCL_START */
if (item == NULL)
return false;
/* LCOV_EXCL_STOP */
return false; // LCOV_EXCL_LINE

item->key = BoolExpr_IncRef(key);
item->val = BoolExpr_IncRef(val);
Expand Down Expand Up @@ -215,14 +206,14 @@ _enlarge(BoolExprDict *dict)
for (size_t i = 0; i < _primes[pridx]; ++i) {
item = items[i];
while (item != (BoolExprDictItem *) NULL) {
/* LCOV_EXCL_START */
if (!_insert(dict, item->key, item->val)) {
/* LCOV_EXCL_START */
for (size_t j = 0; j < i; ++j)
_list_del(items[j]);
free(items);
return false;
/* LCOV_EXCL_STOP */
}
/* LCOV_EXCL_STOP */
item = item->tail;
}
_list_del(items[i]);
Expand All @@ -238,18 +229,14 @@ BoolExprDict_Insert(BoolExprDict *dict, BoolExpr *key, BoolExpr *val)
{
double load;

/* LCOV_EXCL_START */
if (!_insert(dict, key, val))
return false;
/* LCOV_EXCL_STOP */
return false; // LCOV_EXCL_LINE

load = (double) dict->length / (double) _primes[dict->pridx];

if (dict->pridx < _MAX_IDX && load > MAX_LOAD) {
/* LCOV_EXCL_START */
if (!_enlarge(dict))
return false;
/* LCOV_EXCL_STOP */
return false; // LCOV_EXCL_LINE
}

return true;
Expand Down
60 changes: 17 additions & 43 deletions extension/boolexpr/flatten.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,29 +56,20 @@ _distribute(BoolExprType t, BoolExpr *nf)
BoolExpr *dnf;

sets = _nf2sets(nf);

/* LCOV_EXCL_START */
if (sets == NULL)
return NULL;
/* LCOV_EXCL_STOP */
return NULL; // LCOV_EXCL_LINE

product = BoolExprArray2_Product(sets, t);

/* LCOV_EXCL_START */
if (product == NULL) {
BoolExprArray2_Del(sets);
return NULL;
BoolExprArray2_Del(sets); // LCOV_EXCL_LINE
return NULL; // LCOV_EXCL_LINE
}
/* LCOV_EXCL_STOP */

temp = _op_new(DUAL(t), product->length, product->items);

/* LCOV_EXCL_START */
if (temp == NULL) {
BoolExprArray_Del(product);
BoolExprArray2_Del(sets);
BoolExprArray_Del(product); // LCOV_EXCL_LINE
BoolExprArray2_Del(sets); // LCOV_EXCL_LINE
}
/* LCOV_EXCL_STOP */

BoolExprArray_Del(product);
BoolExprArray2_Del(sets);
Expand Down Expand Up @@ -329,51 +320,36 @@ _cofactors(BoolExpr **fv0, BoolExpr **fv1, BoolExpr *f, BoolExpr *v)
BoolExprDict *v0, *v1;

v0 = BoolExprVarMap_New();
/* LCOV_EXCL_START */
if (v0 == NULL)
return false;
/* LCOV_EXCL_STOP */
return false; // LCOV_EXCL_LINE

/* LCOV_EXCL_START */
if (!BoolExprDict_Insert(v0, v, &Zero)) {
BoolExprDict_Del(v0);
return false;
BoolExprDict_Del(v0); // LCOV_EXCL_LINE
return false; // LCOV_EXCL_LINE
}
/* LCOV_EXCL_STOP */

*fv0 = BoolExpr_Restrict(f, v0);

/* LCOV_EXCL_START */
if (fv0 == NULL) {
BoolExprDict_Del(v0);
return false;
BoolExprDict_Del(v0); // LCOV_EXCL_LINE
return false; // LCOV_EXCL_LINE
}
/* LCOV_EXCL_STOP */

BoolExprDict_Del(v0);

v1 = BoolExprVarMap_New();

/* LCOV_EXCL_START */
if (v1 == NULL)
return false;
/* LCOV_EXCL_STOP */
return false; // LCOV_EXCL_LINE

/* LCOV_EXCL_START */
if (!BoolExprDict_Insert(v1, v, &One)) {
BoolExprDict_Del(v1);
return false;
BoolExprDict_Del(v1); // LCOV_EXCL_LINE
return false; // LCOV_EXCL_LINE
}
/* LCOV_EXCL_STOP */

*fv1 = BoolExpr_Restrict(f, v1);

/* LCOV_EXCL_START */
if (fv1 == NULL) {
BoolExprDict_Del(v1);
return false;
BoolExprDict_Del(v1); // LCOV_EXCL_LINE
return false; // LCOV_EXCL_LINE
}
/* LCOV_EXCL_STOP */

BoolExprDict_Del(v1);

Expand All @@ -398,12 +374,10 @@ _complete_sum(BoolExpr *dnf)

CHECK_NULL(v, _choose_var(dnf));

/* LCOV_EXCL_START */
if (!_cofactors(&fv0, &fv1, dnf, v)) {
BoolExpr_DecRef(v);
return NULL;
BoolExpr_DecRef(v); // LCOV_EXCL_LINE
return NULL; // LCOV_EXCL_LINE
}
/* LCOV_EXCL_STOP */

CHECK_NULL_3(cs0, _complete_sum(fv0), v, fv0, fv1);
BoolExpr_DecRef(fv0);
Expand Down

0 comments on commit 312ef34

Please sign in to comment.