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/std.c b/src/std.c
index 39ba972..9ea1591 100644
--- a/src/std.c
+++ b/src/std.c
@@ -3,8 +3,9 @@
void *memset(void *s, int c, size_t n)
{
char *p = (char *)s;
- while (n--)
+ while (n--) {
*p++ = c;
+ }
return s;
}
@@ -14,8 +15,9 @@
size_t strlen(const char *str)
{
const char *p = str;
- while (*p)
+ while (*p) {
p++;
+ }
return p - str;
}
@@ -38,8 +40,9 @@
char *x;
const char *y;
- if (dst < src)
+ if (dst < src) {
return memcpy(dst, src, n);
+ }
x = (char *)dst + n - 1;
y = (const char *)src + n - 1;
@@ -59,8 +62,9 @@
const char *y = b;
while (n--) {
- if (*x != *y)
+ if (*x != *y) {
return *x - *y;
+ }
x++;
y++;
}
@@ -74,8 +78,9 @@
const char *y = b;
while (*x != 0 && *y != 0) {
- if (*x != *y)
+ if (*x != *y) {
return *x - *y;
+ }
x++;
y++;
}