Skip to content

Commit 8e36bdd

Browse files
authored
Merge pull request #35 from saying121/update
Update rust version and fix warnings
2 parents 423ca26 + 06748b0 commit 8e36bdd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+519
-414
lines changed

.github/workflows/build-dev-auto-feature.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
- '*'
77
pull_request_target:
88
types:
9-
- edited
109
- opened
1110
- reopened
1211
- synchronize
@@ -25,18 +24,22 @@ jobs:
2524
- { os: ubuntu-22.04, triple: x86_64-unknown-linux-gnu , alias: amd64-gnu-ubuntu-22.04 }
2625
- { os: ubuntu-22.04, triple: x86_64-unknown-linux-musl, alias: amd64-musl-ubuntu-22.04 }
2726

27+
env:
28+
SCCACHE_GHA_ENABLED: "true"
29+
RUSTC_WRAPPER: "sccache"
30+
2831
steps:
2932
- name: Checkout
30-
uses: actions/checkout@v3
33+
uses: actions/checkout@v4
3134
with:
3235
ref: ${{ github.event.pull_request.head.sha }}
3336

3437
- name: Setup Rust toolchain
35-
uses: actions-rs/toolchain@v1
38+
uses: actions-rs/toolchain@v2
3639
with:
3740
profile: minimal
3841
override: true
39-
toolchain: 1.75.0
42+
toolchain: 1.85
4043
components: rustfmt, clippy
4144

4245
- name: Show environment information
@@ -49,13 +52,13 @@ jobs:
4952
uname -a
5053
cat /usr/include/linux/version.h
5154
52-
- name: Setup Rust cache
53-
uses: Swatinem/rust-cache@v2
55+
- name: Setup build cache
56+
uses: mozilla-actions/[email protected]
5457
with:
55-
prefix-key: ${{ matrix.target.alias }}
58+
version: 'v0.10.0'
5659

5760
- name: Cache APT packages
58-
uses: awalsh128/cache-apt-pkgs-action@v1.3.1
61+
uses: awalsh128/cache-apt-pkgs-action@latest
5962
with:
6063
packages: musl-tools
6164
version: 1.0
@@ -93,4 +96,4 @@ jobs:
9396
target: ${{ matrix.target.triple }}
9497
feature: auto
9598

96-
# TODO: Some tests will fail in GitHub Actions environment
99+
# TODO: Some tests will fail in GitHub Actions environment

.github/workflows/build-dev.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
- '*'
77
pull_request_target:
88
types:
9-
- edited
109
- opened
1110
- reopened
1211
- synchronize
@@ -28,18 +27,22 @@ jobs:
2827
- { pkg: linux-source-6.2.0 , alias: 6.2 , feature: linux-6.0 }
2928
- { pkg: linux-source-6.5.0 , alias: 6.5 , feature: linux-6.3 }
3029

30+
env:
31+
SCCACHE_GHA_ENABLED: "true"
32+
RUSTC_WRAPPER: "sccache"
33+
3134
steps:
3235
- name: Checkout
33-
uses: actions/checkout@v3
36+
uses: actions/checkout@v4
3437
with:
3538
ref: ${{ github.event.pull_request.head.sha }}
3639

3740
- name: Setup Rust toolchain
38-
uses: actions-rs/toolchain@v1
41+
uses: actions-rs/toolchain@v2
3942
with:
4043
profile: minimal
4144
override: true
42-
toolchain: 1.75.0
45+
toolchain: 1.85
4346
components: rustfmt, clippy
4447

4548
- name: Show environment information
@@ -51,13 +54,13 @@ jobs:
5154
rustc -V
5255
uname -a
5356
54-
- name: Setup Rust cache
55-
uses: Swatinem/rust-cache@v2
57+
- name: Setup build cache
58+
uses: mozilla-actions/[email protected]
5659
with:
57-
prefix-key: ${{ matrix.target.alias }}
60+
version: 'v0.10.0'
5861

5962
- name: Cache APT packages
60-
uses: awalsh128/cache-apt-pkgs-action@v1.3.1
63+
uses: awalsh128/cache-apt-pkgs-action@latest
6164
with:
6265
packages: musl-tools ${{ matrix.linux-source.pkg }}
6366
version: 1.0
@@ -105,4 +108,4 @@ jobs:
105108
env:
106109
LINUX_HEADERS_PATH: ${{ github.workspace }}/linux-headers
107110

108-
# TODO: Some tests will fail in GitHub Actions environment
111+
# TODO: Some tests will fail in GitHub Actions environment

build/helpers.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212
// You should have received a copy of the GNU Lesser General Public License along with Perf-event-rs. If not,
1313
// see <https://www.gnu.org/licenses/>.
1414

