diff options
author | Kyle Evans <kevans@FreeBSD.org> | 2020-08-04 21:49:13 +0000 |
---|---|---|
committer | Kyle Evans <kevans@FreeBSD.org> | 2020-08-04 21:49:13 +0000 |
commit | 0bc1c0786b26b9ec564a463bacddb66793f75aa0 (patch) | |
tree | 818c4c8ba9dba3dfdc8f5b7b12d36f2b3a95b602 /sys/tools | |
parent | 784d8d8db08b11101b0278fc22bb232665c3b1b1 (diff) | |
download | src-0bc1c0786b26b9ec564a463bacddb66793f75aa0.tar.gz src-0bc1c0786b26b9ec564a463bacddb66793f75aa0.zip |
makesyscalls.lua: improve syscall ordering validation
There were two separate issues here:
1.) #if/#else wasn't taken into account at all for maxsyscall figures, but
2.) We didn't validate contiguous syscall numbers anyways...
This kind of inconsistency is bad as we don't currently ensure explicit
indexing of, e.g., the sysent array if one syscall is unimplemented/missing.
This could be fixed and might be more robust, but it's also good to have the
"documentation" that comes from being explicit as to what the missing
syscalls are.
The new version looks much like the awk version; stash off the current
'last highest syscall seen' if we hit an #if, restore to that if we hit an
#else, and make sure that we're explicitly always defining the next syscall.
The logic at the tail end of process_syscall_def that moves maxsyscall has
been 'cleaned up' a little since we're now ensuring that it's monotonically
increasing earlier in the function. At the moment I think it's unlikely we'd
see range-definitions that are not UNIMPL, but there's no reason to
specifically handle that case for bumping maxsyscall there.
This change was provoked by reading the commit message for r363832 and
realizing that this validation hadn't been included in the initial rewrite
to lua.
Reviewed by: brooks
Differential Revision: https://reviews.freebsd.org/D25945
Notes
Notes:
svn path=/head/; revision=363869
Diffstat (limited to 'sys/tools')
-rw-r--r-- | sys/tools/makesyscalls.lua | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/sys/tools/makesyscalls.lua b/sys/tools/makesyscalls.lua index 286230cb13a1..276594f4f6ac 100644 --- a/sys/tools/makesyscalls.lua +++ b/sys/tools/makesyscalls.lua @@ -35,7 +35,8 @@ local lfs = require("lfs") local unistd = require("posix.unistd") -local maxsyscall = 0 +local savesyscall = -1 +local maxsyscall = -1 local generated_tag = "@" .. "generated" -- Default configuration; any of these may get replaced by a configuration file @@ -442,6 +443,11 @@ local pattern_table = { dump_prevline = true, pattern = "^#", process = function(line) + if line:find("^#%s*if") then + savesyscall = maxsyscall + elseif line:find("^#%s*else") then + maxsyscall = savesyscall + end line = line .. "\n" write_line('sysent', line) write_line('sysdcl', line) @@ -916,6 +922,16 @@ process_syscall_def = function(line) sysnum = nil sysstart = tonumber(sysstart) sysend = tonumber(sysend) + if sysstart ~= maxsyscall + 1 then + abort(1, "syscall number out of sync, missing " .. + maxsyscall + 1) + end + else + sysnum = tonumber(sysnum) + if sysnum ~= maxsyscall + 1 then + abort(1, "syscall number out of sync, missing " .. + maxsyscall + 1) + end end -- Split flags @@ -1093,15 +1109,14 @@ process_syscall_def = function(line) handle_obsol(sysnum, funcname, funcomment) elseif flags & known_flags["UNIMPL"] ~= 0 then handle_unimpl(sysnum, sysstart, sysend, funcomment) - if sysend ~= nil and sysend > maxsyscall then - maxsyscall = sysend - end else abort(1, "Bad flags? " .. line) end - if sysnum ~= nil and tonumber(sysnum) > maxsyscall then - maxsyscall = tonumber(sysnum) + if sysend ~= nil then + maxsyscall = sysend + elseif sysnum ~= nil then + maxsyscall = sysnum end end |