diff options
| author | Tyge Løvset <[email protected]> | 2022-04-11 00:04:01 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-04-11 00:04:01 +0200 |
| commit | 99acd2149f3f8996249b3ef82f7490dd098783d7 (patch) | |
| tree | 967ff19c6e06de13aeb76f0f88318846f15623f8 | |
| parent | 2e781ef2c6956d9b4e11f08bdd23477c3b34ee2f (diff) | |
| download | STC-modified-99acd2149f3f8996249b3ef82f7490dd098783d7.tar.gz STC-modified-99acd2149f3f8996249b3ef82f7490dd098783d7.zip | |
Added important parenthesizes around macro expressions.
| -rw-r--r-- | include/stc/alt/clist.h | 4 | ||||
| -rw-r--r-- | include/stc/alt/csmap.h | 6 | ||||
| -rw-r--r-- | include/stc/clist.h | 4 | ||||
| -rw-r--r-- | include/stc/cpque.h | 6 | ||||
| -rw-r--r-- | include/stc/csmap.h | 2 | ||||
| -rw-r--r-- | include/stc/cvec.h | 2 |
6 files changed, 12 insertions, 12 deletions
diff --git a/include/stc/alt/clist.h b/include/stc/alt/clist.h index 9ab4cce6..2d22a1b1 100644 --- a/include/stc/alt/clist.h +++ b/include/stc/alt/clist.h @@ -207,7 +207,7 @@ STC_API size_t _clist_count(const clist_VOID* self); _cx_iter i = it1; \
for (_cx_memb(_next)(&i); i.ref != it2.ref; _cx_memb(_next)(&i)) { \
i_valraw r = i_valto(i.ref); \
- if (i_cmp((&r), (&val)) == 0) return it1; \
+ if (!(i_cmp((&r), (&val)))) return it1; \
it1 = i; \
} \
it1.ref = NULL; return it1; \
@@ -243,7 +243,7 @@ STC_API size_t _clist_count(const clist_VOID* self); while (prev) { \
node = prev->next; \
i_valraw r = i_valto((&node->value)); \
- if (i_cmp((&r), (&val)) == 0) \
+ if (!(i_cmp((&r), (&val)))) \
prev = _cx_memb(_erase_after_)(self, prev), ++n; \
else \
prev = (node == self->last ? NULL : node); \
diff --git a/include/stc/alt/csmap.h b/include/stc/alt/csmap.h index deb071f7..a2200028 100644 --- a/include/stc/alt/csmap.h +++ b/include/stc/alt/csmap.h @@ -232,7 +232,7 @@ static csmap_SENTINEL_node _aatree_sentinel = {&_aatree_sentinel, &_aatree_senti out->_top = 0; \
while (tn->level) { \
int c; _cx_rawkey rx = i_keyto(_i_keyref(&tn->value)); \
- if ((c = i_cmp((&rx), (&rkey))) < 0) tn = tn->link[1]; \
+ if ((c = (i_cmp((&rx), (&rkey)))) < 0) tn = tn->link[1]; \
else if (c > 0) {out->_st[out->_top++] = tn; tn = tn->link[0]; } \
else {out->_tn = tn->link[1]; return (out->ref = &tn->value); } \
} \
@@ -296,7 +296,7 @@ static csmap_SENTINEL_node _aatree_sentinel = {&_aatree_sentinel, &_aatree_senti while (tx->level) { \
up[top++] = tx; \
_cx_rawkey r = i_keyto(_i_keyref(&tx->value)); \
- if (!(c = i_cmp((&r), rkey))) {res->ref = &tx->value; return tn; } \
+ if (!(c = (i_cmp((&r), rkey)))) {res->ref = &tx->value; return tn; } \
tx = tx->link[(dir = (c < 0))]; \
} \
tn = c_alloc(_cx_node); \
@@ -326,7 +326,7 @@ static csmap_SENTINEL_node _aatree_sentinel = {&_aatree_sentinel, &_aatree_senti if (tn->level == 0) \
return tn; \
_cx_rawkey raw = i_keyto(_i_keyref(&tn->value)); \
- _cx_node *tx; int c = i_cmp((&raw), rkey); \
+ _cx_node *tx; int c = (i_cmp((&raw), rkey)); \
if (c != 0) \
tn->link[c < 0] = _cx_memb(_erase_r_)(tn->link[c < 0], rkey, erased); \
else { \
diff --git a/include/stc/clist.h b/include/stc/clist.h index ed8bb1ca..0ff59967 100644 --- a/include/stc/clist.h +++ b/include/stc/clist.h @@ -289,7 +289,7 @@ STC_DEF _cx_iter _cx_memb(_find_in)(_cx_iter it1, _cx_iter it2, i_valraw val) {
c_foreach (it, _cx_self, it1, it2) {
i_valraw r = i_valto(it.ref);
- if (i_cmp((&r), (&val)) == 0) return it;
+ if (!(i_cmp((&r), (&val)))) return it;
}
it2.ref = NULL; return it2;
}
@@ -301,7 +301,7 @@ _cx_memb(_remove)(_cx_self* self, i_valraw val) { while (prev) {
node = prev->next;
i_valraw r = i_valto((&node->value));
- if (i_cmp((&r), (&val)) == 0)
+ if (!(i_cmp((&r), (&val))))
prev = _cx_memb(_erase_after_)(self, prev), ++n;
else
prev = (node == self->last ? NULL : node);
diff --git a/include/stc/cpque.h b/include/stc/cpque.h index 3a4528ec..1b247a9f 100644 --- a/include/stc/cpque.h +++ b/include/stc/cpque.h @@ -110,8 +110,8 @@ STC_INLINE void _cx_memb(_emplace)(_cx_self* self, _cx_raw raw) STC_DEF void
_cx_memb(_sift_down_)(_cx_value* arr, const size_t idx, const size_t n) {
for (size_t r = idx, c = idx << 1; c <= n; c <<= 1) {
- c += (c < n && i_cmp((&arr[c]), (&arr[c + 1])) < 0);
- if (i_cmp((&arr[r]), (&arr[c])) >= 0) return;
+ c += (c < n && (i_cmp((&arr[c]), (&arr[c + 1]))) < 0);
+ if ((i_cmp((&arr[r]), (&arr[c]))) >= 0) return;
_cx_value t = arr[r]; arr[r] = arr[c]; arr[r = c] = t;
}
}
@@ -148,7 +148,7 @@ _cx_memb(_push)(_cx_self* self, _cx_value value) { _cx_memb(_reserve)(self, self->size*3/2 + 4);
_cx_value *arr = self->data - 1; /* base 1 */
size_t c = ++self->size;
- for (; c > 1 && i_cmp((&arr[c >> 1]), (&value)) < 0; c >>= 1)
+ for (; c > 1 && (i_cmp((&arr[c >> 1]), (&value))) < 0; c >>= 1)
arr[c] = arr[c >> 1];
arr[c] = value;
}
diff --git a/include/stc/csmap.h b/include/stc/csmap.h index cd25a2c4..af36db6c 100644 --- a/include/stc/csmap.h +++ b/include/stc/csmap.h @@ -369,7 +369,7 @@ _cx_memb(_insert_entry_i_)(_cx_self* self, _cx_size tn, const _cx_rawkey* rkey, while (tx) {
up[top++] = tx;
i_keyraw raw = i_keyto(_i_keyref(&d[tx].value));
- if ((c = i_cmp((&raw), rkey)) == 0) {res->ref = &d[tx].value; return tn; }
+ if (!(c = i_cmp((&raw), rkey))) { res->ref = &d[tx].value; return tn; }
dir = (c < 0);
tx = d[tx].link[dir];
}
diff --git a/include/stc/cvec.h b/include/stc/cvec.h index c7f1a001..79506a28 100644 --- a/include/stc/cvec.h +++ b/include/stc/cvec.h @@ -397,7 +397,7 @@ _cx_memb(_bsearch_in)(_cx_iter i1, _cx_iter i2, i_valraw raw, _cx_iter* lower_bo while (i1.ref != i2.ref) {
mid.ref = i1.ref + ((i2.ref - i1.ref) >> 1);
int c; i_valraw m = i_valto(mid.ref);
- if ((c = i_cmp((&raw), (&m))) == 0) return *lower_bound = mid;
+ if (!(c = i_cmp((&raw), (&m)))) return *lower_bound = mid;
else if (c < 0) i2.ref = mid.ref;
else i1.ref = mid.ref + 1;
}
|
