diff --git a/.clang-format b/.clang-format index 64fdf2c..017c104 100644 --- a/.clang-format +++ b/.clang-format @@ -44,7 +44,7 @@ AlignTrailingComments: AllowAllArgumentsOnNextLine: true AllowAllParametersOfDeclarationOnNextLine: true AllowBreakBeforeNoexceptSpecifier: Never -AllowShortBlocksOnASingleLine: Empty +AllowShortBlocksOnASingleLine: Never AllowShortCaseLabelsOnASingleLine: false AllowShortCompoundRequirementOnASingleLine: true AllowShortEnumsOnASingleLine: true diff --git a/kernel/main.c b/kernel/main.c index 107a20c..24fe214 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -28,7 +28,8 @@ main() __sync_synchronize(); started = 1; } else { - while(started == 0) {} + while(started == 0) + ; __sync_synchronize(); printf("hart %d starting\n", cpuid()); kvminithart(); // turn on paging diff --git a/kernel/printf.c b/kernel/printf.c index 16b1a94..006da3c 100644 --- a/kernel/printf.c +++ b/kernel/printf.c @@ -123,7 +123,8 @@ panic(char *s) printf(s); printf("\n"); panicked = 1; // freeze uart output from other CPUs - for(;;) {} + for(;;) + ; } void diff --git a/kernel/spinlock.c b/kernel/spinlock.c index c4247d6..29d02db 100644 --- a/kernel/spinlock.c +++ b/kernel/spinlock.c @@ -60,8 +60,9 @@ acquire(struct spinlock *lk) if(holding(lk)) // If the lock is already held, panic. panic("acquire"); - // Spin until aquired. See file header for details - while(__sync_lock_test_and_set(&lk->locked, 1) != 0) {} + // See file header for details + while(__sync_lock_test_and_set(&lk->locked, 1) != 0) + ; __sync_synchronize(); // No loads/stores after this point // Record info about lock acquisition for holding() and debugging. diff --git a/kernel/string.c b/kernel/string.c index 5f3d4ac..cc637d3 100644 --- a/kernel/string.c +++ b/kernel/string.c @@ -73,7 +73,8 @@ strncpy(char *s, const char *t, int n) char *os; os = s; - while(n-- > 0 && (*s++ = *t++) != 0) {} + while(n-- > 0 && (*s++ = *t++) != 0) + ; while(n-- > 0) *s++ = 0; return os; @@ -88,7 +89,8 @@ safestrcpy(char *s, const char *t, int n) os = s; if(n <= 0) return os; - while(--n > 0 && (*s++ = *t++) != 0) {} + while(--n > 0 && (*s++ = *t++) != 0) + ; *s = 0; return os; } @@ -98,6 +100,7 @@ strlen(const char *s) { int n; - for(n = 0; s[n]; n++) {} + for(n = 0; s[n]; n++) + ; return n; } diff --git a/kernel/uart.c b/kernel/uart.c index 370472e..9409002 100644 --- a/kernel/uart.c +++ b/kernel/uart.c @@ -89,7 +89,8 @@ uartputc(int c) acquire(&uart_tx_lock); if(panicked) { - for(;;) {} + for(;;) + ; } while(uart_tx_w == uart_tx_r + UART_TX_BUF_SIZE) { // buffer is full. @@ -112,11 +113,13 @@ uartputc_sync(int c) push_off(); if(panicked) { - for(;;) {} + for(;;) + ; } // wait for Transmit Holding Empty to be set in LSR. - while((ReadReg(LSR) & LSR_TX_IDLE) == 0) {} + while((ReadReg(LSR) & LSR_TX_IDLE) == 0) + ; WriteReg(THR, c); pop_off(); diff --git a/user/ls.c b/user/ls.c index 4efb969..629494f 100644 --- a/user/ls.c +++ b/user/ls.c @@ -10,7 +10,8 @@ fmtname(char *path) char *p; // Find first character after last slash. - for(p = path + strlen(path); p >= path && *p != '/'; p--) {} + for(p = path + strlen(path); p >= path && *p != '/'; p--) + ; p++; // Return blank-padded name. diff --git a/user/ulib.c b/user/ulib.c index e7a6e95..332d1da 100644 --- a/user/ulib.c +++ b/user/ulib.c @@ -20,7 +20,8 @@ strcpy(char *s, const char *t) char *os; os = s; - while((*s++ = *t++) != 0) {} + while((*s++ = *t++) != 0) + ; return os; } @@ -37,7 +38,8 @@ strlen(const char *s) { int n; - for(n = 0; s[n]; n++) {} + for(n = 0; s[n]; n++) + ; return n; } diff --git a/user/usertests.c b/user/usertests.c index a809516..d078540 100644 --- a/user/usertests.c +++ b/user/usertests.c @@ -823,7 +823,8 @@ preempt(char *s) exit(1); } if(pid1 == 0) - for(;;) {} + for(;;) + ; pid2 = fork(); if(pid2 < 0) { @@ -831,7 +832,8 @@ preempt(char *s) exit(1); } if(pid2 == 0) - for(;;) {} + for(;;) + ; pipe(pfds); pid3 = fork(); @@ -844,7 +846,8 @@ preempt(char *s) if(write(pfds[1], "x", 1) != 1) printf("%s: preempt write error", s); close(pfds[1]); - for(;;) {} + for(;;) + ; } close(pfds[1]);