From c6a40630156b3cf65843abdf23451a7f58e53ccf Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Sun, 30 Aug 2026 08:37:39 +0800 Subject: [PATCH] =?UTF-8?q?revert:=20devfs=20find=20=E6=81=A2=E5=A4=8D=20f?= =?UTF-8?q?or=20i=20in=20result=EF=BC=88=E7=BC=96=E8=AF=91=E5=99=A8?= =?UTF-8?q?=E5=B7=B2=E5=AE=9E=E7=8E=B0=20NULL=20=E7=BB=88=E6=AD=A2?= =?UTF-8?q?=E9=81=8D=E5=8E=86=E8=AF=AD=E4=B9=89=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VKernel/Kernel/drivers/devfs/devfs.vp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/VKernel/Kernel/drivers/devfs/devfs.vp b/VKernel/Kernel/drivers/devfs/devfs.vp index 84e2cde..922ebd6 100644 --- a/VKernel/Kernel/drivers/devfs/devfs.vp +++ b/VKernel/Kernel/drivers/devfs/devfs.vp @@ -36,14 +36,13 @@ class devfs_directory: result: t.CArray[str, PATH_BUFFER_SIZE] token = string.split(path, "/", result) - # 只遍历 split 返回的 token 数:`for i in result` 会全量遍历 256 槽, - # 而 split 只在末尾设 NULL 哨兵、其余槽是栈垃圾 → samestr→strcmp 解引用 - # NULL/垃圾 → #PF(open("/dev/serial0") 走 find("/dev") 时 B1 崩溃根因)。 - for ti in range(token): + # `for i in result` 按 NULL 终止语义遍历(i8* 元素,split 尾哨兵 NULL 停): + # 编译器 _handle_array_iter 已实现"长度上限 + 解引用为空提前终止"。 + for i in result: found: bool = False for d in range(directory_count): dirp: devfs_directory = c.Addr(directories[d]) - if dirp.parent == current_dir and string.samestr(dirp.name, result[ti]): + if dirp.parent == current_dir and string.samestr(dirp.name, i): current_dir = dirp found = True break