Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appease rustc dead_code lint #881

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions aya-log/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,21 @@ use bytes::BytesMut;
use log::{error, Log, Record};
use thiserror::Error;

#[allow(dead_code)] // TODO(https://github.com/rust-lang/rust/issues/120770): Remove when false positive is fixed.
#[derive(Copy, Clone)]
#[repr(transparent)]
struct RecordFieldWrapper(RecordField);
#[allow(dead_code)] // TODO(https://github.com/rust-lang/rust/issues/120770): Remove when false positive is fixed.
#[derive(Copy, Clone)]
#[repr(transparent)]
struct ArgumentWrapper(Argument);
#[derive(Copy, Clone)]
#[repr(transparent)]
struct DisplayHintWrapper(DisplayHint);

unsafe impl aya::Pod for RecordFieldWrapper {}
unsafe impl aya::Pod for ArgumentWrapper {}
unsafe impl aya::Pod for DisplayHintWrapper {}
unsafe impl Pod for RecordFieldWrapper {}
unsafe impl Pod for ArgumentWrapper {}
unsafe impl Pod for DisplayHintWrapper {}

/// Log messages generated by `aya_log_ebpf` using the [log] crate.
///
Expand Down
30 changes: 15 additions & 15 deletions aya/src/maps/perf/perf_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,21 +282,6 @@ impl Drop for PerfBuffer {
}
}

#[derive(Debug)]
#[repr(C)]
struct Sample {
header: perf_event_header,
size: u32,
}

#[repr(C)]
#[derive(Debug)]
struct LostSamples {
header: perf_event_header,
id: u64,
count: u64,
}

#[cfg(test)]
mod tests {
use std::{fmt::Debug, mem};
Expand All @@ -309,6 +294,13 @@ mod tests {
sys::{override_syscall, Syscall, TEST_MMAP_RET},
};

#[repr(C)]
#[derive(Debug)]
struct Sample {
header: perf_event_header,
size: u32,
}

const PAGE_SIZE: usize = 4096;
union MMappedBuf {
mmap_page: perf_event_mmap_page,
Expand Down Expand Up @@ -375,6 +367,14 @@ mod tests {
};
fake_mmap(&mmapped_buf);

#[repr(C)]
#[derive(Debug)]
struct LostSamples {
header: perf_event_header,
id: u64,
count: u64,
}

let evt = LostSamples {
header: perf_event_header {
type_: PERF_RECORD_LOST as u32,
Expand Down
1 change: 1 addition & 0 deletions aya/src/programs/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub(crate) fn lines(bytes: &[u8]) -> impl Iterator<Item = &OsStr> {

pub(crate) trait OsStringExt {
fn starts_with(&self, needle: &OsStr) -> bool;
#[allow(dead_code)] // Would be odd to have the others without this one.
fn ends_with(&self, needle: &OsStr) -> bool;
fn strip_prefix(&self, prefix: &OsStr) -> Option<&OsStr>;
fn strip_suffix(&self, suffix: &OsStr) -> Option<&OsStr>;
Expand Down