From 79a7f085187e77828d764c2d30e8a43c9ec94df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20M=C3=BCller?= Date: Wed, 22 Jan 2025 15:21:20 -0800 Subject: [PATCH] Bump minimum supported Rust version to 1.78 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bump the minimum supported Rust version to 1.78. This version will be required to use newer versions of cargo_metadata. Signed-off-by: Daniel Müller --- .github/workflows/test.yml | 2 +- Cargo.toml | 2 +- libbpf-cargo/CHANGELOG.md | 1 + libbpf-cargo/README.md | 2 +- libbpf-rs/README.md | 2 +- libbpf-rs/src/util.rs | 12 +++--------- 6 files changed, 8 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 81973c43..b4386b2e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -132,7 +132,7 @@ jobs: with: # Please adjust README and rust-version field in Cargo.toml files when # bumping version. - toolchain: 1.71.0 + toolchain: 1.78.0 components: rustfmt - uses: Swatinem/rust-cache@v2 - name: Build diff --git a/Cargo.toml b/Cargo.toml index 4125622d..7422c09f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [workspace.package] version = "0.25.0-beta.1" edition = "2021" -rust-version = "1.71" +rust-version = "1.78" license = "LGPL-2.1-only OR BSD-2-Clause" repository = "https://github.com/libbpf/libbpf-rs" homepage = "https://github.com/libbpf/libbpf-rs" diff --git a/libbpf-cargo/CHANGELOG.md b/libbpf-cargo/CHANGELOG.md index 8242a63e..8f10a8f5 100644 --- a/libbpf-cargo/CHANGELOG.md +++ b/libbpf-cargo/CHANGELOG.md @@ -9,6 +9,7 @@ Unreleased - Removed `--quiet` option of `libbpf make` sub-command - Fixed handling of multiple types of same name in BTF by enumerating them in the generated skeleton +- Bumped minimum Rust version to `1.78` 0.25.0-beta.1 diff --git a/libbpf-cargo/README.md b/libbpf-cargo/README.md index f3947e29..e5530733 100644 --- a/libbpf-cargo/README.md +++ b/libbpf-cargo/README.md @@ -1,5 +1,5 @@ [![CI](https://github.com/libbpf/libbpf-rs/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/libbpf/libbpf-rs/actions/workflows/test.yml) -[![rustc](https://img.shields.io/badge/rustc-1.71+-blue.svg)](https://blog.rust-lang.org/2023/07/13/Rust-1.71.0.html) +[![rustc](https://img.shields.io/badge/rustc-1.78+-blue.svg)](https://blog.rust-lang.org/2024/05/02/Rust-1.78.0.html) # libbpf-cargo diff --git a/libbpf-rs/README.md b/libbpf-rs/README.md index c79e4bf6..78391047 100644 --- a/libbpf-rs/README.md +++ b/libbpf-rs/README.md @@ -1,5 +1,5 @@ [![CI](https://github.com/libbpf/libbpf-rs/actions/workflows/test.yml/badge.svg?branch=master)](https://github.com/libbpf/libbpf-rs/actions/workflows/test.yml) -[![rustc](https://img.shields.io/badge/rustc-1.71+-blue.svg)](https://blog.rust-lang.org/2023/07/13/Rust-1.71.0.html) +[![rustc](https://img.shields.io/badge/rustc-1.78+-blue.svg)](https://blog.rust-lang.org/2024/05/02/Rust-1.78.0.html) # libbpf-rs diff --git a/libbpf-rs/src/util.rs b/libbpf-rs/src/util.rs index d5b8ea19..8debd52e 100644 --- a/libbpf-rs/src/util.rs +++ b/libbpf-rs/src/util.rs @@ -56,7 +56,7 @@ pub fn c_char_slice_to_cstr(s: &[c_char]) -> Option<&CStr> { /// Round up a number to the next multiple of `r` pub fn roundup(num: usize, r: usize) -> usize { - ((num + (r - 1)) / r) * r + num.div_ceil(r) * r } /// Get the number of CPUs in the system, e.g., to interact with per-cpu maps. @@ -194,16 +194,10 @@ mod tests { assert_eq!(c_char_slice_to_cstr(&slice), None); let slice = [0]; - assert_eq!( - c_char_slice_to_cstr(&slice).unwrap(), - CStr::from_bytes_with_nul(b"\0").unwrap() - ); + assert_eq!(c_char_slice_to_cstr(&slice).unwrap(), c""); let slice = ['a' as _, 'b' as _, 'c' as _, 0 as _]; - assert_eq!( - c_char_slice_to_cstr(&slice).unwrap(), - CStr::from_bytes_with_nul(b"abc\0").unwrap() - ); + assert_eq!(c_char_slice_to_cstr(&slice).unwrap(), c"abc"); // Missing terminating NUL byte. let slice = ['a' as _, 'b' as _, 'c' as _];