Merge pull request #67 from dmitris/fix-clippy

Fix clippy issues in the generated code.
pull/72/head
Michal Rostecki 2 years ago committed by GitHub
commit 2ba73f6f2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,5 +1,4 @@
use std::path::PathBuf;
use std::process::Command;
use std::{path::PathBuf, process::Command};
use clap::Parser;
@ -55,7 +54,7 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
args.push("--release")
}
let status = Command::new("cargo")
.current_dir(&dir)
.current_dir(dir)
.args(&args)
.status()
.expect("failed to build bpf program");

@ -27,7 +27,7 @@ fn main() {
};
if let Err(e) = ret {
eprintln!("{:#}", e);
eprintln!("{e:#}");
exit(1);
}
}

@ -47,7 +47,7 @@ pub fn run(opts: Options) -> Result<(), anyhow::Error> {
// profile we are building (release or debug)
let profile = if opts.release { "release" } else { "debug" };
let bin_path = format!("target/{}/{{project-name}}", profile);
let bin_path = format!("target/{profile}/{{project-name}}");
// arguments to pass to the application
let mut run_args: Vec<_> = opts.run_args.iter().map(String::as_str).collect();
@ -58,7 +58,7 @@ pub fn run(opts: Options) -> Result<(), anyhow::Error> {
args.append(&mut run_args);
// spawn the command
let err = Command::new(args.get(0).expect("No first argument"))
let err = Command::new(args.first().expect("No first argument"))
.args(args.iter().skip(1))
.exec();

@ -43,6 +43,9 @@ use clap::Parser;
use log::{info, warn};
use tokio::signal;
{% case program_type %}
{%- when
"xdp", "classifier", "sock_ops", "cgroup_skb", "cgroup_sysctl", "cgroup_sockopt", "uprobe", "uretprobe" -%}
#[derive(Debug, Parser)]
struct Opt {
{% if program_type == "xdp" or program_type == "classifier" -%}
@ -56,11 +59,17 @@ struct Opt {
pid: Option<i32>
{%- endif %}
}
{%- endcase %}
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
{% case program_type %}
{%- when
"xdp", "classifier", "sock_ops", "cgroup_skb", "cgroup_sysctl", "cgroup_sockopt", "uprobe", "uretprobe" -%}
let opt = Opt::parse();
{%- endcase %}
env_logger::init();
// This will include your eBPF object file as raw bytes at compile-time and load it at

Loading…
Cancel
Save