mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-06-06 17:31:14 -03:00
fix: clippy::ptr_cast_constness
https://rust-lang.github.io/rust-clippy/master/index.html#ptr_cast_constness Part of #12136
This commit is contained in:
committed by
Johannes Altmanninger
parent
831411ddd5
commit
cc29216ea9
@@ -415,7 +415,7 @@ fn safe_launch_process(
|
||||
// +1 for /bin/sh, +1 for terminating nullptr
|
||||
let mut argv2 = [std::ptr::null(); 1 + MAXARGS + 1];
|
||||
let bshell = PATH_BSHELL.as_ptr() as *const c_char;
|
||||
argv2[0] = bshell as *mut c_char;
|
||||
argv2[0] = bshell;
|
||||
argv2[1..argv.len() + 1].copy_from_slice(argv);
|
||||
// The command to call should use the full path,
|
||||
// not what we would pass as argv0.
|
||||
|
||||
@@ -172,12 +172,12 @@ pub(crate) fn spawn(
|
||||
let cmdcstr = unsafe { CStr::from_ptr(cmd) };
|
||||
if spawn_err.0 == libc::ENOEXEC && is_thompson_shell_script(cmdcstr) {
|
||||
// Create a new argv with /bin/sh prepended.
|
||||
let mut argv2 = vec![PATH_BSHELL.as_ptr() as *mut c_char];
|
||||
let mut argv2: Vec<*mut c_char> = vec![PATH_BSHELL.as_ptr().cast_mut() as *mut c_char];
|
||||
|
||||
// The command to call should use the full path,
|
||||
// not what we would pass as argv0.
|
||||
let cmd2: CString = CString::new(cmdcstr.to_bytes()).unwrap();
|
||||
argv2.push(cmd2.as_ptr() as *mut c_char);
|
||||
argv2.push(cmd2.as_ptr().cast_mut());
|
||||
for i in 1.. {
|
||||
let ptr = unsafe { argv.offset(i).read() };
|
||||
if ptr.is_null() {
|
||||
|
||||
@@ -35,7 +35,7 @@ fn clone(&self) -> Self {
|
||||
|
||||
impl<T: ?Sized> AtomicRef<T> {
|
||||
pub const fn new(value: &'static &'static T) -> Self {
|
||||
Self(AtomicPtr::new(std::ptr::from_ref(value) as *mut &'static T))
|
||||
Self(AtomicPtr::new(std::ptr::from_ref(value).cast_mut()))
|
||||
}
|
||||
|
||||
pub fn load(&self) -> &'static T {
|
||||
@@ -43,10 +43,8 @@ pub fn load(&self) -> &'static T {
|
||||
}
|
||||
|
||||
pub fn store(&self, value: &'static &'static T) {
|
||||
self.0.store(
|
||||
std::ptr::from_ref(value) as *mut &'static T,
|
||||
Ordering::Relaxed,
|
||||
)
|
||||
self.0
|
||||
.store(std::ptr::from_ref(value).cast_mut(), Ordering::Relaxed)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ unsafe fn lconv_to_locale(lconv: &libc::lconv) -> Locale {
|
||||
|
||||
// Up to 4 groups.
|
||||
// group_cursor is terminated by either a 0 or CHAR_MAX.
|
||||
let mut group_cursor = lconv.grouping as *const libc::c_char;
|
||||
let mut group_cursor = lconv.grouping.cast_const();
|
||||
if group_cursor.is_null() {
|
||||
group_cursor = empty.as_ptr();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user