You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Auto merge of #1970 - asquared31415:open_unix_varargs, r=RalfJung
Allow varargs for libc::open when it is allowed by the second argument
This PR allows `libc::open` to be called using two or three arguments as defined in https://man7.org/linux/man-pages/man2/open.2.html
The presence of the third argument depends on the value of the second argument. If the second argument dictates that the third argument is *required* miri will emit an error if the argument is missing. If the second argument does *not* require a third argument, then the argument is ignored and passed as 0 internally (it would be ignored by libc anyway)
// `open` is variadic, the third argument is only present when the second argument has O_CREAT (or on linux O_TMPFILE, but miri doesn't support that) set
let name_ptr = name.as_ptr().cast::<libc::c_char>();
15
+
let _fd = unsafe{ libc::open(name_ptr, libc::O_CREAT)};//~ ERROR Undefined Behavior: incorrect number of arguments for `open` with `O_CREAT`: got 2, expected 3
let name_ptr = name.as_ptr().cast::<libc::c_char>();
15
+
let _fd = unsafe{ libc::open(name_ptr, libc::O_RDONLY,0,0)};//~ ERROR Undefined Behavior: incorrect number of arguments for `open`: got 4, expected 2 or 3
0 commit comments