diff --git a/src/header/stdio/mod.rs b/src/header/stdio/mod.rs index dfae1cc9c2..90987779aa 100644 --- a/src/header/stdio/mod.rs +++ b/src/header/stdio/mod.rs @@ -327,10 +327,10 @@ pub unsafe extern "C" fn cuserid(s: *mut c_char) -> *mut c_char { unsafe { pwd::getpwuid_r( unistd::geteuid(), - &mut pwd, + &raw mut pwd, buf.as_mut_ptr(), buf.len(), - &mut pwdbuf, + &raw mut pwdbuf, ) }; if pwdbuf.is_null() { @@ -438,7 +438,7 @@ pub unsafe extern "C" fn fgetc(stream: *mut FILE) -> c_int { return -1; } - unsafe { getc_unlocked(&mut *stream) } + unsafe { getc_unlocked(&raw mut *stream) } } /// See . @@ -611,7 +611,7 @@ pub unsafe extern "C" fn fputc(c: c_int, stream: *mut FILE) -> c_int { return -1; } - unsafe { putc_unlocked(c, &mut *stream) } + unsafe { putc_unlocked(c, &raw mut *stream) } } /// See . @@ -853,7 +853,7 @@ pub unsafe extern "C" fn fwrite( #[unsafe(no_mangle)] pub unsafe extern "C" fn getc(stream: *mut FILE) -> c_int { let mut stream = unsafe { (*stream).lock() }; - unsafe { getc_unlocked(&mut *stream) } + unsafe { getc_unlocked(&raw mut *stream) } } /// See . @@ -861,7 +861,7 @@ pub unsafe extern "C" fn getc(stream: *mut FILE) -> c_int { /// Get a single char from `stdin` #[unsafe(no_mangle)] pub unsafe extern "C" fn getchar() -> c_int { - unsafe { fgetc(&mut *stdin) } + unsafe { fgetc(&raw mut *stdin) } } /// See . @@ -886,7 +886,7 @@ pub unsafe extern "C" fn getc_unlocked(stream: *mut FILE) -> c_int { /// Get a char from `stdin` without locking `stdin` #[unsafe(no_mangle)] pub unsafe extern "C" fn getchar_unlocked() -> c_int { - unsafe { getc_unlocked(&mut *stdin) } + unsafe { getc_unlocked(&raw mut *stdin) } } /// See . @@ -897,7 +897,7 @@ pub unsafe extern "C" fn getchar_unlocked() -> c_int { /// Get a string from `stdin` #[unsafe(no_mangle)] pub unsafe extern "C" fn gets(s: *mut c_char) -> *mut c_char { - unsafe { fgets(s, c_int::MAX, &mut *stdin) } + unsafe { fgets(s, c_int::MAX, &raw mut *stdin) } } /// See . @@ -1066,7 +1066,7 @@ pub unsafe extern "C" fn popen(command: *const c_char, mode: *const c_char) -> * #[unsafe(no_mangle)] pub unsafe extern "C" fn putc(c: c_int, stream: *mut FILE) -> c_int { let mut stream = unsafe { (*stream).lock() }; - unsafe { putc_unlocked(c, &mut *stream) } + unsafe { putc_unlocked(c, &raw mut *stream) } } /// See . @@ -1074,7 +1074,7 @@ pub unsafe extern "C" fn putc(c: c_int, stream: *mut FILE) -> c_int { /// Put a character `c` into `stdout` #[unsafe(no_mangle)] pub unsafe extern "C" fn putchar(c: c_int) -> c_int { - unsafe { fputc(c, &mut *stdout) } + unsafe { fputc(c, &raw mut *stdout) } } /// See . @@ -1419,13 +1419,13 @@ pub unsafe extern "C" fn dprintf(fd: c_int, format: *const c_char, mut __valist: /// See . #[unsafe(no_mangle)] pub unsafe extern "C" fn vprintf(format: *const c_char, ap: va_list) -> c_int { - unsafe { vfprintf(&mut *stdout, format, ap) } + unsafe { vfprintf(&raw mut *stdout, format, ap) } } /// See . #[unsafe(no_mangle)] pub unsafe extern "C" fn printf(format: *const c_char, mut __valist: ...) -> c_int { - unsafe { vfprintf(&mut *stdout, format, __valist.as_va_list()) } + unsafe { vfprintf(&raw mut *stdout, format, __valist.as_va_list()) } } /// See . @@ -1541,13 +1541,13 @@ pub unsafe extern "C" fn fscanf( /// See . #[unsafe(no_mangle)] pub unsafe extern "C" fn vscanf(format: *const c_char, ap: va_list) -> c_int { - unsafe { vfscanf(&mut *stdin, format, ap) } + unsafe { vfscanf(&raw mut *stdin, format, ap) } } /// See . #[unsafe(no_mangle)] pub unsafe extern "C" fn scanf(format: *const c_char, mut __valist: ...) -> c_int { - unsafe { vfscanf(&mut *stdin, format, __valist.as_va_list()) } + unsafe { vfscanf(&raw mut *stdin, format, __valist.as_va_list()) } } /// See . diff --git a/src/header/stdlib/mod.rs b/src/header/stdlib/mod.rs index 93e10a572c..478c142e56 100644 --- a/src/header/stdlib/mod.rs +++ b/src/header/stdlib/mod.rs @@ -187,7 +187,7 @@ macro_rules! dec_num_from_ascii { ($s:expr, $t:ty) => {{ let mut s = $s; // Iterate past whitespace - while ctype::isspace(unsafe { *s } as c_int) != 0 { + while ctype::isspace(c_int::from(unsafe { *s })) != 0 { s = unsafe { s.offset(1) }; } @@ -206,7 +206,7 @@ macro_rules! dec_num_from_ascii { }; let mut n: $t = 0; - while ctype::isdigit(unsafe { *s } as c_int) != 0 { + while ctype::isdigit(c_int::from(unsafe { *s })) != 0 { n = 10 * n - (unsafe { *s } as $t - 0x30); s = unsafe { s.offset(1) }; } @@ -368,7 +368,7 @@ pub unsafe extern "C" fn exit(status: c_int) -> ! { // Look for the neighbor functions in memory until the end let mut f = unsafe { &__fini_array_end } as *const _; #[allow(clippy::op_ref)] - while f > unsafe { &__fini_array_start } { + while f > &raw const __fini_array_start { f = unsafe { f.offset(-1) }; (unsafe { *f })(); } @@ -719,7 +719,7 @@ pub unsafe extern "C" fn memalign(alignment: size_t, size: size_t) -> *mut c_voi pub unsafe extern "C" fn mblen(s: *const c_char, n: size_t) -> c_int { let mut wc: wchar_t = 0; let mut state: mbstate_t = mbstate_t {}; - let result: usize = unsafe { mbrtowc(&mut wc, s, n, &mut state) }; + let result: usize = unsafe { mbrtowc(&raw mut wc, s, n, &raw mut state) }; if result == -1isize as usize { return -1; @@ -735,14 +735,14 @@ pub unsafe extern "C" fn mblen(s: *const c_char, n: size_t) -> c_int { #[unsafe(no_mangle)] pub unsafe extern "C" fn mbstowcs(pwcs: *mut wchar_t, mut s: *const c_char, n: size_t) -> size_t { let mut state: mbstate_t = mbstate_t {}; - unsafe { mbsrtowcs(pwcs, &mut s, n, &mut state) } + unsafe { mbsrtowcs(pwcs, &raw mut s, n, &raw mut state) } } /// See . #[unsafe(no_mangle)] pub unsafe extern "C" fn mbtowc(pwc: *mut wchar_t, s: *const c_char, n: size_t) -> c_int { let mut state: mbstate_t = mbstate_t {}; - (unsafe { mbrtowc(pwc, s, n, &mut state) }) as c_int + (unsafe { mbrtowc(pwc, s, n, &raw mut state) }) as c_int } fn inner_mktemp(name: *mut c_char, suffix_len: c_int, mut attempt: F) -> Option @@ -1682,14 +1682,14 @@ pub unsafe extern "C" fn valloc(size: size_t) -> *mut c_void { #[unsafe(no_mangle)] pub unsafe extern "C" fn wcstombs(s: *mut c_char, mut pwcs: *const wchar_t, n: size_t) -> size_t { let mut state: mbstate_t = mbstate_t {}; - unsafe { wcsrtombs(s, &mut pwcs, n, &mut state) } + unsafe { wcsrtombs(s, &raw mut pwcs, n, &raw mut state) } } /// See . #[unsafe(no_mangle)] pub unsafe extern "C" fn wctomb(s: *mut c_char, wc: wchar_t) -> c_int { let mut state: mbstate_t = mbstate_t {}; - let result: usize = unsafe { wcrtomb(s, wc, &mut state) }; + let result: usize = unsafe { wcrtomb(s, wc, &raw mut state) }; if result == -1isize as usize { return -1; diff --git a/src/macros.rs b/src/macros.rs index ba546ebcd8..d6c8663180 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -227,7 +227,7 @@ macro_rules! strto_float_impl { let mut s = $s; let endptr = $endptr; - while ctype::isspace(unsafe{*s} as c_int) != 0 { + while ctype::isspace(c_int::from(unsafe{*s})) != 0 { s = unsafe{ s.offset(1)}; }