任何人都可以看到为什么使用以下 ifs,即 xv6-rev6 代码中的第 3279-3285 行:
int num;
num = proc−>tf−>eax;
if (num >= 0 && num < SYS_open && syscalls[num]) {
proc−>tf−>eax = syscalls[num]();
} else if (num >= SYS_open && num < NELEM(syscalls) && syscalls[num]) {
proc−>tf−>eax = syscalls[num]();
} else {...}
而不仅仅是:
int num;
num = proc−>tf−>eax;
if (num >= 0 && num < NELEM(syscalls) && syscalls[num]) {
proc−>tf−>eax = syscalls[num]();
} else {...}