Skip to content

Commit 032c161

Browse files
andreeaflorescualexandruag
authored andcommitted
fix initialization of invalid fds
With Rust 1.52.1 we can no longer initialize invalid fd 2 by using -1 as the value because there is an assert in the from_raw_fd function that checks for that value. We can use -2 instead. Signed-off-by: Andreea Florescu <[email protected]>
1 parent aa59b37 commit 032c161

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/ioctls/system.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ mod tests {
718718
let badf_errno = libc::EBADF;
719719

720720
let faulty_kvm = Kvm {
721-
kvm: unsafe { File::from_raw_fd(-1) },
721+
kvm: unsafe { File::from_raw_fd(-2) },
722722
};
723723

724724
assert_eq!(

src/ioctls/vcpu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1969,7 +1969,7 @@ mod tests {
19691969
let badf_errno = libc::EBADF;
19701970

19711971
let faulty_vcpu_fd = VcpuFd {
1972-
vcpu: unsafe { File::from_raw_fd(-1) },
1972+
vcpu: unsafe { File::from_raw_fd(-2) },
19731973
kvm_run_ptr: KvmRunWrapper {
19741974
kvm_run_ptr: mmap_anonymous(10),
19751975
mmap_size: 10,

src/ioctls/vm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1633,7 +1633,7 @@ mod tests {
16331633
let badf_errno = libc::EBADF;
16341634

16351635
let faulty_vm_fd = VmFd {
1636-
vm: unsafe { File::from_raw_fd(-1) },
1636+
vm: unsafe { File::from_raw_fd(-2) },
16371637
run_size: 0,
16381638
};
16391639

0 commit comments

Comments
 (0)