diff options
author | Marvin Borner | 2020-10-26 16:36:40 +0100 |
---|---|---|
committer | Marvin Borner | 2020-10-26 16:36:40 +0100 |
commit | 197ea3ca20879b29fca41a07cf43e5b04b9c5083 (patch) | |
tree | c0e0223e289bde3af7cca995f98d681779bfda26 /kernel/features | |
parent | 4ae48304b2290b6c835eb3d937bd5e905ce0e5d4 (diff) |
Optimizations
Diffstat (limited to 'kernel/features')
-rw-r--r-- | kernel/features/event.c | 2 | ||||
-rw-r--r-- | kernel/features/fs.c | 10 | ||||
-rw-r--r-- | kernel/features/proc.c | 7 |
3 files changed, 10 insertions, 9 deletions
diff --git a/kernel/features/event.c b/kernel/features/event.c index 633f633..d79d531 100644 --- a/kernel/features/event.c +++ b/kernel/features/event.c @@ -46,7 +46,7 @@ u32 event_trigger(u32 id, void *data) { assert(id < sizeof(event_table) / sizeof(*event_table)); - if (memcmp(event_table[id], 0, sizeof(struct list)) == 0 || !event_table[id]->head) { + if (!event_table[id] || !event_table[id]->head) { printf("Event %d not mapped!\n", id); return 1; } diff --git a/kernel/features/fs.c b/kernel/features/fs.c index 2db0a97..c52a7b6 100644 --- a/kernel/features/fs.c +++ b/kernel/features/fs.c @@ -68,10 +68,10 @@ void *read_inode(struct inode *in) printf("Loading %dKiB\n", sz >> 10); assert(buf != NULL); - int indirect; + int indirect = 0; - int blocknum; - char *data; + int blocknum = 0; + char *data = 0; // TODO: Support triply indirect pointers // TODO: This can be heavily optimized by saving the indirect block lists for (int i = 0; i < num_blocks; i++) { @@ -105,7 +105,7 @@ void *read_file(char *path) path++; u32 current_inode = EXT2_ROOT; - int i; + int i = 0; while (1) { for (i = 0; path[i] != '/' && path[i] != '\0'; i++) ; @@ -176,7 +176,7 @@ void ls_root() struct dirent *d = (struct dirent *)buf; int sum = 0; - int calc; + int calc = 0; printf("\nRoot directory:\n"); do { calc = (sizeof(struct dirent) + d->name_len + 4) & ~0x3; diff --git a/kernel/features/proc.c b/kernel/features/proc.c index b6ed442..5d1a437 100644 --- a/kernel/features/proc.c +++ b/kernel/features/proc.c @@ -34,13 +34,14 @@ void scheduler(struct regs *regs) assert(proc_list->head); - memcpy(&((struct proc *)current->data)->regs, regs, sizeof(struct regs)); + if (current) + memcpy(&((struct proc *)current->data)->regs, regs, sizeof(struct regs)); if (priority_proc) { current = list_first_data(proc_list, priority_proc); priority_proc = NULL; assert(current); - } else if (current->next) { + } else if (current && current->next) { current = current->next; } else { current = proc_list->head; @@ -76,7 +77,7 @@ void proc_print() struct node *node = proc_list->head; printf("\nPROCESSES\n"); - struct proc *proc; + struct proc *proc = NULL; while (node && (proc = node->data)) { printf("Process %d: %s\n", proc->pid, proc->name); node = node->next; |