diff options
Diffstat (limited to 'src/kernel')
-rw-r--r-- | src/kernel/arch/i386/pagedir.c | 8 | ||||
-rw-r--r-- | src/kernel/mem/virt.c | 4 | ||||
-rw-r--r-- | src/kernel/tests/vfs.c | 30 |
3 files changed, 21 insertions, 21 deletions
diff --git a/src/kernel/arch/i386/pagedir.c b/src/kernel/arch/i386/pagedir.c index 770ff4e..5dd36ec 100644 --- a/src/kernel/arch/i386/pagedir.c +++ b/src/kernel/arch/i386/pagedir.c @@ -138,14 +138,14 @@ void *pagedir_virt2phys(struct pagedir *dir, const void __user *virt, * while i don't currently see a reason to set permissions * directly on page dirs, i might see one in the future. * leaving this as-is would be a security bug */ - if (!dir->e[pd_idx].present) return 0; + if (!dir->e[pd_idx].present) return NULL; pagetable = (void*)(dir->e[pd_idx].address << 11); page = pagetable[pt_idx]; - if (!page.present) return 0; - if (user && !page.user) return 0; - if (writeable && !page.writeable) return 0; + if (!page.present) return NULL; + if (user && !page.user) return NULL; + if (writeable && !page.writeable) return NULL; phys = page.address << 11; phys |= virt_cast & 0xFFF; diff --git a/src/kernel/mem/virt.c b/src/kernel/mem/virt.c index 1fa5a10..b15297e 100644 --- a/src/kernel/mem/virt.c +++ b/src/kernel/mem/virt.c @@ -6,7 +6,7 @@ void virt_iter_new( struct virt_iter *iter, void __user *virt, size_t length, struct pagedir *pages, bool user, bool writeable) { - iter->frag = 0; + iter->frag = NULL; iter->frag_len = 0; iter->prior = 0; iter->error = false; @@ -35,7 +35,7 @@ bool virt_iter_next(struct virt_iter *iter) { iter->frag = pagedir_virt2phys(iter->_pages, iter->_virt, iter->_user, iter->_writeable); - if (iter->frag == 0) { + if (!iter->frag) { iter->error = true; return false; } diff --git a/src/kernel/tests/vfs.c b/src/kernel/tests/vfs.c index 751192b..7591b0e 100644 --- a/src/kernel/tests/vfs.c +++ b/src/kernel/tests/vfs.c @@ -8,7 +8,7 @@ TEST(path_simplify) { #define TEST_WRAPPER(argument, result) do { \ int len = path_simplify(argument, buf, sizeof(argument) - 1); \ - if (result == 0) { \ + if (result == NULL) { \ TEST_COND(len < 0); \ } else { \ if (len == sizeof(result) - 1) { \ @@ -39,24 +39,24 @@ TEST(path_simplify) { TEST_WRAPPER("/asdf//.", "/asdf/"); // going under the root or close to it - TEST_WRAPPER("/..", 0); - TEST_WRAPPER("/../asdf", 0); - TEST_WRAPPER("/../asdf/", 0); - TEST_WRAPPER("/./a/../..", 0); + TEST_WRAPPER("/..", NULL); + TEST_WRAPPER("/../asdf", NULL); + TEST_WRAPPER("/../asdf/", NULL); + TEST_WRAPPER("/./a/../..", NULL); TEST_WRAPPER("/a/a/../..", "/"); TEST_WRAPPER("/a/../a/..", "/"); - TEST_WRAPPER("/a/../../a", 0); - TEST_WRAPPER("/../a/../a", 0); - TEST_WRAPPER("/../../a/a", 0); - TEST_WRAPPER("/////../..", 0); - TEST_WRAPPER("//a//../..", 0); + TEST_WRAPPER("/a/../../a", NULL); + TEST_WRAPPER("/../a/../a", NULL); + TEST_WRAPPER("/../../a/a", NULL); + TEST_WRAPPER("/////../..", NULL); + TEST_WRAPPER("//a//../..", NULL); // relative paths aren't allowed - TEST_WRAPPER("relative", 0); - TEST_WRAPPER("some/stuff", 0); - TEST_WRAPPER("./stuff", 0); - TEST_WRAPPER("../stuff", 0); - TEST_WRAPPER("", 0); + TEST_WRAPPER("relative", NULL); + TEST_WRAPPER("some/stuff", NULL); + TEST_WRAPPER("./stuff", NULL); + TEST_WRAPPER("../stuff", NULL); + TEST_WRAPPER("", NULL); #undef TEST_WRAPPER } |