diff options
author | dzwdz | 2021-09-08 21:00:45 +0200 |
---|---|---|
committer | dzwdz | 2021-09-08 21:00:45 +0200 |
commit | 7192887ee27487d209b98b7192cb6798b036b824 (patch) | |
tree | fb894fdd01710a7d9dafdaea3033a3a270609f4b | |
parent | ddde5ad590d645c653432a8447c82405b0701b90 (diff) |
style: simplify the `kmalloc(sizeof(...` calls
-rw-r--r-- | src/kernel/proc.c | 6 | ||||
-rw-r--r-- | src/kernel/syscalls.c | 4 | ||||
-rw-r--r-- | src/kernel/tests/vfs.c | 2 | ||||
-rw-r--r-- | src/kernel/vfs/mount.c | 4 |
4 files changed, 8 insertions, 8 deletions
diff --git a/src/kernel/proc.c b/src/kernel/proc.c index 445536a..8d363a8 100644 --- a/src/kernel/proc.c +++ b/src/kernel/proc.c @@ -11,7 +11,7 @@ struct process *process_current; uint32_t next_pid = 0; struct process *process_seed(void) { - struct process *proc = kmalloc(sizeof(struct process)); + struct process *proc = kmalloc(sizeof *proc); proc->pages = pagedir_new(); proc->state = PS_RUNNING; proc->sibling = NULL; @@ -40,8 +40,8 @@ struct process *process_seed(void) { } struct process *process_fork(struct process *parent) { - struct process *child = kmalloc(sizeof(struct process)); - memcpy(child, parent, sizeof(struct process)); + struct process *child = kmalloc(sizeof *child); + memcpy(child, parent, sizeof *child); child->pages = pagedir_copy(parent->pages); child->sibling = parent->child; diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index 48cb709..0b557fb 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -128,7 +128,7 @@ int _syscall_mount(handle_t handle, const user_ptr path, int len) { // TODO remove trailing slash // append to mount list - mount = kmalloc(sizeof(struct vfs_mount)); + mount = kmalloc(sizeof *mount); mount->prev = process_current->mount; mount->prefix = path_buf; mount->prefix_len = len; @@ -183,7 +183,7 @@ handle_t _syscall_fs_create(user_ptr back_user) { NULL, (uintptr_t)&back, sizeof(handle_t))) goto fail; - backend = kmalloc(sizeof(struct vfs_backend)); // TODO never freed + backend = kmalloc(sizeof *backend); // TODO never freed backend->type = VFS_BACK_USER; backend->handler = NULL; backend->queue = NULL; diff --git a/src/kernel/tests/vfs.c b/src/kernel/tests/vfs.c index 69e40af..3f0685e 100644 --- a/src/kernel/tests/vfs.c +++ b/src/kernel/tests/vfs.c @@ -63,7 +63,7 @@ TEST(vfs_mount_resolve) { struct vfs_mount *mount = NULL; #define ADD_MOUNT(path) do { \ - struct vfs_mount *mount2 = kmalloc(sizeof(struct vfs_mount)); \ + struct vfs_mount *mount2 = kmalloc(sizeof *mount2); \ mount2->prefix = path; \ mount2->prefix_len = sizeof(path) - 1; \ mount2->prev = mount; \ diff --git a/src/kernel/vfs/mount.c b/src/kernel/vfs/mount.c index 37bfe63..b6b3e8d 100644 --- a/src/kernel/vfs/mount.c +++ b/src/kernel/vfs/mount.c @@ -3,8 +3,8 @@ #include <kernel/vfs/mount.h> struct vfs_mount *vfs_mount_seed(void) { - struct vfs_mount *mount = kmalloc(sizeof(struct vfs_mount)); - struct vfs_backend *backend = kmalloc(sizeof(struct vfs_backend)); + struct vfs_mount *mount = kmalloc(sizeof *mount); + struct vfs_backend *backend = kmalloc(sizeof *backend); backend->type = VFS_BACK_ROOT; *mount = (struct vfs_mount){ .prev = NULL, |