Skip to content

Commit 14a6589

Browse files
fix weird formatting
1 parent 5ce60db commit 14a6589

File tree

10 files changed

+114
-172
lines changed

10 files changed

+114
-172
lines changed

src/ahci.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,7 @@ int find_cmdslot(ahci_hba_port_t *port, ahci_hba_mem_t *abar)
205205
// If not set in SACT and CI, the slot is free
206206
uint32_t slots = (port->sact | port->ci);
207207
int cmdslots = (abar->cap & 0x0f00) >> 8;
208-
for (int i=0; i<cmdslots; i++)
209-
{
208+
for (int i=0; i<cmdslots; i++) {
210209
if ((slots&1) == 0)
211210
return i;
212211
slots >>= 1;

src/basic.c

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,8 +1307,7 @@ void let_statement(struct basic_ctx* ctx, bool global, bool local)
13071307
accept_or_return(VARIABLE, ctx);
13081308
accept_or_return(EQUALS, ctx);
13091309

1310-
switch (var[strlen(var) - 1])
1311-
{
1310+
switch (var[strlen(var) - 1]) {
13121311
case '$':
13131312
_expr = str_expr(ctx);
13141313
basic_set_string_variable(var, _expr, ctx, local, global);
@@ -2749,8 +2748,7 @@ const char* basic_test_string_variable(const char* var, struct basic_ctx* ctx)
27492748
ctx->local_string_variables[ctx->call_stack_ptr],
27502749
ctx->str_variables
27512750
};
2752-
for (int j = 0; j < 2; j++)
2753-
{
2751+
for (int j = 0; j < 2; j++) {
27542752
struct ub_var_string* cur = list[j];
27552753
for (; cur; cur = cur->next) {
27562754
assert(cur->next != cur, "Variable list is linked to itself");
@@ -2785,8 +2783,7 @@ const char* basic_get_string_variable(const char* var, struct basic_ctx* ctx)
27852783
list[j] = ctx->local_string_variables[j];
27862784
}
27872785
list[0] = ctx->str_variables;
2788-
for (j = ctx->call_stack_ptr; j >= 0; --j)
2789-
{
2786+
for (j = ctx->call_stack_ptr; j >= 0; --j) {
27902787
struct ub_var_string* cur = list[j];
27912788
for (; cur; cur = cur->next) {
27922789
assert(cur->next != cur, "Variable list is linked to itself");
@@ -2811,8 +2808,7 @@ bool basic_double_variable_exists(const char* var, struct basic_ctx* ctx)
28112808
list[j] = ctx->local_double_variables[j];
28122809
}
28132810
list[0] = ctx->double_variables;
2814-
for (j = ctx->call_stack_ptr; j >= 0; --j)
2815-
{
2811+
for (j = ctx->call_stack_ptr; j >= 0; --j) {
28162812
struct ub_var_double* cur = list[j];
28172813
for (; cur; cur = cur->next) {
28182814
assert(cur->next != cur, "Variable list is linked to itself");
@@ -2833,8 +2829,7 @@ bool basic_string_variable_exists(const char* var, struct basic_ctx* ctx)
28332829
list[j] = ctx->local_string_variables[j];
28342830
}
28352831
list[0] = ctx->str_variables;
2836-
for (j = ctx->call_stack_ptr; j >= 0; --j)
2837-
{
2832+
for (j = ctx->call_stack_ptr; j >= 0; --j) {
28382833
struct ub_var_string* cur = list[j];
28392834
for (; cur; cur = cur->next) {
28402835
assert(cur->next != cur, "Variable list is linked to itself");
@@ -2855,8 +2850,7 @@ bool basic_int_variable_exists(const char* var, struct basic_ctx* ctx)
28552850
list[j] = ctx->local_int_variables[j];
28562851
}
28572852
list[0] = ctx->int_variables;
2858-
for (j = ctx->call_stack_ptr; j >= 0; --j)
2859-
{
2853+
for (j = ctx->call_stack_ptr; j >= 0; --j) {
28602854
struct ub_var_int* cur = list[j];
28612855
for (; cur; cur = cur->next) {
28622856
assert(cur->next != cur, "Variable list is linked to itself");
@@ -2890,8 +2884,7 @@ int64_t basic_get_int_variable(const char* var, struct basic_ctx* ctx)
28902884
list[j] = ctx->local_int_variables[j];
28912885
}
28922886
list[0] = ctx->int_variables;
2893-
for (j = ctx->call_stack_ptr; j >= 0; --j)
2894-
{
2887+
for (j = ctx->call_stack_ptr; j >= 0; --j) {
28952888
struct ub_var_int* cur = list[j];
28962889
for (; cur; cur = cur->next) {
28972890
assert(cur->next != cur, "Variable list is linked to itself");
@@ -2936,8 +2929,7 @@ bool basic_get_double_variable(const char* var, struct basic_ctx* ctx, double* r
29362929
list[j] = ctx->local_double_variables[j];
29372930
}
29382931
list[0] = ctx->double_variables;
2939-
for (j = ctx->call_stack_ptr; j >= 0; --j)
2940-
{
2932+
for (j = ctx->call_stack_ptr; j >= 0; --j) {
29412933
struct ub_var_double* cur = list[j];
29422934
for (; cur; cur = cur->next) {
29432935
assert(cur->next != cur, "Variable list is linked to itself");

src/basic_tokenizer.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,7 @@ int get_next_token(struct basic_ctx* ctx)
181181
int strl = 0;
182182
do {
183183
++ctx->nextptr;
184-
if (++strl > 10240)
185-
{
184+
if (++strl > 10240) {
186185
tokenizer_error_print(ctx, "String constant too long");
187186
break;
188187
}
@@ -211,16 +210,13 @@ int get_next_token(struct basic_ctx* ctx)
211210
ctx->nextptr = ctx->ptr;
212211
int varl = 0;
213212
while ((*ctx->nextptr >= 'a' && *ctx->nextptr <= 'z') || (*ctx->nextptr >= 'A' && *ctx->nextptr <= 'Z') || (*ctx->nextptr == '$') || (*ctx->nextptr == '#') || (*ctx->nextptr == '(')
214-
|| (varl > 0 && isdigit(*ctx->nextptr)))
215-
{
213+
|| (varl > 0 && isdigit(*ctx->nextptr))) {
216214
//kprintf("%c", *ctx->nextptr);
217215
ctx->nextptr++;
218-
if (*ctx->nextptr == '(')
219-
{
216+
if (*ctx->nextptr == '(') {
220217
//kprintf("Nextptr found open bracket\n");
221218
int bracketdepth = 1;
222-
do
223-
{
219+
do {
224220
ctx->nextptr++;
225221
if (*ctx->nextptr == '(')
226222
bracketdepth++;
@@ -230,8 +226,7 @@ int get_next_token(struct basic_ctx* ctx)
230226
while (bracketdepth > 1 && *ctx->nextptr != 0);
231227
}
232228
else
233-
if (++varl > 60)
234-
{
229+
if (++varl > 60) {
235230
tokenizer_error_print(ctx, "Variable name too long");
236231
break;
237232
}
@@ -341,8 +336,7 @@ const char* tokenizer_variable_name(struct basic_ctx* ctx)
341336
{
342337
char varname[MAX_VARNAME];
343338
int count = 0;
344-
while (((*ctx->ptr >= 'a' && *ctx->ptr <= 'z') || (*ctx->ptr >= 'A' && *ctx->ptr <= 'Z') || (*ctx->ptr == '$') || (*ctx->ptr == '#')) && count < MAX_VARNAME)
345-
{
339+
while (((*ctx->ptr >= 'a' && *ctx->ptr <= 'z') || (*ctx->ptr >= 'A' && *ctx->ptr <= 'Z') || (*ctx->ptr == '$') || (*ctx->ptr == '#')) && count < MAX_VARNAME) {
346340
varname[count++] = *(ctx->ptr++);
347341
}
348342
varname[count] = 0;

src/debugger.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ void dump_hex(void* addr, uint64_t length)
1111
{
1212
unsigned char* address = addr;
1313
uint64_t index = 0;
14-
for(; index < length; index += 16)
15-
{
14+
for(; index < length; index += 16) {
1615
dprintf("%04x: ", index);
1716
size_t hex = 0;
1817
for (; hex < 16; ++hex) {

src/dns.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ static int dns_make_payload(const char * const name, const uint8_t rr, const uns
116116
unsigned short length;
117117

118118
/* split name up into labels, create query */
119-
while ((tempchr = strchr(tempchr2, '.')) != NULL)
120-
{
119+
while ((tempchr = strchr(tempchr2, '.')) != NULL) {
121120
length = tempchr - tempchr2;
122121
if (payloadpos + length + 1 > 507)
123122
return -1;
@@ -127,17 +126,18 @@ static int dns_make_payload(const char * const name, const uint8_t rr, const uns
127126
tempchr2 = &tempchr[1];
128127
}
129128
length = strlen(tempchr2);
130-
if (length)
131-
{
132-
if (payloadpos + length + 2 > 507)
129+
if (length) {
130+
if (payloadpos + length + 2 > 507) {
133131
return -1;
132+
}
134133
payload[payloadpos++] = length;
135134
memcpy(&payload[payloadpos], tempchr2, length);
136135
payloadpos += length;
137136
payload[payloadpos++] = 0;
138137
}
139-
if (payloadpos > 508)
138+
if (payloadpos > 508) {
140139
return -1;
140+
}
141141
length = htons(rr);
142142
memcpy(&payload[payloadpos],&length,2);
143143
length = htons(rr_class);

src/e1000.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,10 @@ void mmio_write64 (uint64_t p_address,uint64_t p_value)
5353

5454
void e1000_writeCommand( uint16_t p_address, uint32_t p_value)
5555
{
56-
if ( bar_type == 0 )
57-
{
56+
if (bar_type == 0) {
5857
mmio_write32(mem_base+p_address,p_value);
5958
}
60-
else
61-
{
59+
else {
6260
outl(io_base, p_address);
6361
outl(io_base + 4, p_value);
6462
}

src/iso9660.c

Lines changed: 25 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,22 @@ void parse_boot([[maybe_unused]] iso9660* info, [[maybe_unused]] unsigned char*
2929
int parse_pvd(iso9660* info, unsigned char* buffer)
3030
{
3131
PVD* pvd = (PVD*)buffer;
32-
if (!VERIFY_ISO9660(pvd))
33-
{
32+
if (!VERIFY_ISO9660(pvd)) {
3433
kprintf("ISO9660: Invalid PVD found, identifier is not 'CD001'\n");
3534
return 0;
3635
}
3736
char* ptr = pvd->volumeidentifier + 31;
38-
for (; ptr != pvd->volumeidentifier && *ptr == ' '; --ptr)
39-
{
37+
for (; ptr != pvd->volumeidentifier && *ptr == ' '; --ptr) {
4038
// Backpeddle over the trailing spaces in the volume name
4139
if (*ptr == ' ')
4240
*ptr = 0;
4341
}
4442

4543
int j = 0;
4644
info->volume_name = kmalloc(strlen(pvd->volumeidentifier) + 1);
47-
for (ptr = pvd->volumeidentifier; *ptr; ++ptr)
45+
for (ptr = pvd->volumeidentifier; *ptr; ++ptr) {
4846
info->volume_name[j++] = *ptr;
47+
}
4948
// Null-terminate volume name
5049
info->volume_name[j] = 0;
5150

@@ -65,8 +64,7 @@ fs_directory_entry_t* parse_directory(fs_tree_t* node, iso9660* info, uint32_t s
6564

6665
_memset(dirbuffer, 0, lengthbytes);
6766

68-
if (!read_storage_device(info->device->name, start_lba, lengthbytes, dirbuffer))
69-
{
67+
if (!read_storage_device(info->device->name, start_lba, lengthbytes, dirbuffer)) {
7068
kprintf("ISO9660: Could not read LBA sectors 0x%x+0x%x when loading directory!\n", start_lba, lengthbytes / 2048);
7169
kfree(dirbuffer);
7270
return NULL;
@@ -78,21 +76,18 @@ fs_directory_entry_t* parse_directory(fs_tree_t* node, iso9660* info, uint32_t s
7876
// Iterate each of the entries in this directory, enumerating files
7977
unsigned char* walkbuffer = dirbuffer;
8078
int entrycount = 0;
81-
while (walkbuffer < dirbuffer + lengthbytes)
82-
{
79+
while (walkbuffer < dirbuffer + lengthbytes) {
8380
entrycount++;
8481
ISO9660_directory* fentry = (ISO9660_directory*)walkbuffer;
8582

8683
if (fentry->length == 0)
8784
break;
8885

8986
// Skip the first two entries, '.' and '..'
90-
if (entrycount > 2)
91-
{
87+
if (entrycount > 2) {
9288
fs_directory_entry_t* thisentry = kmalloc(sizeof(fs_directory_entry_t));
9389

94-
if (info->joliet == 0)
95-
{
90+
if (info->joliet == 0) {
9691
thisentry->filename = kmalloc(fentry->filename_length + 1);
9792
j = 0;
9893
char* ptr = fentry->filename;
@@ -105,19 +100,17 @@ fs_directory_entry_t* parse_directory(fs_tree_t* node, iso9660* info, uint32_t s
105100
/* Filenames ending in '.' are not allowed */
106101
if (thisentry->filename[j - 1] == '.')
107102
thisentry->filename[j - 1] = 0;
108-
}
109-
else
110-
{
103+
} else {
111104
// Parse joliet filename, 16-bit unicode UCS-2
112105
thisentry->filename = kmalloc((fentry->filename_length / 2) + 1);
113106
j = 0;
114107
char* ptr = fentry->filename;
115-
for (; j < fentry->filename_length / 2; ptr += 2)
116-
{
117-
if (*ptr != 0)
108+
for (; j < fentry->filename_length / 2; ptr += 2) {
109+
if (*ptr != 0) {
118110
thisentry->filename[j++] = '?';
119-
else
111+
} else {
120112
thisentry->filename[j++] = *(ptr + 1);
113+
}
121114
}
122115
thisentry->filename[j] = 0;
123116
//kprintf("'%s' ", thisentry->filename);
@@ -157,17 +150,14 @@ fs_directory_entry_t* parse_directory(fs_tree_t* node, iso9660* info, uint32_t s
157150
void parse_svd(iso9660* info, unsigned char* buffer)
158151
{
159152
PVD* svd = (PVD*)buffer;
160-
if (!VERIFY_ISO9660(svd))
161-
{
153+
if (!VERIFY_ISO9660(svd)) {
162154
kprintf("ISO9660: Invalid SVD found, identifier is not 'CD001'\n");
163155
return;
164156
}
165157

166158
int joliet = 0;
167-
if (svd->escape_seq[0] == '%' && svd->escape_seq[1] == '/')
168-
{
169-
switch (svd->escape_seq[2])
170-
{
159+
if (svd->escape_seq[0] == '%' && svd->escape_seq[1] == '/') {
160+
switch (svd->escape_seq[2]) {
171161
case '@':
172162
joliet = 1;
173163
break;
@@ -180,8 +170,7 @@ void parse_svd(iso9660* info, unsigned char* buffer)
180170
}
181171
}
182172

183-
if (joliet)
184-
{
173+
if (joliet) {
185174
//kprintf("Joliet extensions found on CD drive %s, UCS-2 Level %d\n", info->device->name, joliet);
186175
info->joliet = joliet;
187176
info->pathtable_lba = svd->lsb_pathtable_L_lba;
@@ -199,12 +188,11 @@ void parse_VPD([[maybe_unused]] iso9660* info, [[maybe_unused]] unsigned char* b
199188
fs_directory_entry_t* hunt_entry(iso9660* info, const char* filename, uint32_t flags)
200189
{
201190
fs_directory_entry_t* currententry = info->root;
202-
for(; currententry->next; currententry = currententry->next)
203-
{
204-
if ((flags != 0) && !(currententry->flags & flags))
191+
for(; currententry->next; currententry = currententry->next) {
192+
if ((flags != 0) && !(currententry->flags & flags)) {
205193
continue;
206-
if (!strcmp(filename, currententry->filename))
207-
{
194+
}
195+
if (!strcmp(filename, currententry->filename)) {
208196
return currententry;
209197
}
210198
}
@@ -214,13 +202,10 @@ fs_directory_entry_t* hunt_entry(iso9660* info, const char* filename, uint32_t f
214202
void* iso_get_directory(void* t)
215203
{
216204
fs_tree_t* treeitem = (fs_tree_t*)t;
217-
if (treeitem)
218-
{
205+
if (treeitem) {
219206
iso9660* info = (iso9660*)treeitem->opaque;
220207
return (void*)parse_directory(treeitem, (iso9660*)treeitem->opaque, treeitem->lbapos ? treeitem->lbapos : info->rootextent_lba, treeitem->size ? treeitem->size : info->rootextent_len);
221-
}
222-
else
223-
{
208+
} else {
224209
kprintf("*** BUG *** iso_get_directory: null fs_tree_t*!\n");
225210
return NULL;
226211
}
@@ -240,8 +225,7 @@ bool iso_read_file(void* f, uint64_t start, uint32_t length, unsigned char* buff
240225
sectors_size++;
241226

242227
unsigned char* readbuf = kmalloc(sectors_size * fs->block_size);
243-
if (!read_storage_device(file->device_name, sectors_start, length, readbuf))
244-
{
228+
if (!read_storage_device(file->device_name, sectors_start, length, readbuf)) {
245229
kprintf("ISO9660: Could not read LBA sectors 0x%x-0x%x!\n", sectors_start, sectors_start + sectors_size);
246230
kfree(readbuf);
247231
return false;
@@ -267,8 +251,7 @@ iso9660* iso_mount_volume(const char* name)
267251
_memset(buffer, 0, 2048);
268252
uint32_t VolumeDescriptorPos = PVD_LBA;
269253
info->device = fs;
270-
while (1)
271-
{
254+
while (1) {
272255
if (!read_storage_device(name, VolumeDescriptorPos++, fs->block_size, buffer)) {
273256
kprintf("ISO9660: Could not read LBA sector 0x%x from %s!\n", VolumeDescriptorPos, name);
274257
kfree(info);

0 commit comments

Comments
 (0)