From add8e2e1a3a0b3257942c013ba98c8a8941ee7f5 Mon Sep 17 00:00:00 2001 From: hulxv Date: Wed, 17 Dec 2025 22:58:15 +0200 Subject: [PATCH] Replace assertions with errno_check for libc::strerror_r calls --- tests/pass-dep/libc/libc-strerror_r.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/pass-dep/libc/libc-strerror_r.rs b/tests/pass-dep/libc/libc-strerror_r.rs index 09885ce839..682125694a 100644 --- a/tests/pass-dep/libc/libc-strerror_r.rs +++ b/tests/pass-dep/libc/libc-strerror_r.rs @@ -1,11 +1,15 @@ //@ignore-target: windows # Supported only on unixes +#[path = "../../utils/libc.rs"] +mod libc_utils; +use libc_utils::errno_check; + fn main() { unsafe { let mut buf = vec![0u8; 32]; - assert_eq!(libc::strerror_r(libc::EPERM, buf.as_mut_ptr().cast(), buf.len()), 0); + errno_check(libc::strerror_r(libc::EPERM, buf.as_mut_ptr().cast(), buf.len())); let mut buf2 = vec![0u8; 64]; - assert_eq!(libc::strerror_r(-1i32, buf2.as_mut_ptr().cast(), buf2.len()), 0); + errno_check(libc::strerror_r(-1i32, buf2.as_mut_ptr().cast(), buf2.len())); // This buffer is deliberately too small so this triggers ERANGE. let mut buf3 = vec![0u8; 2]; assert_eq!(