@@ -144,7 +144,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
144144 name_op : & OpTy < ' tcx , Provenance > , // LPCWSTR
145145 buf_op : & OpTy < ' tcx , Provenance > , // LPWSTR
146146 size_op : & OpTy < ' tcx , Provenance > , // DWORD
147- ) -> InterpResult < ' tcx , u32 > {
147+ ) -> InterpResult < ' tcx , Scalar < Provenance > > {
148148 // ^ Returns DWORD (u32 on Windows)
149149
150150 let this = self . eval_context_mut ( ) ;
@@ -165,12 +165,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
165165 let buf_ptr = this. read_pointer ( buf_op) ?;
166166 // `buf_size` represents the size in characters.
167167 let buf_size = u64:: from ( this. read_scalar ( size_op) ?. to_u32 ( ) ?) ;
168- windows_check_buffer_size ( this. write_os_str_to_wide_str ( & var, buf_ptr, buf_size) ?)
168+ Scalar :: from_u32 ( windows_check_buffer_size (
169+ this. write_os_str_to_wide_str ( & var, buf_ptr, buf_size) ?,
170+ ) )
169171 }
170172 None => {
171173 let envvar_not_found = this. eval_windows ( "c" , "ERROR_ENVVAR_NOT_FOUND" ) ?;
172174 this. set_last_error ( envvar_not_found) ?;
173- 0 // return zero upon failure
175+ Scalar :: from_u32 ( 0 ) // return zero upon failure
174176 }
175177 } )
176178 }
@@ -200,14 +202,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
200202 fn FreeEnvironmentStringsW (
201203 & mut self ,
202204 env_block_op : & OpTy < ' tcx , Provenance > ,
203- ) -> InterpResult < ' tcx , i32 > {
205+ ) -> InterpResult < ' tcx , Scalar < Provenance > > {
204206 let this = self . eval_context_mut ( ) ;
205207 this. assert_target_os ( "windows" , "FreeEnvironmentStringsW" ) ;
206208
207209 let env_block_ptr = this. read_pointer ( env_block_op) ?;
208210 let result = this. deallocate_ptr ( env_block_ptr, None , MiriMemoryKind :: Runtime . into ( ) ) ;
209211 // If the function succeeds, the return value is nonzero.
210- Ok ( i32:: from ( result. is_ok ( ) ) )
212+ Ok ( Scalar :: from_i32 ( i32:: from ( result. is_ok ( ) ) ) )
211213 }
212214
213215 fn setenv (
@@ -249,7 +251,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
249251 & mut self ,
250252 name_op : & OpTy < ' tcx , Provenance > , // LPCWSTR
251253 value_op : & OpTy < ' tcx , Provenance > , // LPCWSTR
252- ) -> InterpResult < ' tcx , i32 > {
254+ ) -> InterpResult < ' tcx , Scalar < Provenance > > {
253255 let this = self . eval_context_mut ( ) ;
254256 this. assert_target_os ( "windows" , "SetEnvironmentVariableW" ) ;
255257
@@ -272,15 +274,15 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
272274 this. deallocate_ptr ( var, None , MiriMemoryKind :: Runtime . into ( ) ) ?;
273275 this. update_environ ( ) ?;
274276 }
275- Ok ( 1 ) // return non-zero on success
277+ Ok ( Scalar :: from_i32 ( 1 ) ) // return non-zero on success
276278 } else {
277279 let value = this. read_os_str_from_wide_str ( value_ptr) ?;
278280 let var_ptr = alloc_env_var_as_wide_str ( & name, & value, this) ?;
279281 if let Some ( var) = this. machine . env_vars . map . insert ( name, var_ptr) {
280282 this. deallocate_ptr ( var, None , MiriMemoryKind :: Runtime . into ( ) ) ?;
281283 }
282284 this. update_environ ( ) ?;
283- Ok ( 1 ) // return non-zero on success
285+ Ok ( Scalar :: from_i32 ( 1 ) ) // return non-zero on success
284286 }
285287 }
286288
@@ -347,7 +349,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
347349 & mut self ,
348350 size_op : & OpTy < ' tcx , Provenance > , // DWORD
349351 buf_op : & OpTy < ' tcx , Provenance > , // LPTSTR
350- ) -> InterpResult < ' tcx , u32 > {
352+ ) -> InterpResult < ' tcx , Scalar < Provenance > > {
351353 let this = self . eval_context_mut ( ) ;
352354 this. assert_target_os ( "windows" , "GetCurrentDirectoryW" ) ;
353355
@@ -357,16 +359,18 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
357359 if let IsolatedOp :: Reject ( reject_with) = this. machine . isolated_op {
358360 this. reject_in_isolation ( "`GetCurrentDirectoryW`" , reject_with) ?;
359361 this. set_last_error_from_io_error ( ErrorKind :: PermissionDenied ) ?;
360- return Ok ( 0 ) ;
362+ return Ok ( Scalar :: from_u32 ( 0 ) ) ;
361363 }
362364
363365 // If we cannot get the current directory, we return 0
364366 match env:: current_dir ( ) {
365367 Ok ( cwd) =>
366- return Ok ( windows_check_buffer_size ( this. write_path_to_wide_str ( & cwd, buf, size) ?) ) ,
368+ return Ok ( Scalar :: from_u32 ( windows_check_buffer_size (
369+ this. write_path_to_wide_str ( & cwd, buf, size) ?,
370+ ) ) ) ,
367371 Err ( e) => this. set_last_error_from_io_error ( e. kind ( ) ) ?,
368372 }
369- Ok ( 0 )
373+ Ok ( Scalar :: from_u32 ( 0 ) )
370374 }
371375
372376 fn chdir ( & mut self , path_op : & OpTy < ' tcx , Provenance > ) -> InterpResult < ' tcx , i32 > {
@@ -395,7 +399,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
395399 fn SetCurrentDirectoryW (
396400 & mut self ,
397401 path_op : & OpTy < ' tcx , Provenance > , // LPCTSTR
398- ) -> InterpResult < ' tcx , i32 > {
402+ ) -> InterpResult < ' tcx , Scalar < Provenance > > {
399403 // ^ Returns BOOL (i32 on Windows)
400404
401405 let this = self . eval_context_mut ( ) ;
@@ -407,14 +411,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
407411 this. reject_in_isolation ( "`SetCurrentDirectoryW`" , reject_with) ?;
408412 this. set_last_error_from_io_error ( ErrorKind :: PermissionDenied ) ?;
409413
410- return Ok ( 0 ) ;
414+ return Ok ( Scalar :: from_i32 ( 0 ) ) ;
411415 }
412416
413417 match env:: set_current_dir ( path) {
414- Ok ( ( ) ) => Ok ( 1 ) ,
418+ Ok ( ( ) ) => Ok ( Scalar :: from_i32 ( 1 ) ) ,
415419 Err ( e) => {
416420 this. set_last_error_from_io_error ( e. kind ( ) ) ?;
417- Ok ( 0 )
421+ Ok ( Scalar :: from_i32 ( 0 ) )
418422 }
419423 }
420424 }
0 commit comments