aboutsummaryrefslogtreecommitdiff
path: root/kernel/features
diff options
context:
space:
mode:
authorMarvin Borner2020-09-15 19:17:49 +0200
committerMarvin Borner2020-09-15 19:17:49 +0200
commit1a99700287749211aec38cb58ea2664585154794 (patch)
treedb2146945c4d2fcb5a9506aaa65ff3f0e1d48a53 /kernel/features
parentc04947731537a722b7efe94ea0d7e56cbf21bf57 (diff)
Some code improvements.
I know, my commit messages are getting worse...
Diffstat (limited to 'kernel/features')
-rw-r--r--kernel/features/event.c10
-rw-r--r--kernel/features/proc.c10
2 files changed, 12 insertions, 8 deletions
diff --git a/kernel/features/event.c b/kernel/features/event.c
index 71c0ad9..1aa0cd0 100644
--- a/kernel/features/event.c
+++ b/kernel/features/event.c
@@ -34,11 +34,12 @@ void event_unregister(enum message_type id, struct proc *proc)
desc.proc = proc;
struct node *iterator = event_table[id]->head;
- do {
+ while (iterator != NULL) {
struct event_descriptor *desc_comp = iterator->data;
if (desc_comp->id == desc.id && desc_comp->proc == desc.proc)
list_remove(event_table[id], iterator);
- } while ((iterator = iterator->next) != NULL);
+ iterator = iterator->next;
+ }
}
u32 event_trigger(enum message_type id, void *data)
@@ -51,9 +52,10 @@ u32 event_trigger(enum message_type id, void *data)
}
struct node *iterator = event_table[id]->head;
- do {
+ while (iterator != NULL) {
proc_send(kernel_proc, ((struct event_descriptor *)iterator->data)->proc, id, data);
- } while ((iterator = iterator->next) != NULL);
+ iterator = iterator->next;
+ }
return 0;
}
diff --git a/kernel/features/proc.c b/kernel/features/proc.c
index aab4fec..3f8dcf1 100644
--- a/kernel/features/proc.c
+++ b/kernel/features/proc.c
@@ -111,10 +111,11 @@ struct proc_message *proc_receive(struct proc *proc)
struct proc *proc_from_pid(u32 pid)
{
struct node *iterator = proc_list->head;
- do {
+ while (iterator != NULL) {
if (((struct proc *)iterator->data)->pid == pid)
return iterator->data;
- } while ((iterator = iterator->next) != NULL);
+ iterator = iterator->next;
+ }
return NULL;
}
@@ -124,13 +125,14 @@ void proc_exit(struct proc *proc, int status)
int res = 0;
struct node *iterator = proc_list->head;
- do {
+ while (iterator != NULL) {
if (iterator->data == proc) {
res = 1;
list_remove(proc_list, iterator);
break;
}
- } while ((iterator = iterator->next) != NULL);
+ iterator = iterator->next;
+ }
if (memcmp(proc, current->data, sizeof(*proc)) == 0)
current = NULL;