always add braces to control statements and \n at EOF

This commit is contained in:
Furkan Mudanyali 2023-12-27 17:06:41 +03:00
parent 7f0a207220
commit 9dc6b70f19
26 changed files with 40 additions and 32 deletions

View File

@ -40,6 +40,8 @@ IndentGotoLabels: false
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
InsertBraces: true
InsertNewlineAtEOF: true
KeepEmptyLinesAtTheStartOfBlocks: false

View File

@ -41,22 +41,27 @@ unsigned int mbox_call(unsigned char ch) {
unsigned int m = ((unsigned int)((long)&mbox) & ~0xF)
| (ch & 0xF); /* 28-bit address (MSB), 4-bit value (LSB) */
while (1)
if (!(mmio_read(MBOX_STATUS) & MBOX_FULL))
while (1) {
if (!(mmio_read(MBOX_STATUS) & MBOX_FULL)) {
break;
}
}
mmio_write(MBOX_WRITE, m);
while (1) {
while (1)
if (!(mmio_read(MBOX_STATUS) & MBOX_EMPTY))
break; /* Wait for a reply */
while (1) {
if (!(mmio_read(MBOX_STATUS) & MBOX_EMPTY)) {
break; /* Wait for a reply */
}
}
if (m == mmio_read(MBOX_READ)) { /* Look for a message on MBOX_READ */
if (mbox[1] == MBOX_RESPONSE)
if (mbox[1] == MBOX_RESPONSE) {
return 1; /* Success! */
else
} else {
return 0;
}
}
}
return 0;

View File

@ -22,4 +22,4 @@
#define va_copy(d, s) __builtin_va_copy(d, s)
typedef __builtin_va_list va_list;
typedef __builtin_va_list __isoc_va_list;
typedef __builtin_va_list __isoc_va_list;

View File

@ -30,4 +30,4 @@ uint8_t inb(uint16_t port) {
uint8_t ret;
asm("inb %1, %0" : "=a"(ret) : "Nd"(port));
return ret;
}
}

View File

@ -22,4 +22,4 @@
#define va_copy(d, s) __builtin_va_copy(d, s)
typedef __builtin_va_list va_list;
typedef __builtin_va_list __isoc_va_list;
typedef __builtin_va_list __isoc_va_list;

View File

@ -18,4 +18,4 @@
int isdigit(int c) {
return (unsigned)c - '0' < 10;
}
}

View File

@ -24,4 +24,4 @@
#define assert(val) \
((val) ? (void)0 : (printf("ASSERTION FAILED, " __FILE__ ":%d: " #val "\n", __LINE__), abort()))
#endif
#endif

View File

@ -21,4 +21,4 @@
int isdigit(int);
#endif
#endif

View File

@ -25,4 +25,4 @@
#define offsetof(type, member) ((size_t)((char *)&(((type *)0)->member) - (char *)0))
#endif
#endif

View File

@ -36,4 +36,4 @@
#define UINT32_MAX (0xffffffffu)
#define UINT64_MAX (0xffffffffffffffffu)
#endif
#endif

View File

@ -25,4 +25,4 @@ int printf(const char *restrict, ...);
int putchar(int);
int puts(const char *);
#endif
#endif

View File

@ -37,4 +37,4 @@ void *memset(void *, int, size_t);
size_t strlen(const char *);
#endif
#endif

View File

@ -20,4 +20,4 @@
int puts(const char *str) {
return printf("%s", str);
}
}

View File

@ -29,4 +29,4 @@ int memcmp(const void *aptr, const void *bptr, size_t size) {
}
}
return 0;
}
}

View File

@ -25,4 +25,4 @@ void *memcpy(void *restrict dstptr, const void *srcptr, size_t size) {
dst[i] = src[i];
}
return dstptr;
}
}

View File

@ -32,4 +32,4 @@ void *memmove(void *dstptr, const void *srcptr, size_t size) {
}
}
return dstptr;
}
}

View File

@ -24,4 +24,4 @@ void *memset(void *bufptr, int value, size_t size) {
buf[i] = (unsigned char)value;
}
return bufptr;
}
}

View File

@ -20,4 +20,4 @@ char *stpcpy(char *restrict d, const char *s) {
for (; (*d = *s); s++, d++)
;
return d;
}
}

View File

@ -21,4 +21,4 @@
char *strcat(char *restrict dest, const char *src) {
strcpy(dest + strlen(dest), src);
return dest;
}
}

View File

@ -24,4 +24,4 @@ char *strchr(const char *restrict str, int c) {
str++;
}
return 0;
}
}

View File

@ -18,10 +18,11 @@
int strcmp(const char *restrict str1, const char *str2) {
while (*str1 || *str2) {
if (*str1 != *str2)
if (*str1 != *str2) {
return *str1 - *str2;
}
str1++;
str2++;
}
return 0;
}
}

View File

@ -19,4 +19,4 @@
char *strcpy(char *restrict dest, const char *src) {
stpcpy(dest, src);
return dest;
}
}

View File

@ -24,4 +24,4 @@ size_t strlen(const char *str) {
len++;
}
return len;
}
}

View File

@ -47,4 +47,4 @@ char *strtok(char *restrict str, const char *delim) {
}
return tokenStart;
}
}

View File

@ -76,4 +76,4 @@ typedef struct {
Elf64_Xword p_align; /* Segment alignment */
} Elf64_Phdr;
#endif
#endif

View File

@ -91,4 +91,4 @@ EFI_STATUS EFIAPI efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable
/* Should be unreachable */
return EFI_LOAD_ERROR;
}
}