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/cpio.c b/src/cpio.c
index e8e95ec..2a00837 100644
--- a/src/cpio.c
+++ b/src/cpio.c
@@ -41,27 +41,31 @@
size_t namelen;
size_left = iter->size_left;
- if (size_left < sizeof(struct cpio_header))
+ if (size_left < sizeof(struct cpio_header)) {
return false;
+ }
/* TODO: Check magic. */
size_left -= sizeof(struct cpio_header);
namelen = (h->namesize + 1) & ~1;
- if (size_left < namelen)
+ if (size_left < namelen) {
return false;
+ }
size_left -= namelen;
filelen = (size_t)h->filesize[0] << 16 | h->filesize[1];
- if (size_left < filelen)
+ if (size_left < filelen) {
return false;
+ }
/* TODO: Check that string is null-terminated. */
/* TODO: Check that trailler is not returned. */
/* Stop enumerating files when we hit the end marker. */
- if (!strcmp((const char *)(iter->cur + 1), "TRAILER!!!"))
+ if (!strcmp((const char *)(iter->cur + 1), "TRAILER!!!")) {
return false;
+ }
size_left -= filelen;