Address consistency of naming for unused/merely validated arguments.
This commit is contained in:
parent
46aaab30fe
commit
4d3dff2add
@ -56,7 +56,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
this.write_scalar(Scalar::from_i32(result), dest)?;
|
||||
}
|
||||
"fcntl" => {
|
||||
let result = this.fcntl(args);
|
||||
let result = this.fcntl(args)?;
|
||||
this.write_scalar(Scalar::from_i32(result), dest)?;
|
||||
}
|
||||
"read" => {
|
||||
@ -168,8 +168,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
|
||||
// Dynamic symbol loading
|
||||
"dlsym" => {
|
||||
let &[_handle, symbol] = check_arg_count(args)?;
|
||||
let _handle = this.read_scalar(_handle)?.not_undef()?;
|
||||
let &[handle, symbol] = check_arg_count(args)?;
|
||||
this.read_scalar(handle)?.not_undef()?;
|
||||
let symbol = this.read_scalar(symbol)?.not_undef()?;
|
||||
let symbol_name = this.memory.read_c_str(symbol)?;
|
||||
let err = format!("bad c unicode symbol: {:?}", symbol_name);
|
||||
@ -360,8 +360,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
|
||||
// Miscellaneous
|
||||
"isatty" => {
|
||||
let &[_fd] = check_arg_count(args)?;
|
||||
let _fd = this.read_scalar(_fd)?.to_i32()?;
|
||||
let &[fd] = check_arg_count(args)?;
|
||||
this.read_scalar(fd)?.to_i32()?;
|
||||
// "returns 1 if fd is an open file descriptor referring to a terminal; otherwise 0 is returned, and errno is set to indicate the error"
|
||||
// FIXME: we just say nothing is a terminal.
|
||||
let enotty = this.eval_libc("ENOTTY")?;
|
||||
@ -369,10 +369,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
this.write_null(dest)?;
|
||||
}
|
||||
"pthread_atfork" => {
|
||||
let &[_prepare, _parent, _child] = check_arg_count(args)?;
|
||||
let _prepare = this.read_scalar(_prepare)?.not_undef()?;
|
||||
let _parent = this.read_scalar(_parent)?.not_undef()?;
|
||||
let _child = this.read_scalar(_child)?.not_undef()?;
|
||||
let &[prepare, parent, child] = check_arg_count(args)?;
|
||||
this.read_scalar(prepare)?.not_undef()?;
|
||||
this.read_scalar(parent)?.not_undef()?;
|
||||
this.read_scalar(child)?.not_undef()?;
|
||||
// We do not support forking, so there is nothing to do here.
|
||||
this.write_null(dest)?;
|
||||
}
|
||||
|
@ -46,11 +46,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
}
|
||||
// Linux-only
|
||||
"posix_fadvise" => {
|
||||
let &[_fd, _offset, _len, _advice] = check_arg_count(args)?;
|
||||
let _fd = this.read_scalar(_fd)?.to_i32()?;
|
||||
let _offset = this.read_scalar(_offset)?.to_machine_isize(this)?;
|
||||
let _len = this.read_scalar(_len)?.to_machine_isize(this)?;
|
||||
let _advice = this.read_scalar(_advice)?.to_i32()?;
|
||||
let &[fd, offset, len, advice] = check_arg_count(args)?;
|
||||
this.read_scalar(fd)?.to_i32()?;
|
||||
this.read_scalar(offset)?.to_machine_isize(this)?;
|
||||
this.read_scalar(len)?.to_machine_isize(this)?;
|
||||
this.read_scalar(advice)?.to_i32()?;
|
||||
// fadvise is only informational, we can ignore it.
|
||||
this.write_null(dest)?;
|
||||
}
|
||||
@ -66,8 +66,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
// Querying system information
|
||||
"pthread_attr_getstack" => {
|
||||
// We don't support "pthread_attr_setstack", so we just pretend all stacks have the same values here.
|
||||
let &[_attr_place, addr_place, size_place] = check_arg_count(args)?;
|
||||
let _attr_place = this.deref_operand(_attr_place)?;
|
||||
let &[attr_place, addr_place, size_place] = check_arg_count(args)?;
|
||||
this.deref_operand(attr_place)?;
|
||||
let addr_place = this.deref_operand(addr_place)?;
|
||||
let size_place = this.deref_operand(size_place)?;
|
||||
|
||||
@ -102,14 +102,15 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
.to_machine_usize(this)?;
|
||||
|
||||
if args.is_empty() {
|
||||
throw_ub_format!("incorrect number of arguments, needed at least 1");
|
||||
throw_ub_format!("incorrect number of arguments for syscall, needed at least 1");
|
||||
}
|
||||
match this.read_scalar(args[0])?.to_machine_usize(this)? {
|
||||
// `libc::syscall(NR_GETRANDOM, buf.as_mut_ptr(), buf.len(), GRND_NONBLOCK)`
|
||||
// is called if a `HashMap` is created the regular way (e.g. HashMap<K, V>).
|
||||
id if id == sys_getrandom => {
|
||||
// The first argument is the syscall id, so skip over it.
|
||||
getrandom(this, &args[1..], dest)?;
|
||||
let &[_, ptr, len, flags] = check_arg_count(args)?;
|
||||
getrandom(this, ptr, len, flags, dest)?;
|
||||
}
|
||||
// `statx` is used by `libstd` to retrieve metadata information on `linux`
|
||||
// instead of using `stat`,`lstat` or `fstat` as on `macos`.
|
||||
@ -125,13 +126,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
|
||||
// Miscelanneous
|
||||
"getrandom" => {
|
||||
getrandom(this, args, dest)?;
|
||||
let &[ptr, len, flags] = check_arg_count(args)?;
|
||||
getrandom(this, ptr, len, flags, dest)?;
|
||||
}
|
||||
"sched_getaffinity" => {
|
||||
let &[_pid, _cpusetsize, _mask] = check_arg_count(args)?;
|
||||
let _pid = this.read_scalar(_pid)?.to_i32()?;
|
||||
let _cpusetsize = this.read_scalar(_cpusetsize)?.to_machine_usize(this)?;
|
||||
let _mask = this.deref_operand(_mask)?;
|
||||
let &[pid, cpusetsize, mask] = check_arg_count(args)?;
|
||||
this.read_scalar(pid)?.to_i32()?;
|
||||
this.read_scalar(cpusetsize)?.to_machine_usize(this)?;
|
||||
this.deref_operand(mask)?;
|
||||
// FIXME: we just return an error; `num_cpus` then falls back to `sysconf`.
|
||||
let einval = this.eval_libc("EINVAL")?;
|
||||
this.set_last_error(einval)?;
|
||||
@ -154,16 +156,17 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
// Shims the linux `getrandom` syscall.
|
||||
fn getrandom<'tcx>(
|
||||
this: &mut MiriEvalContext<'_, 'tcx>,
|
||||
args: &[OpTy<'tcx, Tag>],
|
||||
ptr: OpTy<'tcx, Tag>,
|
||||
len: OpTy<'tcx, Tag>,
|
||||
flags: OpTy<'tcx, Tag>,
|
||||
dest: PlaceTy<'tcx, Tag>,
|
||||
) -> InterpResult<'tcx> {
|
||||
let &[ptr, len, _flags] = check_arg_count(args)?;
|
||||
let ptr = this.read_scalar(ptr)?.not_undef()?;
|
||||
let len = this.read_scalar(len)?.to_machine_usize(this)?;
|
||||
|
||||
// The only supported flags are GRND_RANDOM and GRND_NONBLOCK,
|
||||
// neither of which have any effect on our current PRNG.
|
||||
let _flags = this.read_scalar(_flags)?.to_i32()?;
|
||||
this.read_scalar(flags)?.to_i32()?;
|
||||
|
||||
this.gen_random(ptr, len)?;
|
||||
this.write_scalar(Scalar::from_machine_usize(len, this), dest)?;
|
||||
|
@ -104,14 +104,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
|
||||
// Querying system information
|
||||
"pthread_get_stackaddr_np" => {
|
||||
let &[_thread] = check_arg_count(args)?;
|
||||
let _thread = this.read_scalar(_thread)?.not_undef()?;
|
||||
let &[thread] = check_arg_count(args)?;
|
||||
this.read_scalar(thread)?.not_undef()?;
|
||||
let stack_addr = Scalar::from_uint(STACK_ADDR, this.pointer_size());
|
||||
this.write_scalar(stack_addr, dest)?;
|
||||
}
|
||||
"pthread_get_stacksize_np" => {
|
||||
let &[_thread] = check_arg_count(args)?;
|
||||
let _thread = this.read_scalar(_thread)?.not_undef()?;
|
||||
let &[thread] = check_arg_count(args)?;
|
||||
this.read_scalar(thread)?.not_undef()?;
|
||||
let stack_size = Scalar::from_uint(STACK_SIZE, this.pointer_size());
|
||||
this.write_scalar(stack_size, dest)?;
|
||||
}
|
||||
|
@ -97,8 +97,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
|
||||
// Allocation
|
||||
"HeapAlloc" => {
|
||||
let &[_handle, flags, size] = check_arg_count(args)?;
|
||||
let _handle = this.read_scalar(_handle)?.to_machine_isize(this)?;
|
||||
let &[handle, flags, size] = check_arg_count(args)?;
|
||||
this.read_scalar(handle)?.to_machine_isize(this)?;
|
||||
let flags = this.read_scalar(flags)?.to_u32()?;
|
||||
let size = this.read_scalar(size)?.to_machine_usize(this)?;
|
||||
let zero_init = (flags & 0x00000008) != 0; // HEAP_ZERO_MEMORY
|
||||
@ -106,16 +106,16 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
this.write_scalar(res, dest)?;
|
||||
}
|
||||
"HeapFree" => {
|
||||
let &[_handle, _flags, ptr] = check_arg_count(args)?;
|
||||
let _handle = this.read_scalar(_handle)?.to_machine_isize(this)?;
|
||||
let &[handle, _flags, ptr] = check_arg_count(args)?;
|
||||
this.read_scalar(handle)?.to_machine_isize(this)?;
|
||||
let _flags = this.read_scalar(_flags)?.to_u32()?;
|
||||
let ptr = this.read_scalar(ptr)?.not_undef()?;
|
||||
this.free(ptr, MiriMemoryKind::WinHeap)?;
|
||||
this.write_scalar(Scalar::from_i32(1), dest)?;
|
||||
}
|
||||
"HeapReAlloc" => {
|
||||
let &[_handle, _flags, ptr, size] = check_arg_count(args)?;
|
||||
let _handle = this.read_scalar(_handle)?.to_machine_isize(this)?;
|
||||
let &[handle, _flags, ptr, size] = check_arg_count(args)?;
|
||||
this.read_scalar(handle)?.to_machine_isize(this)?;
|
||||
let _flags = this.read_scalar(_flags)?.to_u32()?;
|
||||
let ptr = this.read_scalar(ptr)?.not_undef()?;
|
||||
let size = this.read_scalar(size)?.to_machine_usize(this)?;
|
||||
@ -216,18 +216,18 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
|
||||
}
|
||||
"GetConsoleScreenBufferInfo" => {
|
||||
// `term` needs this, so we fake it.
|
||||
let &[_console, _buffer_info] = check_arg_count(args)?;
|
||||
let _console = this.read_scalar(_console)?.to_machine_isize(this)?;
|
||||
let _buffer_info = this.deref_operand(_buffer_info)?;
|
||||
let &[console, buffer_info] = check_arg_count(args)?;
|
||||
this.read_scalar(console)?.to_machine_isize(this)?;
|
||||
this.deref_operand(buffer_info)?;
|
||||
// Indicate an error.
|
||||
// FIXME: we should set last_error, but to what?
|
||||
this.write_null(dest)?;
|
||||
}
|
||||
"GetConsoleMode" => {
|
||||
// Windows "isatty" (in libtest) needs this, so we fake it.
|
||||
let &[_console, _mode] = check_arg_count(args)?;
|
||||
let _console = this.read_scalar(_console)?.to_machine_isize(this)?;
|
||||
let _mode = this.deref_operand(_mode)?;
|
||||
let &[console, mode] = check_arg_count(args)?;
|
||||
this.read_scalar(console)?.to_machine_isize(this)?;
|
||||
this.deref_operand(mode)?;
|
||||
// Indicate an error.
|
||||
// FIXME: we should set last_error, but to what?
|
||||
this.write_null(dest)?;
|
||||
|
Loading…
x
Reference in New Issue
Block a user