diff options
author | Zach Reizner <zachr@google.com> | 2017-08-30 17:07:01 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2017-09-01 12:39:18 -0700 |
commit | 3cbded2c51574bfdefe8d26a9c6ff235c7330b59 (patch) | |
tree | 6e891f47d965e42c47c254094b17b6813ca8dd09 /sys_util | |
parent | 86fb9567b588a11ed1f7ed2e3223c25fad07cc6f (diff) | |
download | crosvm-3cbded2c51574bfdefe8d26a9c6ff235c7330b59.tar crosvm-3cbded2c51574bfdefe8d26a9c6ff235c7330b59.tar.gz crosvm-3cbded2c51574bfdefe8d26a9c6ff235c7330b59.tar.bz2 crosvm-3cbded2c51574bfdefe8d26a9c6ff235c7330b59.tar.lz crosvm-3cbded2c51574bfdefe8d26a9c6ff235c7330b59.tar.xz crosvm-3cbded2c51574bfdefe8d26a9c6ff235c7330b59.tar.zst crosvm-3cbded2c51574bfdefe8d26a9c6ff235c7330b59.zip |
fix armv7a and aarch64 build errors and warnings
BUG=None TEST=cargo build --target=armv7a-cros-linux-gnueabi && cargo build --target=aarch64-cros-linux-gnu Change-Id: I954c152f3c8086e24c4809dd5aabb5043fdd63af Reviewed-on: https://chromium-review.googlesource.com/644408 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Jason Clinton <jclinton@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
Diffstat (limited to 'sys_util')
-rw-r--r-- | sys_util/sock_ctrl_msg.c | 6 | ||||
-rw-r--r-- | sys_util/src/fork.rs | 4 | ||||
-rw-r--r-- | sys_util/src/lib.rs | 4 | ||||
-rw-r--r-- | sys_util/src/shm.rs | 6 | ||||
-rw-r--r-- | sys_util/src/syslog.rs | 11 | ||||
-rw-r--r-- | sys_util/src/tempdir.rs | 2 |
6 files changed, 14 insertions, 19 deletions
diff --git a/sys_util/sock_ctrl_msg.c b/sys_util/sock_ctrl_msg.c index 85ef9f7..d569a47 100644 --- a/sys_util/sock_ctrl_msg.c +++ b/sys_util/sock_ctrl_msg.c @@ -39,7 +39,8 @@ ssize_t scm_sendmsg(int fd, const struct iovec *outv, size_t outv_count, uint8_t if (fd < 0 || ((!cmsg_buffer || !fds) && fd_count > 0)) return -EINVAL; - struct msghdr msg = {0}; + struct msghdr msg; + memset(&msg, 0, sizeof(msg)); msg.msg_iov = (struct iovec *)outv; // discard const, sendmsg won't mutate it msg.msg_iovlen = outv_count; @@ -83,7 +84,8 @@ ssize_t scm_recvmsg(int fd, struct iovec *outv, size_t outv_count, uint8_t *cmsg if (fd < 0 || !cmsg_buffer || !fds || !fd_count) return -EINVAL; - struct msghdr msg = {0}; + struct msghdr msg; + memset(&msg, 0, sizeof(msg)); msg.msg_iov = outv; msg.msg_iovlen = outv_count; msg.msg_control = cmsg_buffer; diff --git a/sys_util/src/fork.rs b/sys_util/src/fork.rs index 053152a..69a49c5 100644 --- a/sys_util/src/fork.rs +++ b/sys_util/src/fork.rs @@ -10,7 +10,7 @@ use std::result; use errno_result; -use libc::{syscall, SIGCHLD, CLONE_NEWUSER, CLONE_NEWPID, pid_t}; +use libc::{syscall, SIGCHLD, CLONE_NEWUSER, CLONE_NEWPID, c_long, pid_t}; use syscall_defines::linux::LinuxSyscall::SYS_clone; @@ -36,7 +36,7 @@ pub enum CloneError { unsafe fn do_clone(flags: i32) -> ::Result<pid_t> { // Forking is unsafe, this function must be unsafe as there is no way to guarantee safety // without more context about the state of the program. - let pid = syscall(SYS_clone as i64, flags | SIGCHLD as i32, 0); + let pid = syscall(SYS_clone as c_long, flags | SIGCHLD as i32, 0); if pid < 0 { errno_result() } else { diff --git a/sys_util/src/lib.rs b/sys_util/src/lib.rs index 3574f98..7610d4e 100644 --- a/sys_util/src/lib.rs +++ b/sys_util/src/lib.rs @@ -52,7 +52,7 @@ pub use signalfd::Error as SignalFdError; use std::ptr; -use libc::{kill, syscall, waitpid, pid_t, uid_t, gid_t, SIGKILL, WNOHANG}; +use libc::{kill, syscall, waitpid, c_long, pid_t, uid_t, gid_t, SIGKILL, WNOHANG}; use syscall_defines::linux::LinuxSyscall::SYS_getpid; @@ -61,7 +61,7 @@ use syscall_defines::linux::LinuxSyscall::SYS_getpid; #[inline(always)] pub fn getpid() -> pid_t { // Safe because this syscall can never fail and we give it a valid syscall number. - unsafe { syscall(SYS_getpid as i64) as pid_t } + unsafe { syscall(SYS_getpid as c_long) as pid_t } } /// Safe wrapper for `geteuid(2)`. diff --git a/sys_util/src/shm.rs b/sys_util/src/shm.rs index 5fee8df..4d2e41c 100644 --- a/sys_util/src/shm.rs +++ b/sys_util/src/shm.rs @@ -7,7 +7,7 @@ use std::fs::File; use std::io::{Seek, SeekFrom}; use std::os::unix::io::{AsRawFd, IntoRawFd, FromRawFd, RawFd}; -use libc::{off64_t, c_int, c_uint, c_char, syscall, ftruncate64}; +use libc::{off64_t, c_long, c_int, c_uint, c_char, syscall, ftruncate64}; use syscall_defines::linux::LinuxSyscall::SYS_memfd_create; @@ -23,7 +23,7 @@ pub struct SharedMemory { const MFD_CLOEXEC: c_uint = 0x0001; unsafe fn memfd_create(name: *const c_char, flags: c_uint) -> c_int { - syscall(SYS_memfd_create as i64, name as i64, flags as i64) as c_int + syscall(SYS_memfd_create as c_long, name as i64, flags as i64) as c_int } impl SharedMemory { @@ -35,7 +35,7 @@ impl SharedMemory { /// The file descriptor is opened with the close on exec flag. pub fn new(name: Option<&CStr>) -> Result<SharedMemory> { let shm_name = name.map(|n| n.as_ptr()) - .unwrap_or(b"/crosvm_shm\0".as_ptr() as *const i8); + .unwrap_or(b"/crosvm_shm\0".as_ptr() as *const c_char); // The following are safe because we give a valid C string and check the // results of the memfd_create call. let fd = unsafe { memfd_create(shm_name, MFD_CLOEXEC) }; diff --git a/sys_util/src/syslog.rs b/sys_util/src/syslog.rs index 1a3e6ee..12996f8 100644 --- a/sys_util/src/syslog.rs +++ b/sys_util/src/syslog.rs @@ -38,9 +38,9 @@ use std::result; use std::str::from_utf8; use std::sync::{Mutex, MutexGuard, Once, ONCE_INIT}; -use libc::{tm, time, time_t, localtime_r, gethostname, c_char, syscall}; +use libc::{tm, time, time_t, localtime_r, gethostname, c_char}; -use syscall_defines::linux::LinuxSyscall::SYS_getpid; +use getpid; const SYSLOG_PATH: &'static str = "/dev/log"; @@ -293,13 +293,6 @@ fn send_buf(socket: &UnixDatagram, buf: &[u8]) { } } -// This bypasses libc's caching getpid() wrapper which can be invalid if a raw clone was used -// elsewhere. -fn getpid() -> i32 { - // Safe because this syscall can never fail and we give it a valid syscall number. - unsafe { syscall(SYS_getpid as i64) as i32 } -} - fn get_localtime() -> tm { unsafe { // Safe because tm is just a struct of plain data. diff --git a/sys_util/src/tempdir.rs b/sys_util/src/tempdir.rs index 6a27652..de36c69 100644 --- a/sys_util/src/tempdir.rs +++ b/sys_util/src/tempdir.rs @@ -45,7 +45,7 @@ impl TempDir { let ret = unsafe { // Creating the directory isn't unsafe. The fact that it modifies the guts of the path // is also OK because it only overwrites the last 6 Xs added above. - libc::mkdtemp(dir_bytes.as_mut_ptr() as *mut i8) + libc::mkdtemp(dir_bytes.as_mut_ptr() as *mut libc::c_char) }; if ret.is_null() { return errno_result(); |