From f65db271b331d997e9b9a9a0153d9ee3569b48be Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Thu, 5 Nov 2026 15:14:17 +0000 Subject: [PATCH 1/2] Write the errno description without Rust's suffix in refcount strerror_r --- rules/cstring/tgt_refcount.rs | 4 ++-- tests/unit/string_h.c | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/rules/cstring/tgt_refcount.rs b/rules/cstring/tgt_refcount.rs index 1d26cc54d9..4d3e81793e 100644 --- a/rules/cstring/tgt_refcount.rs +++ b/rules/cstring/tgt_refcount.rs @@ -181,7 +181,7 @@ fn f27(a0: Ptr, a1: Ptr) -> i32 { #[cfg(target_os = "linux")] fn f28(a0: i32, a1: Ptr, a2: usize) -> Ptr { - let __msg = std::io::Error::from_raw_os_error(a0).to_string(); + let __msg = nix::errno::Errno::from_raw(a0).desc(); let __len = __msg.len().min(a2.saturating_sub(1)); let mut __p = a1.clone(); for __i in 0..__len { @@ -196,7 +196,7 @@ fn f28(a0: i32, a1: Ptr, a2: usize) -> Ptr { #[cfg(target_os = "macos")] fn f28(a0: i32, a1: Ptr, a2: usize) -> i32 { - let __msg = std::io::Error::from_raw_os_error(a0).to_string(); + let __msg = nix::errno::Errno::from_raw(a0).desc(); let __len = __msg.len().min(a2.saturating_sub(1)); let mut __p = a1.clone(); for __i in 0..__len { diff --git a/tests/unit/string_h.c b/tests/unit/string_h.c index 53bd062f76..169b264237 100644 --- a/tests/unit/string_h.c +++ b/tests/unit/string_h.c @@ -1,6 +1,7 @@ #undef _GNU_SOURCE #define _GNU_SOURCE #include +#include #include #include @@ -153,6 +154,17 @@ static void test_strcasecmp(void) { assert(strcasecmp(p, q) == 0); } +static void test_strerror_r(void) { + char buf[64]; +#if defined(__linux__) + const char *msg = strerror_r(ENOENT, buf, sizeof buf); +#else + assert(strerror_r(ENOENT, buf, sizeof buf) == 0); + const char *msg = buf; +#endif + assert(strcmp(msg, "No such file or directory") == 0); +} + int main(void) { test_memcpy(); test_memset(); @@ -169,5 +181,6 @@ int main(void) { test_strstr(); test_strpbrk(); test_strcasecmp(); + test_strerror_r(); return 0; } From 2398f3fce30d4ccce5c754f712a63b9982f79ea4 Mon Sep 17 00:00:00 2001 From: Lucian Popescu Date: Thu, 5 Nov 2026 15:40:06 +0000 Subject: [PATCH 2/2] Delete platform specific testg --- tests/unit/string_h.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/tests/unit/string_h.c b/tests/unit/string_h.c index 169b264237..53bd062f76 100644 --- a/tests/unit/string_h.c +++ b/tests/unit/string_h.c @@ -1,7 +1,6 @@ #undef _GNU_SOURCE #define _GNU_SOURCE #include -#include #include #include @@ -154,17 +153,6 @@ static void test_strcasecmp(void) { assert(strcasecmp(p, q) == 0); } -static void test_strerror_r(void) { - char buf[64]; -#if defined(__linux__) - const char *msg = strerror_r(ENOENT, buf, sizeof buf); -#else - assert(strerror_r(ENOENT, buf, sizeof buf) == 0); - const char *msg = buf; -#endif - assert(strcmp(msg, "No such file or directory") == 0); -} - int main(void) { test_memcpy(); test_memset(); @@ -181,6 +169,5 @@ int main(void) { test_strstr(); test_strpbrk(); test_strcasecmp(); - test_strerror_r(); return 0; }