summaryrefslogtreecommitdiff
path: root/alacritty_terminal/src/tty
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2019-09-10 18:08:01 +0200
committerChristian Duerr <contact@christianduerr.com>2019-09-10 16:08:01 +0000
commit1067fa609b6a5a0017814cb96d8b21b39b2f83f2 (patch)
tree4b71a2863f0efdbc5aeb3a8f36234f85e59f7eec /alacritty_terminal/src/tty
parent8aa406b98b3932a47a05ac8d71b4704198acd6f2 (diff)
downloadalacritty-1067fa609b6a5a0017814cb96d8b21b39b2f83f2.tar.gz
alacritty-1067fa609b6a5a0017814cb96d8b21b39b2f83f2.zip
Replace uninitialized with MaybeUninit
Diffstat (limited to 'alacritty_terminal/src/tty')
-rw-r--r--alacritty_terminal/src/tty/unix.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/alacritty_terminal/src/tty/unix.rs b/alacritty_terminal/src/tty/unix.rs
index 8ed8ba03..e666eeba 100644
--- a/alacritty_terminal/src/tty/unix.rs
+++ b/alacritty_terminal/src/tty/unix.rs
@@ -13,7 +13,6 @@
// limitations under the License.
//
//! tty related functionality
-//!
use crate::config::{Config, Shell};
use crate::display::OnResize;
@@ -36,6 +35,7 @@ use std::os::unix::{
use std::process::{Child, Command, Stdio};
use std::ptr;
use std::sync::atomic::{AtomicUsize, Ordering};
+use std::mem::MaybeUninit;
/// Process ID of child process
///
@@ -91,15 +91,16 @@ struct Passwd<'a> {
/// If `buf` is changed while `Passwd` is alive, bad thing will almost certainly happen.
fn get_pw_entry(buf: &mut [i8; 1024]) -> Passwd<'_> {
// Create zeroed passwd struct
- let mut entry: libc::passwd = unsafe { ::std::mem::uninitialized() };
+ let mut entry: MaybeUninit<libc::passwd> = MaybeUninit::uninit();
let mut res: *mut libc::passwd = ptr::null_mut();
// Try and read the pw file.
let uid = unsafe { libc::getuid() };
let status = unsafe {
- libc::getpwuid_r(uid, &mut entry, buf.as_mut_ptr() as *mut _, buf.len(), &mut res)
+ libc::getpwuid_r(uid, entry.as_mut_ptr(), buf.as_mut_ptr() as *mut _, buf.len(), &mut res)
};
+ let entry = unsafe { entry.assume_init() };
if status < 0 {
die!("getpwuid_r failed");