Introduce clang-format
An automated and opinionated style for code. We can decide to change the
style and have the source updated by the clang-format tool by running:
make format
I've based the style on the Google style with exceptions to better
match
the current source style.
Change-Id: I43f85c7d4ce02ca999805558b25fcab2e43859c6
diff --git a/src/dlog.c b/src/dlog.c
index c4d49ce..0af7eb5 100644
--- a/src/dlog.c
+++ b/src/dlog.c
@@ -1,13 +1,16 @@
#include "dlog.h"
+#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
-#include <stdarg.h>
#include "arch.h"
#include "spinlock.h"
#include "std.h"
+/* Keep macro alignment */
+/* clang-format off */
+
#define FLAG_SPACE 0x01
#define FLAG_ZERO 0x02
#define FLAG_MINUS 0x04
@@ -16,6 +19,8 @@
#define FLAG_UPPER 0x20
#define FLAG_NEG 0x40
+/* clang-format on */
+
/*
* Prints a raw string to the debug log and returns its length.
*/
@@ -200,27 +205,23 @@
/* Handle the format specifier. */
switch (p[1]) {
- case 's':
- {
- char *str = va_arg(args, char *);
- print_string(str, str, w, flags, ' ');
- }
+ case 's': {
+ char *str = va_arg(args, char *);
+ print_string(str, str, w, flags, ' ');
p++;
- break;
+ } break;
case 'd':
- case 'i':
- {
- int v = va_arg(args, int);
- if (v < 0) {
- flags |= FLAG_NEG;
- v = -v;
- }
-
- print_num((size_t)v, 10, w, flags);
+ case 'i': {
+ int v = va_arg(args, int);
+ if (v < 0) {
+ flags |= FLAG_NEG;
+ v = -v;
}
+
+ print_num((size_t)v, 10, w, flags);
p++;
- break;
+ } break;
case 'X':
flags |= FLAG_UPPER;