Skip to content

Commit

Permalink
Narrow clippy allowances
Browse files Browse the repository at this point in the history
  • Loading branch information
tamird committed Dec 27, 2024
1 parent c6487da commit 9ec2d31
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions aya-log-parser/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// We implement our own formatter here and we pass literal strings on purpose.
#![allow(clippy::literal_string_with_formatting_args)]

use std::str;

use aya_log_common::DisplayHint;
Expand Down Expand Up @@ -133,6 +130,9 @@ pub fn parse(format_string: &str) -> Result<Vec<Fragment>, String> {
mod test {
use super::*;

// TODO(https://github.com/rust-lang/rust-clippy/issues/13885): narrow this to just the specific
// strings when that doesn't trip the lint.
#[allow(clippy::literal_string_with_formatting_args)]
#[test]
fn test_parse() {
assert_eq!(
Expand Down
12 changes: 7 additions & 5 deletions aya/src/sys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ fn syscall(call: Syscall<'_>) -> SysResult<i64> {
#[cfg(test)]
return TEST_SYSCALL.with(|test_impl| unsafe { test_impl.borrow()(call) });

// The type of integer taken by `ioctl` is different in glibc (i64) and
// musl (i32). musl builds would complain about useless conversion.
// `libc::ioctl` returns i32 on x86_64 while `libc::syscall` returns i64.
#[allow(clippy::useless_conversion)]
#[cfg_attr(test, allow(unreachable_code))]
{
let ret = unsafe {
Expand All @@ -112,7 +108,13 @@ fn syscall(call: Syscall<'_>) -> SysResult<i64> {
flags,
} => libc::syscall(SYS_perf_event_open, &attr, pid, cpu, group, flags),
Syscall::PerfEventIoctl { fd, request, arg } => {
let ret = libc::ioctl(fd.as_raw_fd(), request.try_into().unwrap(), arg);
// The type of integer taken by `ioctl` is different in glibc (i64) and
// musl (i32). musl builds would complain about useless conversion.
#[allow(clippy::useless_conversion)]
let request = request.try_into().unwrap();
let ret = libc::ioctl(fd.as_raw_fd(), request, arg);
// `libc::ioctl` returns i32 on x86_64 while `libc::syscall` returns i64.
#[allow(clippy::useless_conversion)]
ret.into()
}
}
Expand Down

0 comments on commit 9ec2d31

Please sign in to comment.