Clean up lack of braces
diff --git a/src/cn-cbor.c b/src/cn-cbor.c
index aca6b97..6219f97 100644
--- a/src/cn-cbor.c
+++ b/src/cn-cbor.c
@@ -43,8 +43,9 @@
p = p1;
}
if (!(p1 = p->next)) { /* go up next */
- if ((p1 = p->parent))
+ if ((p1 = p->parent)) {
p1->first_child = 0;
+ }
}
CN_CBOR_FREE_CONTEXT(p);
p = p1;
@@ -57,12 +58,15 @@
int exp = (half >> 10) & 0x1f;
int mant = half & 0x3ff;
double val;
- if (exp == 0)
+ if (exp == 0) {
val = ldexp(mant, -24);
- else if (exp != 31)
+ }
+ else if (exp != 31) {
val = ldexp(mant + 1024, exp - 25);
- else
+ }
+ else {
val = mant == 0 ? INFINITY : NAN;
+ }
return half & 0x8000 ? -val : val;
}
#endif /* CBOR_NO_FLOAT */
@@ -143,16 +147,18 @@
again:
TAKE(pos, ebuf, 1, ib = ntoh8p(pos));
if (ib == IB_BREAK) {
- if (!(parent->flags & CN_CBOR_FL_INDEF))
+ if (!(parent->flags & CN_CBOR_FL_INDEF)) {
CN_CBOR_FAIL(CN_CBOR_ERR_BREAK_OUTSIDE_INDEF);
+ }
switch (parent->type) {
case CN_CBOR_BYTES:
case CN_CBOR_TEXT:
parent->type += 2; /* CN_CBOR_* -> CN_CBOR_*_CHUNKED */
break;
case CN_CBOR_MAP:
- if (parent->length & 1)
+ if (parent->length & 1) {
CN_CBOR_FAIL(CN_CBOR_ERR_ODD_SIZE_INDEF_MAP);
+ }
default:;
}
goto complete;
@@ -162,8 +168,9 @@
val = ai;
cb = CN_CALLOC_CONTEXT();
- if (!cb)
+ if (!cb) {
CN_CBOR_FAIL(CN_CBOR_ERR_OUT_OF_MEMORY);
+ }
cb->type = mt_trans[mt];
@@ -275,20 +282,25 @@
}
fill: /* emulate loops */
if (parent->flags & CN_CBOR_FL_INDEF) {
- if (parent->type == CN_CBOR_BYTES || parent->type == CN_CBOR_TEXT)
- if (cb->type != parent->type)
+ if (parent->type == CN_CBOR_BYTES || parent->type == CN_CBOR_TEXT) {
+ if (cb->type != parent->type) {
CN_CBOR_FAIL(CN_CBOR_ERR_WRONG_NESTING_IN_INDEF_STRING);
+ }
+ }
goto again;
}
if (parent->flags & CN_CBOR_FL_COUNT) {
- if (--parent->v.count)
+ if (--parent->v.count) {
goto again;
+ }
}
/* so we are done filling parent. */
complete: /* emulate return from call */
if (parent == top_parent) {
- if (pos != ebuf) /* XXX do this outside */
+ if (pos != ebuf) {
+ /* XXX do this outside */
CN_CBOR_FAIL(CN_CBOR_ERR_NOT_ALL_DATA_CONSUMED);
+ }
pb->buf = pos;
return cb;
}
diff --git a/src/cn-encoder.c b/src/cn-encoder.c
index 51c82f0..80d4968 100644
--- a/src/cn-encoder.c
+++ b/src/cn-encoder.c
@@ -157,20 +157,25 @@
int s16 = (u32.u >> 16) & 0x8000;
int exp = (u32.u >> 23) & 0xff;
int mant = u32.u & 0x7fffff;
- if (exp == 0 && mant == 0)
+ if (exp == 0 && mant == 0) {
; /* 0.0, -0.0 */
- else if (exp >= 113 && exp <= 142) /* normalized */
+ }
+ else if (exp >= 113 && exp <= 142) {
+ /* normalized */
s16 += ((exp - 112) << 10) + (mant >> 13);
+ }
else if (exp >= 103 && exp < 113) { /* denorm, exp16 = 0 */
- if (mant & ((1 << (126 - exp)) - 1))
+ if (mant & ((1 << (126 - exp)) - 1)) {
goto float32; /* loss of precision */
+ }
s16 += ((mant + 0x800000) >> (126 - exp));
}
else if (exp == 255 && mant == 0) { /* Inf */
s16 += 0x7c00;
}
- else
+ else {
goto float32; /* loss of range */
+ }
ensure_writable(3);
u16 = s16;
diff --git a/src/cn-print.c b/src/cn-print.c
index 621b334..38f844a 100644
--- a/src/cn-print.c
+++ b/src/cn-print.c
@@ -43,8 +43,9 @@
bool _isWritable(cn_write_state *ws, size_t cb)
{
- if (ws->rgbOutput == NULL)
+ if (ws->rgbOutput == NULL) {
return true;
+ }
if ((ws->ib < 0) || (ws->ib + cb > ws->cbLeft)) {
ws->ib = -1;
return false;
@@ -194,13 +195,16 @@
}
if (depth > 0) {
- if (ws->rgFlags[depth - 1] & 4)
+ if (ws->rgFlags[depth - 1] & 4) {
ws->rgFlags[depth] |= 1;
+ }
else if (ws->rgFlags[depth - 1] & 8) {
- if (flags & 2)
+ if (flags & 2) {
ws->rgFlags[depth] |= 1;
- else
+ }
+ else {
ws->rgFlags[depth] |= 2;
+ }
}
}
}