@@ -562,17 +562,17 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
562
562
let mut mirror = access_mode;
563
563
564
564
let o_append = this. eval_libc_i32 ( "O_APPEND" ) ?;
565
- if flag & o_append != 0 {
565
+ if flag & o_append == o_append {
566
566
options. append ( true ) ;
567
567
mirror |= o_append;
568
568
}
569
569
let o_trunc = this. eval_libc_i32 ( "O_TRUNC" ) ?;
570
- if flag & o_trunc != 0 {
570
+ if flag & o_trunc == o_trunc {
571
571
options. truncate ( true ) ;
572
572
mirror |= o_trunc;
573
573
}
574
574
let o_creat = this. eval_libc_i32 ( "O_CREAT" ) ?;
575
- if flag & o_creat != 0 {
575
+ if flag & o_creat == o_creat {
576
576
// Get the mode. On macOS, the argument type `mode_t` is actually `u16`, but
577
577
// C integer promotion rules mean that on the ABI level, it gets passed as `u32`
578
578
// (see https://github.com/rust-lang/rust/issues/71915).
@@ -592,22 +592,22 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
592
592
mirror |= o_creat;
593
593
594
594
let o_excl = this. eval_libc_i32 ( "O_EXCL" ) ?;
595
- if flag & o_excl != 0 {
595
+ if flag & o_excl == o_excl {
596
596
mirror |= o_excl;
597
597
options. create_new ( true ) ;
598
598
} else {
599
599
options. create ( true ) ;
600
600
}
601
601
}
602
602
let o_cloexec = this. eval_libc_i32 ( "O_CLOEXEC" ) ?;
603
- if flag & o_cloexec != 0 {
603
+ if flag & o_cloexec == o_cloexec {
604
604
// We do not need to do anything for this flag because `std` already sets it.
605
605
// (Technically we do not support *not* setting this flag, but we ignore that.)
606
606
mirror |= o_cloexec;
607
607
}
608
608
if this. tcx . sess . target . os == "linux" {
609
609
let o_tmpfile = this. eval_libc_i32 ( "O_TMPFILE" ) ?;
610
- if flag & o_tmpfile != 0 {
610
+ if flag & o_tmpfile == o_tmpfile {
611
611
// if the flag contains `O_TMPFILE` then we return a graceful error
612
612
let eopnotsupp = this. eval_libc ( "EOPNOTSUPP" ) ?;
613
613
this. set_last_error ( eopnotsupp) ?;
@@ -1020,7 +1020,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
1020
1020
1021
1021
let path = this. read_path_from_c_str ( pathname_ptr) ?. into_owned ( ) ;
1022
1022
// 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;
1024
1025
// We only support:
1025
1026
// * interpreting `path` as an absolute directory,
1026
1027
// * interpreting `path` as a path relative to `dirfd` when the latter is `AT_FDCWD`, or
0 commit comments