@@ -144,7 +144,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
144
144
name_op : & OpTy < ' tcx , Provenance > , // LPCWSTR
145
145
buf_op : & OpTy < ' tcx , Provenance > , // LPWSTR
146
146
size_op : & OpTy < ' tcx , Provenance > , // DWORD
147
- ) -> InterpResult < ' tcx , u32 > {
147
+ ) -> InterpResult < ' tcx , Scalar < Provenance > > {
148
148
// ^ Returns DWORD (u32 on Windows)
149
149
150
150
let this = self . eval_context_mut ( ) ;
@@ -165,12 +165,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
165
165
let buf_ptr = this. read_pointer ( buf_op) ?;
166
166
// `buf_size` represents the size in characters.
167
167
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
+ ) )
169
171
}
170
172
None => {
171
173
let envvar_not_found = this. eval_windows ( "c" , "ERROR_ENVVAR_NOT_FOUND" ) ?;
172
174
this. set_last_error ( envvar_not_found) ?;
173
- 0 // return zero upon failure
175
+ Scalar :: from_u32 ( 0 ) // return zero upon failure
174
176
}
175
177
} )
176
178
}
@@ -200,14 +202,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
200
202
fn FreeEnvironmentStringsW (
201
203
& mut self ,
202
204
env_block_op : & OpTy < ' tcx , Provenance > ,
203
- ) -> InterpResult < ' tcx , i32 > {
205
+ ) -> InterpResult < ' tcx , Scalar < Provenance > > {
204
206
let this = self . eval_context_mut ( ) ;
205
207
this. assert_target_os ( "windows" , "FreeEnvironmentStringsW" ) ;
206
208
207
209
let env_block_ptr = this. read_pointer ( env_block_op) ?;
208
210
let result = this. deallocate_ptr ( env_block_ptr, None , MiriMemoryKind :: Runtime . into ( ) ) ;
209
211
// 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 ( ) ) ) )
211
213
}
212
214
213
215
fn setenv (
@@ -249,7 +251,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
249
251
& mut self ,
250
252
name_op : & OpTy < ' tcx , Provenance > , // LPCWSTR
251
253
value_op : & OpTy < ' tcx , Provenance > , // LPCWSTR
252
- ) -> InterpResult < ' tcx , i32 > {
254
+ ) -> InterpResult < ' tcx , Scalar < Provenance > > {
253
255
let this = self . eval_context_mut ( ) ;
254
256
this. assert_target_os ( "windows" , "SetEnvironmentVariableW" ) ;
255
257
@@ -272,15 +274,15 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
272
274
this. deallocate_ptr ( var, None , MiriMemoryKind :: Runtime . into ( ) ) ?;
273
275
this. update_environ ( ) ?;
274
276
}
275
- Ok ( 1 ) // return non-zero on success
277
+ Ok ( Scalar :: from_i32 ( 1 ) ) // return non-zero on success
276
278
} else {
277
279
let value = this. read_os_str_from_wide_str ( value_ptr) ?;
278
280
let var_ptr = alloc_env_var_as_wide_str ( & name, & value, this) ?;
279
281
if let Some ( var) = this. machine . env_vars . map . insert ( name, var_ptr) {
280
282
this. deallocate_ptr ( var, None , MiriMemoryKind :: Runtime . into ( ) ) ?;
281
283
}
282
284
this. update_environ ( ) ?;
283
- Ok ( 1 ) // return non-zero on success
285
+ Ok ( Scalar :: from_i32 ( 1 ) ) // return non-zero on success
284
286
}
285
287
}
286
288
@@ -347,7 +349,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
347
349
& mut self ,
348
350
size_op : & OpTy < ' tcx , Provenance > , // DWORD
349
351
buf_op : & OpTy < ' tcx , Provenance > , // LPTSTR
350
- ) -> InterpResult < ' tcx , u32 > {
352
+ ) -> InterpResult < ' tcx , Scalar < Provenance > > {
351
353
let this = self . eval_context_mut ( ) ;
352
354
this. assert_target_os ( "windows" , "GetCurrentDirectoryW" ) ;
353
355
@@ -357,16 +359,18 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
357
359
if let IsolatedOp :: Reject ( reject_with) = this. machine . isolated_op {
358
360
this. reject_in_isolation ( "`GetCurrentDirectoryW`" , reject_with) ?;
359
361
this. set_last_error_from_io_error ( ErrorKind :: PermissionDenied ) ?;
360
- return Ok ( 0 ) ;
362
+ return Ok ( Scalar :: from_u32 ( 0 ) ) ;
361
363
}
362
364
363
365
// If we cannot get the current directory, we return 0
364
366
match env:: current_dir ( ) {
365
367
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
+ ) ) ) ,
367
371
Err ( e) => this. set_last_error_from_io_error ( e. kind ( ) ) ?,
368
372
}
369
- Ok ( 0 )
373
+ Ok ( Scalar :: from_u32 ( 0 ) )
370
374
}
371
375
372
376
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> {
395
399
fn SetCurrentDirectoryW (
396
400
& mut self ,
397
401
path_op : & OpTy < ' tcx , Provenance > , // LPCTSTR
398
- ) -> InterpResult < ' tcx , i32 > {
402
+ ) -> InterpResult < ' tcx , Scalar < Provenance > > {
399
403
// ^ Returns BOOL (i32 on Windows)
400
404
401
405
let this = self . eval_context_mut ( ) ;
@@ -407,14 +411,14 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
407
411
this. reject_in_isolation ( "`SetCurrentDirectoryW`" , reject_with) ?;
408
412
this. set_last_error_from_io_error ( ErrorKind :: PermissionDenied ) ?;
409
413
410
- return Ok ( 0 ) ;
414
+ return Ok ( Scalar :: from_i32 ( 0 ) ) ;
411
415
}
412
416
413
417
match env:: set_current_dir ( path) {
414
- Ok ( ( ) ) => Ok ( 1 ) ,
418
+ Ok ( ( ) ) => Ok ( Scalar :: from_i32 ( 1 ) ) ,
415
419
Err ( e) => {
416
420
this. set_last_error_from_io_error ( e. kind ( ) ) ?;
417
- Ok ( 0 )
421
+ Ok ( Scalar :: from_i32 ( 0 ) )
418
422
}
419
423
}
420
424
}
0 commit comments