15-
use crate::consts::IOCTLS;
1615
use std::fs;
1716

17+
use crate::consts::IOCTLS;
18+
1819
/// Parse `LINUX_VERSION_CODE` of `linux/version.h` to (major, patch_level, sub_level)
1920
pub fn parse_linux_version_h(path: &str) -> (usize, usize, usize) {
2021
let first_line = fs::read_to_string(path)

build/main.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ mod helpers;
1717

1818
extern crate bindgen;
1919

20-
use crate::consts::LINUX_FEATURE_VERSIONS;
21-
use crate::helpers::{bindgen, parse_linux_version_h};
22-
use std::env;
23-
use std::path::Path;
20+
use std::{env, path::Path};
21+
22+
use crate::{
23+
consts::LINUX_FEATURE_VERSIONS,
24+
helpers::{bindgen, parse_linux_version_h},
25+
};
2426

2527
fn main() {
2628
// Check target OS

rust-toolchain.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[toolchain]
2+
channel = "1.85"
3+
components = ["rustfmt", "clippy"]
4+
profile = "minimal"

src/infra/box.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
// You should have received a copy of the GNU Lesser General Public License along with Perf-event-rs. If not,
1313
// see <https://www.gnu.org/licenses/>.
1414

15-
use std::alloc::{alloc, Layout};
16-
use std::ptr;
15+
use std::{
16+
alloc::{alloc, Layout},
17+
ptr,
18+
};
1719

1820
pub trait WrapBox<T> {
1921
#[inline]
@@ -36,6 +38,6 @@ impl<T> BoxSliceExt for Box<[T]> {
3638
let layout = Layout::array::<u8>(len).unwrap();
3739
let ptr = unsafe { alloc(layout) };
3840
let slice = ptr::slice_from_raw_parts(ptr, len);
39-
unsafe { Self::from_raw(std::mem::transmute(slice)) }
41+
unsafe { Self::from_raw(std::mem::transmute::<*const [u8], *mut [T]>(slice)) }
4042
}
4143
}

src/infra/vla.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
// You should have received a copy of the GNU Lesser General Public License along with Perf-event-rs. If not,
1313
// see <https://www.gnu.org/licenses/>.
1414

15-
use std::marker::PhantomData;
16-
use std::slice;
15+
use std::{marker::PhantomData, slice};
1716

1817
#[repr(C)]
1918
pub struct Vla<L, T> {
@@ -114,7 +113,7 @@ mod tests {
114113
fn test_vla_u8_u8() {
115114
let buf = [2, 1, 2, 3, 4, 5_u8];
116115
let len_ptr = &buf[0] as *const u8;
117-
let vla: &Vla<u8, u8> = unsafe { &*Vla::from_ptr(len_ptr) };
116+
let vla: &Vla<u8, u8> = unsafe { Vla::from_ptr(len_ptr) };
118117

119118
assert_eq!(vla.as_slice(), &buf[1..3])
120119
}
@@ -126,7 +125,7 @@ mod tests {
126125

127126
let buf = Wrapper([2, 0, 0, 0, 1, 2, 3, 4, 5_u8]);
128127
let len_ptr = &buf.0[0] as *const _ as *const u32;
129-
let vla: &Vla<u32, u8> = unsafe { &*Vla::from_ptr(len_ptr) };
128+
let vla: &Vla<u32, u8> = unsafe { Vla::from_ptr(len_ptr) };
130129

131130
assert_eq!(vla.as_slice(), &buf.0[4..6])
132131
}

src/infra/zt.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@
1212
// You should have received a copy of the GNU Lesser General Public License along with Perf-event-rs. If not,
1313
// see <https://www.gnu.org/licenses/>.
1414

15+
use std::{marker::PhantomData, mem::size_of, ops::Not, slice};
16+
1517
use crate::infra::SizedExt;
16-
use std::marker::PhantomData;
17-
use std::mem::size_of;
18-
use std::ops::Not;
19-
use std::slice;
2018

2119
#[repr(C)]
2220
pub struct ZeroTerminated<T> {

src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
// see <https://www.gnu.org/licenses/>.
1414

1515
#![cfg(target_os = "linux")]
16-
#![deny(warnings)]
17-
#![warn(clippy::all, clippy::nursery, clippy::cargo_common_metadata)]
1816

1917
mod infra;
2018
mod perf_event;

src/perf_event/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// see <https://www.gnu.org/licenses/>.
1414

1515
use std::{io, result};
16+
1617
use thiserror::Error;
1718

1819
#[derive(Error, Debug)]

0 commit comments

Comments
 (0)