strerror(3): changed panic to 0

This commit is contained in:
Emma Tebibyte 2024-03-18 20:45:53 -06:00
parent b2d56bbc9a
commit b356ac522f
Signed by: emma
GPG Key ID: 06FA419A1698C270

View File

@ -15,7 +15,7 @@ extern "C" { fn strerror(errnum: c_int) -> *mut c_char; }
/* wrapper function for use in Rust */ /* wrapper function for use in Rust */
pub fn raw_message(err: std::io::Error) -> String { pub fn raw_message(err: std::io::Error) -> String {
/* Get the raw OS error. If its None, what the hell is going on‽ */ /* Get the raw OS error. If its None, what the hell is going on‽ */
let errno = err.raw_os_error().unwrap() as c_int; let errno = err.raw_os_error().unwrap_or(0) as c_int;
/* Get a CStr from the error message so that its referenced and then /* Get a CStr from the error message so that its referenced and then
* convert it to an owned value. If the string is not valid UTF-8, return * convert it to an owned value. If the string is not valid UTF-8, return