Merge branch 'casting-ascii' into 'master'
avoid as casting ascii bytes to c_char See merge request redox-os/relibc!1457
This commit is contained in:
@@ -17,6 +17,7 @@ use core::{
|
||||
};
|
||||
|
||||
use crate::{
|
||||
byte_literal::ByteLiteral,
|
||||
c_str::{CStr, Thin},
|
||||
c_vec::CVec,
|
||||
error::{ResultExt, ResultExtPtrMut},
|
||||
@@ -551,9 +552,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 != b'r' as c_char
|
||||
&& initial_mode != b'w' as c_char
|
||||
&& initial_mode != b'a' as c_char
|
||||
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();
|
||||
@@ -1289,7 +1290,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) = b'/' as _ };
|
||||
unsafe { *out_buf.add(dirname_len) = ByteLiteral::cast_cchar(b'/') };
|
||||
unsafe {
|
||||
out_buf
|
||||
.add(dirname_len + 1)
|
||||
@@ -1348,7 +1349,7 @@ pub unsafe extern "C" fn tmpnam(s: *mut c_char) -> *mut c_char {
|
||||
s
|
||||
};
|
||||
|
||||
unsafe { *buf = b'/' as _ };
|
||||
unsafe { *buf = ByteLiteral::cast_cchar(b'/') };
|
||||
unsafe {
|
||||
#[allow(deprecated)]
|
||||
tmpnam_inner(buf, 1)
|
||||
|
||||
Reference in New Issue
Block a user