style: add braces around if/while statements
Per guidelines, all statements should have braces around them. We do not
have a CI check for this, so a few went in unnoticed.
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
diff --git a/lib/libc/minimal/source/stdlib/strtol.c b/lib/libc/minimal/source/stdlib/strtol.c
index c71941f..eceb3a8 100644
--- a/lib/libc/minimal/source/stdlib/strtol.c
+++ b/lib/libc/minimal/source/stdlib/strtol.c
@@ -60,14 +60,17 @@
if (c == '-') {
neg = 1;
c = *s++;
- } else if (c == '+')
+ } else if (c == '+') {
c = *s++;
+ }
+
if ((base == 0 || base == 16) &&
c == '0' && (*s == 'x' || *s == 'X')) {
c = s[1];
s += 2;
base = 16;
}
+
if (base == 0) {
base = c == '0' ? 8 : 10;
}
@@ -111,11 +114,14 @@
acc += c;
}
}
+
if (any < 0) {
acc = neg ? LONG_MIN : LONG_MAX;
errno = ERANGE;
- } else if (neg)
+ } else if (neg) {
acc = -acc;
+ }
+
if (endptr != NULL) {
*endptr = (char *)(any ? s - 1 : nptr);
}
diff --git a/lib/libc/minimal/source/stdlib/strtoul.c b/lib/libc/minimal/source/stdlib/strtoul.c
index df4e7c2..188390e 100644
--- a/lib/libc/minimal/source/stdlib/strtoul.c
+++ b/lib/libc/minimal/source/stdlib/strtoul.c
@@ -58,17 +58,21 @@
if (c == '-') {
neg = 1;
c = *s++;
- } else if (c == '+')
+ } else if (c == '+') {
c = *s++;
+ }
+
if ((base == 0 || base == 16) &&
c == '0' && (*s == 'x' || *s == 'X')) {
c = s[1];
s += 2;
base = 16;
}
+
if (base == 0) {
base = c == '0' ? 8 : 10;
}
+
cutoff = (unsigned long)ULONG_MAX / (unsigned long)base;
cutlim = (unsigned long)ULONG_MAX % (unsigned long)base;
for (acc = 0, any = 0;; c = *s++) {
diff --git a/lib/libc/minimal/source/stdout/prf.c b/lib/libc/minimal/source/stdout/prf.c
index c2e5b6b..cb61334 100644
--- a/lib/libc/minimal/source/stdout/prf.c
+++ b/lib/libc/minimal/source/stdout/prf.c
@@ -312,8 +312,10 @@
exp++;
}
- if (precision < 0)
+ if (precision < 0) {
precision = 6; /* Default precision if none given */
+ }
+
prune_zero = false; /* Assume trailing 0's allowed */
if ((c == 'g') || (c == 'G')) {
if (!falt && (precision > 0)) {
@@ -390,8 +392,10 @@
}
if (prune_zero) {
- while (*--buf == '0')
+ while (*--buf == '0') {
;
+ }
+
if (*buf != '.') {
buf++;
}
@@ -703,17 +707,21 @@
if (c < width) {
if (fminus) {
/* Left justify? */
- for (i = c; i < width; i++)
+ for (i = c; i < width; i++) {
buf[i] = ' ';
+ }
} else {
/* Right justify */
(void) memmove((buf + (width - c)), buf, (size_t) (c
+ 1));
- if (pad == ' ')
+ if (pad == ' ') {
prefix = 0;
+ }
+
c = width - c + prefix;
- for (i = prefix; i < c; i++)
+ for (i = prefix; i < c; i++) {
buf[i] = pad;
+ }
}
c = width;
}
diff --git a/lib/libc/minimal/source/string/string.c b/lib/libc/minimal/source/string/string.c
index a974227..8fcd271 100644
--- a/lib/libc/minimal/source/string/string.c
+++ b/lib/libc/minimal/source/string/string.c
@@ -68,8 +68,9 @@
{
char tmp = (char) c;
- while ((*s != tmp) && (*s != '\0'))
+ while ((*s != tmp) && (*s != '\0')) {
s++;
+ }
return (*s == tmp) ? (char *) s : NULL;
}
@@ -180,8 +181,9 @@
const char *c1 = m1;
const char *c2 = m2;
- if (!n)
+ if (!n) {
return 0;
+ }
while ((--n > 0) && (*c1 == *c2)) {
c1++;
diff --git a/lib/libc/minimal/source/string/strstr.c b/lib/libc/minimal/source/string/strstr.c
index 7334893..7de678f 100644
--- a/lib/libc/minimal/source/string/strstr.c
+++ b/lib/libc/minimal/source/string/strstr.c
@@ -51,8 +51,9 @@
do {
do {
sc = *s++;
- if (sc == 0)
- return NULL;
+ if (sc == 0) {
+ return NULL;
+ }
} while (sc != c);
} while (strncmp(s, find, len) != 0);
s--;