add descriptions and pick a better function name

This commit is contained in:
auronandace
2026-06-12 11:13:06 +01:00
parent 0dc5247ff6
commit ecb081d8bd
6 changed files with 48 additions and 38 deletions
+5 -5
View File
@@ -554,9 +554,9 @@ pub unsafe extern "C" fn flockfile(file: *mut FILE) {
#[unsafe(no_mangle)]
pub unsafe extern "C" fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FILE {
let initial_mode = unsafe { *mode };
if initial_mode != ByteLiteral::cast_unchecked(b'r')
&& initial_mode != ByteLiteral::cast_unchecked(b'w')
&& initial_mode != ByteLiteral::cast_unchecked(b'a')
if initial_mode != ByteLiteral::cast_cchar(b'r')
&& initial_mode != ByteLiteral::cast_cchar(b'w')
&& initial_mode != ByteLiteral::cast_cchar(b'a')
{
platform::ERRNO.set(errno::EINVAL);
return ptr::null_mut();
@@ -1292,7 +1292,7 @@ pub unsafe extern "C" fn tempnam(dir: *const c_char, pfx: *const c_char) -> *mut
if !out_buf.is_null() {
// copy the directory name and prefix into the allocated buffer
unsafe { out_buf.copy_from_nonoverlapping(dirname, dirname_len) };
unsafe { *out_buf.add(dirname_len) = ByteLiteral::cast_unchecked(b'/') };
unsafe { *out_buf.add(dirname_len) = ByteLiteral::cast_cchar(b'/') };
unsafe {
out_buf
.add(dirname_len + 1)
@@ -1351,7 +1351,7 @@ pub unsafe extern "C" fn tmpnam(s: *mut c_char) -> *mut c_char {
s
};
unsafe { *buf = ByteLiteral::cast_unchecked(b'/') };
unsafe { *buf = ByteLiteral::cast_cchar(b'/') };
unsafe {
#[allow(deprecated)]
tmpnam_inner(buf, 1)