kboot: Assert errno is negative
When converting from a Linux error to a FreeBSD errno, assert that the value passed in is negative, as is Linux's custom. Suggested by: brooks Sponsored by: Netflix Reviewed by: tsoome, brooks Differential Revision: https://reviews.freebsd.org/D38357
This commit is contained in:
parent
fb53e7adaf
commit
63c7a483e5
|
@ -29,6 +29,7 @@
|
|||
#define _HOST_SYSCALL_H
|
||||
|
||||
#include <stand.h>
|
||||
#include <assert.h>
|
||||
|
||||
long host_syscall(int number, ...);
|
||||
|
||||
|
@ -214,6 +215,12 @@ ssize_t host_write(int fd, const void *buf, size_t nbyte);
|
|||
* function where -1 to -34 are translated to 1 to 34 and all others are EINVAL.
|
||||
* Pass the linux return value, which will be the -errno.
|
||||
*/
|
||||
#define host_to_stand_errno(e) ((-e) > 34 ? EINVAL : (-e))
|
||||
static __inline int
|
||||
host_to_stand_errno(int e)
|
||||
{
|
||||
assert(e < 0);
|
||||
|
||||
return((-e) > 34 ? EINVAL : (-e));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue