Skip to content

Commit a022980

Browse files
committed
Add braces to if statements whose bodies have multiple statements.
Add braces to `if` statements so that the whole intended body is covered by the conditional.
1 parent 241060c commit a022980

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

libc-bottom-half/sources/preopens.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@ static int resize(void) {
6565

6666
preopen *old_preopens = preopens;
6767
preopen *new_preopens = calloc(sizeof(preopen), new_capacity);
68-
if (new_preopens == NULL)
68+
if (new_preopens == NULL) {
6969
UNLOCK(lock);
7070
return -1;
71+
}
7172

7273
memcpy(new_preopens, old_preopens, num_preopens * sizeof(preopen));
7374
preopens = new_preopens;
@@ -111,14 +112,16 @@ static int internal_register_preopened_fd(__wasi_fd_t fd, const char *relprefix)
111112
assert(fd != -1);
112113
assert(relprefix != NULL);
113114

114-
if (num_preopens == preopen_capacity && resize() != 0)
115+
if (num_preopens == preopen_capacity && resize() != 0) {
115116
UNLOCK(lock);
116117
return -1;
118+
}
117119

118120
char *prefix = strdup(strip_prefixes(relprefix));
119-
if (prefix == NULL)
121+
if (prefix == NULL) {
120122
UNLOCK(lock);
121123
return -1;
124+
}
122125
preopens[num_preopens++] = (preopen) { prefix, fd, };
123126

124127
assert_invariants();

0 commit comments

Comments
 (0)