Skip to content
Closed
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
4 changes: 2 additions & 2 deletions .github/workflows/cargo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
shell: bash
continue-on-error: true

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: clippy-sarif
path: clippy.sarif
Expand All @@ -65,7 +65,7 @@ jobs:
security-events: write
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
name: clippy-sarif
- uses: github/codeql-action/upload-sarif@v2
Expand Down
3 changes: 1 addition & 2 deletions perf-event/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,7 @@ impl<'a> Builder<'a> {
pub fn build_group(&self) -> io::Result<Group> {
let read_format = ReadFormat::from_bits_retain(self.attrs.read_format);
if !read_format.contains(ReadFormat::GROUP) {
return Err(io::Error::new(
ErrorKind::Other,
return Err(io::Error::other(
"groups must be created with the GROUP flag enabled",
));
}
Expand Down
4 changes: 2 additions & 2 deletions perf-event/src/events/dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ impl std::error::Error for MissingParameterError {}

impl From<DynamicBuilderError> for io::Error {
fn from(value: DynamicBuilderError) -> Self {
io::Error::new(io::ErrorKind::Other, value)
io::Error::other(value)
}
}

Expand All @@ -677,7 +677,7 @@ impl From<MissingParameterError> for DynamicBuilderError {

impl From<MissingParameterError> for io::Error {
fn from(value: MissingParameterError) -> Self {
io::Error::new(io::ErrorKind::Other, value)
io::Error::other(value)
}
}

Expand Down
4 changes: 1 addition & 3 deletions perf-event/src/events/tracepoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ impl Tracepoint {
let id = std::fs::read_to_string(&path)?
.trim_end()
.parse()
.map_err(move |e| {
io::Error::new(io::ErrorKind::Other, UnparseableIdFile::new(path, e))
})?;
.map_err(move |e| io::Error::other(UnparseableIdFile::new(path, e)))?;

Ok(Self::with_id(id))
}
Expand Down
11 changes: 4 additions & 7 deletions perf-event/src/events/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,10 @@ impl CachedPmuType {
.trim_end()
.parse()
.map_err(|e| {
io::Error::new(
io::ErrorKind::Other,
ParsePmuTypeError {
name: self.name,
error: e,
},
)
io::Error::other(ParsePmuTypeError {
name: self.name,
error: e,
})
})?;

self.value.store(ty, Ordering::Relaxed);
Expand Down
4 changes: 2 additions & 2 deletions perf-event/src/group_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ impl GroupData {
/// }
/// # std::io::Result::Ok(())
/// ```
pub fn iter(&self) -> GroupIter {
pub fn iter(&self) -> GroupIter<'_> {
let mut iter = self.iter_with_group();
if self.should_skip {
let _ = iter.next();
}
iter
}

fn iter_with_group(&self) -> GroupIter {
fn iter_with_group(&self) -> GroupIter<'_> {
GroupIter(self.data.entries())
}

Expand Down
20 changes: 4 additions & 16 deletions perf-event/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,21 +633,11 @@ impl Counter {
count: data.count(),
time_enabled: data
.time_enabled()
.ok_or_else(|| {
io::Error::new(
io::ErrorKind::Other,
"time_enabled was not enabled within read_format",
)
})?
.ok_or_else(|| io::Error::other("time_enabled was not enabled within read_format"))?
.as_nanos() as _,
time_running: data
.time_running()
.ok_or_else(|| {
io::Error::new(
io::ErrorKind::Other,
"time_running was not enabled within read_format",
)
})?
.ok_or_else(|| io::Error::other("time_running was not enabled within read_format"))?
.as_nanos() as _,
})
}
Expand Down Expand Up @@ -676,9 +666,7 @@ impl Counter {
}

let mut parser = crate::data::parse::Parser::new(&data[..len], self.config.clone());
let value: crate::data::ReadValue = parser
.parse()
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
let value: crate::data::ReadValue = parser.parse().map_err(io::Error::other)?;

Ok(CounterData(value))
}
Expand Down Expand Up @@ -741,7 +729,7 @@ impl Counter {
let mut parser = crate::data::parse::Parser::new(data.as_slice(), self.config.clone());
let data: ReadGroup = parser
.parse::<ReadGroup>()
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?
.map_err(io::Error::other)?
.into_owned();

let data = GroupData::new(data);
Expand Down
8 changes: 4 additions & 4 deletions perf-event/src/sampler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl Sampler {
///
/// [`next_blocking`]: Self::next_blocking
/// [man]: https://www.mankier.com/2/perf_event_open
pub fn next_record(&mut self) -> Option<Record> {
pub fn next_record(&mut self) -> Option<Record<'_>> {
use std::{mem, ptr, slice};

let page = self.page();
Expand Down Expand Up @@ -163,7 +163,7 @@ impl Sampler {
/// `libc::poll`. There are only two cases where this can happen:
/// - the current process has run out of file descriptors, or,
/// - the kernel couldn't allocate memory for internal poll datastructures.
pub fn next_blocking(&mut self, timeout: Option<Duration>) -> Option<Record> {
pub fn next_blocking(&mut self, timeout: Option<Duration>) -> Option<Record<'_>> {
let deadline = timeout.map(|timeout| Instant::now() + timeout);

loop {
Expand Down Expand Up @@ -587,7 +587,7 @@ impl<'s> Record<'s> {
///
/// For most records this is effectively free but if the record wraps
/// around the end of the ringbuffer then it will be copied to a vector.
pub fn to_contiguous(&self) -> Cow<[u8]> {
pub fn to_contiguous(&self) -> Cow<'_, [u8]> {
match self.data {
ByteBuffer::Single(data) => Cow::Borrowed(data),
ByteBuffer::Split([a, b]) => {
Expand All @@ -600,7 +600,7 @@ impl<'s> Record<'s> {
}

/// Parse the data in this record to a [`data::Record`] enum.
pub fn parse_record(&self) -> ParseResult<data::Record> {
pub fn parse_record(&self) -> ParseResult<data::Record<'_>> {
let mut parser = Parser::new(self.data, self.sampler.config().clone());
data::Record::parse_with_header(&mut parser, self.header)
}
Expand Down
Loading