@@ -9,6 +9,9 @@ use crate::{concurrency::VClock, *};
9
9
10
10
use self :: shims:: unix:: fd:: FileDescriptor ;
11
11
12
+ /// Minimum size of u8 array to hold u64 value.
13
+ const U64_MIN_ARRAY_SIZE : usize = 8 ;
14
+
12
15
/// Maximum value that the eventfd counter can hold.
13
16
const MAX_COUNTER : u64 = u64:: MAX - 1 ;
14
17
@@ -48,7 +51,7 @@ impl FileDescription for Event {
48
51
ecx : & mut MiriInterpCx < ' tcx > ,
49
52
) -> InterpResult < ' tcx , io:: Result < usize > > {
50
53
// Check the size of slice, and return error only if the size of the slice < 8.
51
- let Some ( bytes) = bytes. first_chunk_mut :: < 8 > ( ) else {
54
+ let Some ( bytes) = bytes. first_chunk_mut :: < U64_MIN_ARRAY_SIZE > ( ) else {
52
55
return Ok ( Err ( Error :: from ( ErrorKind :: InvalidInput ) ) ) ;
53
56
} ;
54
57
// Block when counter == 0.
@@ -68,7 +71,7 @@ impl FileDescription for Event {
68
71
Endian :: Big => self . counter . to_be_bytes ( ) ,
69
72
} ;
70
73
self . counter = 0 ;
71
- return Ok ( Ok ( 8 ) ) ;
74
+ return Ok ( Ok ( U64_MIN_ARRAY_SIZE ) ) ;
72
75
}
73
76
}
74
77
@@ -91,7 +94,7 @@ impl FileDescription for Event {
91
94
ecx : & mut MiriInterpCx < ' tcx > ,
92
95
) -> InterpResult < ' tcx , io:: Result < usize > > {
93
96
// Check the size of slice, and return error only if the size of the slice < 8.
94
- let Some ( bytes) = bytes. first_chunk :: < 8 > ( ) else {
97
+ let Some ( bytes) = bytes. first_chunk :: < U64_MIN_ARRAY_SIZE > ( ) else {
95
98
return Ok ( Err ( Error :: from ( ErrorKind :: InvalidInput ) ) ) ;
96
99
} ;
97
100
// Convert from bytes to int according to host endianness.
@@ -120,7 +123,7 @@ impl FileDescription for Event {
120
123
}
121
124
}
122
125
} ;
123
- Ok ( Ok ( 8 ) )
126
+ Ok ( Ok ( U64_MIN_ARRAY_SIZE ) )
124
127
}
125
128
}
126
129
@@ -161,14 +164,14 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
161
164
162
165
let mut is_nonblock = false ;
163
166
// Unload the flag that we support.
167
+ // After unloading, flags != 0 means other flags are used.
164
168
if flags & efd_cloexec == efd_cloexec {
165
169
flags &= !efd_cloexec;
166
170
}
167
171
if flags & efd_nonblock == efd_nonblock {
168
172
flags &= !efd_nonblock;
169
173
is_nonblock = true ;
170
174
}
171
- // After unloading, flags != 0 means other flags are used.
172
175
if flags != 0 {
173
176
let einval = this. eval_libc ( "EINVAL" ) ;
174
177
this. set_last_error ( einval) ?;
0 commit comments