Work around type mismatches on 32-bit platforms

Signed-off-by: Daiki Ueno <dueno@redhat.com>
This commit is contained in:
Daiki Ueno 2022-01-25 07:30:43 +01:00
parent 8858a2e08d
commit aa69e4762d
2 changed files with 64 additions and 0 deletions

View File

@ -0,0 +1,63 @@
diff --git a/src/common.rs b/src/common.rs
index b44cf39..e38385e 100644
--- a/src/common.rs
+++ b/src/common.rs
@@ -252,7 +252,7 @@ pub(crate) fn chownroot(path: String) -> Result<String> {
}
// change directory owner to root
- if libc::chown(path.as_bytes().as_ptr() as *const i8, 0, 0) != 0 {
+ if libc::chown(path.as_bytes().as_ptr() as *const _, 0, 0) != 0 {
error!("Failed to change file {} owner.", path);
return Err(Error::Permission);
}
diff --git a/src/main.rs b/src/main.rs
index 4631836..d7598d7 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -18,7 +18,7 @@
missing_copy_implementations,
missing_debug_implementations,
missing_docs,
- trivial_casts,
+ //trivial_casts,
trivial_numeric_casts,
unused_allocation,
unused_comparisons,
diff --git a/src/tpm.rs b/src/tpm.rs
index f6ae1bb..dbcc848 100644
--- a/src/tpm.rs
+++ b/src/tpm.rs
@@ -117,12 +117,12 @@ pub(crate) fn create_ek(
fn unmarshal_tpms_attest(val: &[u8]) -> Result<TPMS_ATTEST> {
let mut resp = TPMS_ATTEST::default();
- let mut offset = 0u64;
+ let mut offset = 0;
unsafe {
let res = Tss2_MU_TPMS_ATTEST_Unmarshal(
val[..].as_ptr(),
- val.len() as u64,
+ val.len() as _,
&mut offset,
&mut resp,
);
@@ -140,7 +140,7 @@ fn unmarshal_tpms_attest(val: &[u8]) -> Result<TPMS_ATTEST> {
macro_rules! create_marshal_fn {
($func:ident, $tpmobj:ty, $marshal:ident) => {
fn $func(t: $tpmobj) -> Vec<u8> {
- let mut offset = 0u64;
+ let mut offset = 0;
let size = std::mem::size_of::<$tpmobj>();
let mut tpm_vec = Vec::with_capacity(size);
@@ -148,7 +148,7 @@ macro_rules! create_marshal_fn {
let res = $marshal(
&t,
tpm_vec.as_mut_ptr(),
- tpm_vec.capacity() as u64,
+ tpm_vec.capacity() as _,
&mut offset,
);
if res != 0 {

View File

@ -55,6 +55,7 @@ Source0: %{url}/archive/%{commit}/rust-keylime-%{version}.tar.gz
# cargo vendor
# tar jcf rust-keylime-%%{version}-vendor.tar.xz vendor
Source1: rust-keylime-%{version}-vendor.tar.xz
Patch1: keylime-agent-rust-types.patch
ExclusiveArch: %{rust_arches}