diff options
author | dzwdz | 2023-01-25 20:16:22 +0100 |
---|---|---|
committer | dzwdz | 2023-01-25 20:16:22 +0100 |
commit | 17bfb0ef0a48330b1d54e61fe3c30d83528d2d90 (patch) | |
tree | b3d4aed1f408edcb17fe5c86fccaeacaa2a5a48a /src/user/app/tests/kernel/fs.c | |
parent | 2ad6ee8ed15d1bf898645a16dbc06991a3c1425e (diff) |
style: typedef structs, shorter namespaces
I've wanted to do this for a while, and since I've just had a relatively
large refactor commit (pcpy), this is as good of a time as any.
Typedefing structs was mostly inspired by Plan 9's coding style. It makes
some lines of code much shorter at basically no expense.
Everything related to userland kept old-style struct definitions, so as not
to force that style onto other people.
I also considered changing SCREAMING_ENUM_FIELDS to NicerLookingCamelcase,
but I didn't, just in case that'd be confusing.
Diffstat (limited to 'src/user/app/tests/kernel/fs.c')
-rw-r--r-- | src/user/app/tests/kernel/fs.c | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/src/user/app/tests/kernel/fs.c b/src/user/app/tests/kernel/fs.c index 6669c41..b5684d7 100644 --- a/src/user/app/tests/kernel/fs.c +++ b/src/user/app/tests/kernel/fs.c @@ -5,34 +5,34 @@ #include <string.h> static void test_unfinished_req(void) { - handle_t h = -1; - int ret = _syscall_fork(FORK_NEWFS, &h); + hid_t h = -1; + int ret = _sys_fork(FORK_NEWFS, &h); test(0 <= ret); if (ret == 0) { // TODO make a similar test with all 0s passed to fs_wait struct ufs_request res; - _syscall_fs_wait(NULL, 0, &res); + _sys_fs_wait(NULL, 0, &res); // TODO second fs_wait exit(0); } else { test(0 <= h); - test(_syscall_mount(h, "/", 1) == 0); - int ret = _syscall_open("/", 1, 0); + test(_sys_mount(h, "/", 1) == 0); + int ret = _sys_open("/", 1, 0); test(ret < 0); // the handler quits while handling that call - but this syscall should return anyways } } static void test_orphaned_fs(void) { - handle_t h = -1; - int ret = _syscall_fork(FORK_NEWFS, &h); + hid_t h = -1; + int ret = _sys_fork(FORK_NEWFS, &h); test(0 <= ret); if (ret == 0) { exit(0); } else { test(0 <= h); - test(_syscall_mount(h, "/", 1) == 0); - int ret = _syscall_open("/", 1, 0); + test(_sys_mount(h, "/", 1) == 0); + int ret = _sys_open("/", 1, 0); test(ret < 0); } } @@ -41,32 +41,32 @@ static void test_fs_cleanup(void) { const char *msg = "success"; int msglen = 8; char buf[16]; - handle_t ends[2]; - test(_syscall_pipe(ends, 0) >= 0); - if (!_syscall_fork(0, NULL)) { - handle_t h = -1; - if (_syscall_fork(FORK_NEWFS, &h) == 0) { + hid_t ends[2]; + test(_sys_pipe(ends, 0) >= 0); + if (!_sys_fork(0, NULL)) { + hid_t h = -1; + if (_sys_fork(FORK_NEWFS, &h) == 0) { for (;;) { struct ufs_request req; - handle_t reqh = _syscall_fs_wait(buf, sizeof buf, &req); + hid_t reqh = _sys_fs_wait(buf, sizeof buf, &req); if (reqh < 0) break; - _syscall_fs_respond(reqh, NULL, 0, 0); /* success */ + _sys_fs_respond(reqh, NULL, 0, 0); /* success */ } /* this is the test: does it break out of the loop * when it should cleanup */ - _syscall_write(ends[1], msg, msglen, -1, 0); + _sys_write(ends[1], msg, msglen, -1, 0); exit(0); } else { - test(_syscall_mount(h, "/", 1) == 0); - h = _syscall_open("/", 1, 0); + test(_sys_mount(h, "/", 1) == 0); + h = _sys_open("/", 1, 0); test(h >= 0); - _syscall_close(h); + _sys_close(h); // TODO another test without the delay - _syscall_sleep(0); + _sys_sleep(0); exit(0); } } else { - test(_syscall_read(ends[0], buf, sizeof buf, 0) == msglen); + test(_sys_read(ends[0], buf, sizeof buf, 0) == msglen); test(memcmp(buf, msg, msglen) == 0); } } |