Merge branch 'several-lints' into 'master'
remove pthread_atfork from unistd and tackle some lints See merge request redox-os/relibc!1004
This commit is contained in:
@@ -30,6 +30,7 @@ zero_ptr = "warn" # must allow on public constants due to cbindgen issue
|
||||
|
||||
[workspace.lints.rust]
|
||||
dangling_pointers_from_temporaries = "deny"
|
||||
internal_features = "allow" # core_intrinsics and lang_items
|
||||
irrefutable_let_patterns = "deny"
|
||||
mismatched_lifetime_syntaxes = "deny"
|
||||
non_camel_case_types = "allow"
|
||||
|
||||
@@ -166,7 +166,7 @@ pub unsafe extern "C" fn duplocale(loc: locale_t) -> locale_t {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_locale_file(name: &str) -> Result<Box<LocaleData>, Errno> {
|
||||
pub(crate) fn load_locale_file(name: &str) -> Result<Box<LocaleData>, Errno> {
|
||||
let mut path = String::from("/usr/share/i18n/locales/");
|
||||
path.push_str(name);
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ use super::{
|
||||
|
||||
pub(super) static LOGGER: Mutex<LogParams<LogFile>> = Mutex::new(LogParams::new(None));
|
||||
|
||||
pub struct LogParams<L: LogSink> {
|
||||
pub(super) struct LogParams<L: LogSink> {
|
||||
/// Identity prepended to each log message. POSIX does not specific what to do when it's empty,
|
||||
/// but the program name is a common default.
|
||||
ident: String,
|
||||
|
||||
@@ -15,7 +15,7 @@ pub const UTSLENGTH: usize = 65;
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_utsname.h.html>.
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Copy, Debug, OutProject)]
|
||||
#[derive(Clone, Debug, OutProject)]
|
||||
pub struct utsname {
|
||||
pub sysname: [c_char; UTSLENGTH],
|
||||
pub nodename: [c_char; UTSLENGTH],
|
||||
|
||||
@@ -115,17 +115,6 @@ pub const _CS_POSIX_V7_LPBIG_OFFBIG_LDFLAGS: c_int = 1145;
|
||||
pub const _CS_POSIX_V7_LPBIG_OFFBIG_LIBS: c_int = 1146;
|
||||
pub const _CS_POSIX_V7_LPBIG_OFFBIG_LINTFLAGS: c_int = 1147;
|
||||
|
||||
// Re-exported from pthread.h. `pthread_atfork` should be in pthread.h according to the
|
||||
// standard, but glibc exports it here as well. We ONLY exported it in unistd.h till recently.
|
||||
unsafe extern "C" {
|
||||
#[unsafe(no_mangle)]
|
||||
pub fn pthread_atfork(
|
||||
prepare: Option<extern "C" fn()>,
|
||||
parent: Option<extern "C" fn()>,
|
||||
child: Option<extern "C" fn()>,
|
||||
) -> c_int;
|
||||
}
|
||||
|
||||
/// See <https://pubs.opengroup.org/onlinepubs/9799919799/functions/fork.html>.
|
||||
#[unsafe(no_mangle)]
|
||||
pub unsafe extern "C" fn _Fork() -> pid_t {
|
||||
@@ -583,7 +572,6 @@ pub unsafe extern "C" fn gethostname(mut name: *mut c_char, mut len: size_t) ->
|
||||
.map(|()| 0)
|
||||
.or_minus_one_errno();
|
||||
if err < 0 {
|
||||
mem::forget(uts);
|
||||
return err;
|
||||
}
|
||||
for c in unsafe { uts.assume_init() }.nodename.iter() {
|
||||
|
||||
@@ -75,14 +75,12 @@ unsafe impl GlobalAlloc for Allocator {
|
||||
let new =
|
||||
unsafe { self.alloc(Layout::from_size_align_unchecked(new_size, layout.align())) };
|
||||
let old_size = layout.size();
|
||||
let old_align = layout.align();
|
||||
|
||||
if !new.is_null() {
|
||||
let size = cmp::min(old_size, new_size);
|
||||
unsafe { copy_nonoverlapping(ptr, new, size) };
|
||||
}
|
||||
|
||||
drop((old_size, old_align));
|
||||
unsafe { (*self.get()).lock().free(ptr) };
|
||||
|
||||
new
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::{
|
||||
header::{
|
||||
pthread::pthread_atfork,
|
||||
sys_mman::{self, MREMAP_MAYMOVE},
|
||||
unistd::pthread_atfork,
|
||||
},
|
||||
platform::{Pal, Sys},
|
||||
sync::Mutex,
|
||||
|
||||
+1
-1
@@ -190,7 +190,7 @@ pub(crate) unsafe fn create(
|
||||
push(arg as usize);
|
||||
push(start_routine as usize);
|
||||
|
||||
push(new_thread_shim as usize);
|
||||
push(new_thread_shim as *const () as usize);
|
||||
}
|
||||
|
||||
let Ok(os_tid) = (unsafe { Sys::rlct_clone(stack, &mut new_tcb.os_specific) }) else {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
Reference in New Issue
Block a user