From b599062ec31628b96891893e95fcfed605208fc6 Mon Sep 17 00:00:00 2001 From: Mikko Ylinen Date: Sat, 7 Sep 2024 08:21:00 +0300 Subject: [PATCH] ocicrypt: keyprovider: fix warnings on dead code For quite some time, we have seen: warning: struct `TestRunner` is never constructed Warning: --> ocicrypt-rs/src/keywrap/keyprovider/mod.rs:558:16 | 558 | pub struct TestRunner {} | ^^^^^^^^^^ | = note: `TestRunner` has a derived impl for the trait `Clone`, but this is intentionally ignored during dead code analysis = note: `#[warn(dead_code)]` on by default warning: struct `TestServer` is never constructed Warning: --> ocicrypt-rs/src/keywrap/keyprovider/mod.rs:570:12 | 570 | struct TestServer {} | ^^^^^^^^^^ | = note: `TestServer` has a derived impl for the trait `Default`, but this is intentionally ignored during dead code analysis The fix is to add them behind the right feature flags. Signed-off-by: Mikko Ylinen --- ocicrypt-rs/src/keywrap/keyprovider/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ocicrypt-rs/src/keywrap/keyprovider/mod.rs b/ocicrypt-rs/src/keywrap/keyprovider/mod.rs index ddf0bc56c..464670cde 100644 --- a/ocicrypt-rs/src/keywrap/keyprovider/mod.rs +++ b/ocicrypt-rs/src/keywrap/keyprovider/mod.rs @@ -555,6 +555,7 @@ mod tests { ///Test runner which mocks binary executable for key wrapping and unwrapping #[derive(Clone, Copy)] + #[cfg(feature = "keywrap-keyprovider-cmd")] pub struct TestRunner {} ///Mock annotation packet, which goes into container image manifest @@ -567,6 +568,10 @@ mod tests { ///grpc server with mock api implementation for serving the clients with mock WrapKey and Unwrapkey grpc method implementations #[derive(Default)] + #[cfg(any( + feature = "keywrap-keyprovider-grpc", + feature = "keywrap-keyprovider-ttrpc" + ))] struct TestServer {} #[cfg(any(