Skip to content

Commit 71d6c9e

Browse files
committed
Change the range syntax that is giving ctest problems
`ctest` is iffy about whether or not it accepts `..=` syntax, and I can't figure out what makes it decide whether or not to accept it and sometimes random changes seem to make things fail, so just replace the syntax. This is simpler anyway, and closer matches the upstream definition [1]. Link: https://github.com/torvalds/linux/blob/80e54e84911a923c40d7bee33a34c1b4be148d7a/Makefile#L1316 [1]
1 parent 3914f82 commit 71d6c9e

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
//! Compare libc's KERNEL_VERSION macro against a specific kernel version.
22
3-
#[cfg(
4-
target_os = "linux",
5-
)]
3+
#[cfg(target_os = "linux")]
64
mod t {
75
use libc;
86

97
#[test]
108
fn test_kernel_version() {
11-
unsafe {
12-
assert_eq!(libc::KERNEL_VERSION(6, 0, 0), 393216);
13-
}
9+
assert_eq!(unsafe { libc::KERNEL_VERSION(6, 0, 0) }, 393216);
10+
// Check that patch level saturates
11+
assert_eq!(unsafe { libc::KERNEL_VERSION(6, 0, 255) }, 393471);
12+
assert_eq!(unsafe { libc::KERNEL_VERSION(6, 0, 300) }, 393471);
1413
}
1514
}

src/unix/linux_like/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1755,11 +1755,7 @@ safe_f! {
17551755

17561756
#[allow(ellipsis_inclusive_range_patterns)]
17571757
pub {const} fn KERNEL_VERSION(a: u32, b: u32, c: u32) -> u32 {
1758-
((a << 16) + (b << 8))
1759-
+ match c {
1760-
0..=255 => c,
1761-
_ => 255,
1762-
}
1758+
((a << 16) + (b << 8)) + if c > 255 { 255 } else { c }
17631759
}
17641760
}
17651761

0 commit comments

Comments
 (0)