Early errors prior to a system call did not set td_errno. This commit
sets td_errno for all errors during syscallenter(). As a result,
syscallret() can now always use td_errno without checking TDP_NERRNO.
Details
- Reviewers
kib - Commits
- rS350012: Always set td_errno to the error value of a system call.
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
sys/kern/kern_fork.c | ||
---|---|---|
1086 ↗ | (On Diff #59584) | For safety (?), I would also clear td_errno in thread_create(). |
sys/kern/subr_syscall.c | ||
88 ↗ | (On Diff #59584) | if (error != 0), since you are changing the line anyway. |
124 ↗ | (On Diff #59584) | I would write td->rd_errno = error = ECAPMODE; |
175 ↗ | (On Diff #59584) | Do we need the error argument anymore ? |
201 ↗ | (On Diff #59584) | I would left this line as is, just in case. |
sys/kern/subr_syscall.c | ||
---|---|---|
175 ↗ | (On Diff #59584) | We do not, though that makes for a larger patch that touches all the architectures. I could do that as a followup so that if for some reason someone needs to bisect it is more isolated to this change than the mechanical one to remove the arg. It might be that we no longer need to return a value from syscallenter() either. I haven't looked yet to see what the fallout is from removing the arg to syscallret(). |
201 ↗ | (On Diff #59584) | The reason I took it out is that syscallret doesn't check this flag anymore, so I felt it was cleaner to only clear it in syscallenter() since that is now the only function that checks it. |
sys/kern/kern_fork.c | ||
---|---|---|
1086 ↗ | (On Diff #59584) | I could do it in thead_ctor() perhaps, or in HEAD I could just move td_errno up into the zero section. For MFC I'd have to set it explicitly. If I do that I can axe setting it here. |
sys/kern/kern_fork.c | ||
---|---|---|
1086 ↗ | (On Diff #59584) | FYI, the reason I set it here was that I was trying to be sure that td_errno was always set to a valid value when TDB_SCX was set and grepping for TDB_SCX is how I ended up at this function. |