From fee105d838168b246e1d756cf1d4dd18014436f6 Mon Sep 17 00:00:00 2001 From: Markus Theil Date: Thu, 12 Oct 2023 17:51:52 +0200 Subject: [PATCH] more fiddling with anon unions Signed-off-by: Markus Theil --- openssl-sys/src/handwritten/x509_sbgp.rs | 16 ++++++++++++++-- openssl/src/x509/sbgp.rs | 10 +--------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/openssl-sys/src/handwritten/x509_sbgp.rs b/openssl-sys/src/handwritten/x509_sbgp.rs index 8dbc7a0fc7..f979e2cb2e 100644 --- a/openssl-sys/src/handwritten/x509_sbgp.rs +++ b/openssl-sys/src/handwritten/x509_sbgp.rs @@ -27,11 +27,17 @@ pub union ASIdOrRange_st_anon_union { #[cfg(ossl110)] stack!(stack_st_ASIdOrRange); +#[repr(C)] +#[cfg(ossl110)] +pub union ASIdsOrRanges_st_anon_union { + pub asIdsOrRanges: *mut stack_st_ASIdOrRange, +} + #[repr(C)] #[cfg(ossl110)] pub struct ASIdentifierChoice { pub type_: c_int, - pub asIdsOrRanges: *mut stack_st_ASIdOrRange, + pub u: ASIdsOrRanges_st_anon_union, } #[repr(C)] @@ -66,11 +72,17 @@ stack!(stack_st_IPAddressOrRange); #[cfg(ossl110)] type IPAddressOrRanges = stack_st_IPAddressOrRange; +#[repr(C)] +#[cfg(ossl110)] +pub union IPAddressOrRanges_st_anon_union { + pub addressesOrRanges: *mut IPAddressOrRanges +} + #[repr(C)] #[cfg(ossl110)] pub struct IPAddressChoice { pub type_: c_int, - pub addressesOrRanges: *mut IPAddressOrRanges, + pub u: IPAddressOrRanges_st_anon_union, } #[repr(C)] diff --git a/openssl/src/x509/sbgp.rs b/openssl/src/x509/sbgp.rs index 3a620ae2ad..8f3cf7f945 100644 --- a/openssl/src/x509/sbgp.rs +++ b/openssl/src/x509/sbgp.rs @@ -66,11 +66,7 @@ impl ASIdentifiers { if (*asnum).type_ != ASIdentifierChoice_asIdsOrRanges { return None; } - #[cfg(ossl310)] - let as_range = StackRef::::from_const_ptr_opt((*asnum).u.asIdsOrRanges); - #[cfg(any(not(ossl310),ossl320))] - let as_range = StackRef::::from_const_ptr_opt((*asnum).asIdsOrRanges); - if let Some(s) = as_range { + if let Some(s) = StackRef::::from_const_ptr_opt((*asnum).u.asIdsOrRanges) { for a_ptr in s { let a = a_ptr.as_ptr(); if (*a).type_ == ASIdOrRange_id { @@ -159,12 +155,8 @@ impl IPAddressFamily { if (*choice).type_ != IPAddressChoice_addressesOrRanges { return None; } - #[cfg(ossl310)] let stack = StackRef::::from_const_ptr_opt((*choice).u.addressesOrRanges)?; - #[cfg(any(not(ossl310),ossl320))] - let stack = - StackRef::::from_const_ptr_opt((*choice).addressesOrRanges)?; for e in stack { let mut min = MaybeUninit::<[u8; 16]>::uninit(); let mut max = MaybeUninit::<[u8; 16]>::uninit();