@@ -562,17 +562,17 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
562562 let mut mirror = access_mode;
563563
564564 let o_append = this. eval_libc_i32 ( "O_APPEND" ) ?;
565- if flag & o_append != 0 {
565+ if flag & o_append == o_append {
566566 options. append ( true ) ;
567567 mirror |= o_append;
568568 }
569569 let o_trunc = this. eval_libc_i32 ( "O_TRUNC" ) ?;
570- if flag & o_trunc != 0 {
570+ if flag & o_trunc == o_trunc {
571571 options. truncate ( true ) ;
572572 mirror |= o_trunc;
573573 }
574574 let o_creat = this. eval_libc_i32 ( "O_CREAT" ) ?;
575- if flag & o_creat != 0 {
575+ if flag & o_creat == o_creat {
576576 // Get the mode. On macOS, the argument type `mode_t` is actually `u16`, but
577577 // C integer promotion rules mean that on the ABI level, it gets passed as `u32`
578578 // (see https://github.com/rust-lang/rust/issues/71915).
@@ -592,22 +592,22 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
592592 mirror |= o_creat;
593593
594594 let o_excl = this. eval_libc_i32 ( "O_EXCL" ) ?;
595- if flag & o_excl != 0 {
595+ if flag & o_excl == o_excl {
596596 mirror |= o_excl;
597597 options. create_new ( true ) ;
598598 } else {
599599 options. create ( true ) ;
600600 }
601601 }
602602 let o_cloexec = this. eval_libc_i32 ( "O_CLOEXEC" ) ?;
603- if flag & o_cloexec != 0 {
603+ if flag & o_cloexec == o_cloexec {
604604 // We do not need to do anything for this flag because `std` already sets it.
605605 // (Technically we do not support *not* setting this flag, but we ignore that.)
606606 mirror |= o_cloexec;
607607 }
608608 if this. tcx . sess . target . os == "linux" {
609609 let o_tmpfile = this. eval_libc_i32 ( "O_TMPFILE" ) ?;
610- if flag & o_tmpfile != 0 {
610+ if flag & o_tmpfile == o_tmpfile {
611611 // if the flag contains `O_TMPFILE` then we return a graceful error
612612 let eopnotsupp = this. eval_libc ( "EOPNOTSUPP" ) ?;
613613 this. set_last_error ( eopnotsupp) ?;
@@ -1020,7 +1020,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
10201020
10211021 let path = this. read_path_from_c_str ( pathname_ptr) ?. into_owned ( ) ;
10221022 // See <https://github.com/rust-lang/rust/pull/79196> for a discussion of argument sizes.
1023- let empty_path_flag = flags & this. eval_libc ( "AT_EMPTY_PATH" ) ?. to_i32 ( ) ? != 0 ;
1023+ let at_ampty_path = this. eval_libc_i32 ( "AT_EMPTY_PATH" ) ?;
1024+ let empty_path_flag = flags & at_ampty_path == at_ampty_path;
10241025 // We only support:
10251026 // * interpreting `path` as an absolute directory,
10261027 // * interpreting `path` as a path relative to `dirfd` when the latter is `AT_FDCWD`, or
0 commit comments