Skip to content

Commit

Permalink
Silence clippy warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Daiki Ueno <[email protected]>
  • Loading branch information
ueno committed Apr 1, 2024
1 parent b5a3891 commit 257fbaf
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
4 changes: 2 additions & 2 deletions agent/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ fn main() {

let vmlinux_h = srcdir.join("src").join("bpf").join("vmlinux.h");
if vmlinux_h.exists() {
fs::copy(&vmlinux_h, &builddir.join("vmlinux.h")).expect("unable to copy vmlinux.h");
fs::copy(&vmlinux_h, builddir.join("vmlinux.h")).expect("unable to copy vmlinux.h");
} else {
let file = File::create(&builddir.join("vmlinux.h")).expect("unable to create vmlinux.h");
let file = File::create(builddir.join("vmlinux.h")).expect("unable to create vmlinux.h");
Command::new("bpftool")
.arg("btf")
.arg("dump")
Expand Down
4 changes: 2 additions & 2 deletions agent/tests/agenttest/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ fn main() {

let vmlinux_h = srcdir.join("src").join("bpf").join("vmlinux.h");
if vmlinux_h.exists() {
fs::copy(&vmlinux_h, &builddir.join("vmlinux.h")).expect("unable to copy vmlinux.h");
fs::copy(&vmlinux_h, builddir.join("vmlinux.h")).expect("unable to copy vmlinux.h");
} else {
let file = File::create(&builddir.join("vmlinux.h")).expect("unable to create vmlinux.h");
let file = File::create(builddir.join("vmlinux.h")).expect("unable to create vmlinux.h");
Command::new("bpftool")
.arg("btf")
.arg("dump")
Expand Down
17 changes: 6 additions & 11 deletions crypto-auditing/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,12 @@ impl EventGroup {

/// Removes events which do not match the given scopes
pub fn events_filtered(&mut self, scopes: &[String]) {
self.events = self
.events
.iter()
.cloned()
.filter(|event| match event {
Event::NewContext { .. } => true,
Event::Data { key, .. } => scopes
.iter()
.any(|scope| !key.contains("::") || key.starts_with(&format!("{}::", scope))),
})
.collect();
self.events.retain(|event| match event {
Event::NewContext { .. } => true,
Event::Data { key, .. } => scopes
.iter()
.any(|scope| !key.contains("::") || key.starts_with(&format!("{}::", scope))),
});
}

/// Deserializes an event group from bytes
Expand Down
11 changes: 7 additions & 4 deletions event-broker/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ use std::os::fd::{AsRawFd, RawFd};
use std::os::fd::{FromRawFd, IntoRawFd};
use std::os::unix::net::UnixListener as StdUnixListener;
use std::path::{Path, PathBuf};
use std::sync::{Arc, RwLock};
use std::sync::Arc;
use tokio::net::{unix::OwnedWriteHalf, UnixListener};
use tokio::sync::mpsc::{self, Receiver, Sender};
use tokio::sync::{
mpsc::{self, Receiver, Sender},
RwLock,
};
use tokio_serde::{formats::SymmetricalCbor, SymmetricallyFramed};
use tokio_stream::wrappers::ReceiverStream;
use tokio_util::codec::{FramedRead, FramedWrite, LengthDelimitedCodec};
Expand Down Expand Up @@ -137,7 +140,7 @@ impl Publisher {

// Populate the scopes
if let Some(scopes) = de.try_next().await.unwrap() {
subscriptions.write().unwrap().insert(
subscriptions.write().await.insert(
subscriber_fd,
Subscription {
stream: ser,
Expand All @@ -151,7 +154,7 @@ impl Publisher {

let mut stream = ReceiverStream::new(receiver);
while let Some(group) = stream.next().await {
let mut subscriptions = self.subscriptions.write().unwrap();
let mut subscriptions = self.subscriptions.write().await;
let mut publications = Vec::new();

for (_, subscription) in subscriptions.iter_mut() {
Expand Down

0 comments on commit 257fbaf

Please sign in to comment.