Hold on to your braces!
This introduces the use of clang-tidy for static analysis and linting.
We start by ensuring that we use braces everywhere to reduce the risk of
programmer error caused by the misuse of scope.
Change-Id: I8aba449e6ef8405192d04aff5ed827f97e458d3d
diff --git a/src/dlog.c b/src/dlog.c
index 0af7eb5..38ccc85 100644
--- a/src/dlog.c
+++ b/src/dlog.c
@@ -27,8 +27,9 @@
static size_t print_raw_string(const char *str)
{
const char *c = str;
- while (*c != '\0')
+ while (*c != '\0') {
arch_putchar(*c++);
+ }
return c - str;
}
@@ -47,8 +48,9 @@
size_t len = suffix - str;
/* Print the string up to the beginning of the suffix. */
- while (str != suffix)
+ while (str != suffix) {
arch_putchar(*str++);
+ }
if (flags & FLAG_MINUS) {
/* Left-aligned. Print suffix, then print padding if needed. */
@@ -110,17 +112,18 @@
}
/* Add sign if requested. */
- if (flags & FLAG_NEG)
+ if (flags & FLAG_NEG) {
*--ptr = '-';
- else if (flags & FLAG_PLUS)
+ } else if (flags & FLAG_PLUS) {
*--ptr = '+';
- else if (flags & FLAG_SPACE)
+ } else if (flags & FLAG_SPACE) {
*--ptr = ' ';
-
- if (flags & FLAG_ZERO)
+ }
+ if (flags & FLAG_ZERO) {
print_string(ptr, num, width, flags, '0');
- else
+ } else {
print_string(ptr, ptr, width, flags, ' ');
+ }
}
/*