From c7dfae49335581d37e9161d811b34a7a4bec0aa4 Mon Sep 17 00:00:00 2001 From: Dmitry Savintsev Date: Wed, 6 Oct 2021 15:53:12 +0200 Subject: [PATCH] import TryFrom only for sk_msg programs Avoid unused_imports warning for std::convert::TryFrom. Conditionally import it only when it is needed - in sk_msg programs. remove unused `std::convert::TryFrom` import to avoid the warning in the generated projects: ``` warning: unused import: `TryFrom` --> myapp/src/main.rs:4:15 | 4 | convert::{TryFrom,TryInto}, | ^^^^^^^ | = note: `#[warn(unused_imports)]` on by default warning: `myapp` (bin "myapp") generated 1 warning ``` --- {{project-name}}/src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/{{project-name}}/src/main.rs b/{{project-name}}/src/main.rs index 0b775b4..9e1ccf1 100644 --- a/{{project-name}}/src/main.rs +++ b/{{project-name}}/src/main.rs @@ -14,6 +14,7 @@ use aya::programs::SockOps; use aya::maps::{MapRefMut,SockHash}; use aya::programs::SkMsg; use {{crate_name}}_common::SockKey; +use std::convert::TryFrom; {%- when "xdp" -%} use aya::programs::{Xdp, XdpFlags}; {%- when "classifier" -%} @@ -28,7 +29,7 @@ use aya::{programs::Lsm, Btf}; use aya::{programs::BtfTracePoint, Btf}; {%- endcase %} use std::{ - convert::{TryFrom,TryInto}, + convert::TryInto, sync::Arc, sync::atomic::{AtomicBool, Ordering}, thread,