Fix compilation for 32-bit architectures

Signed-off-by: Manos Pitsidianakis <manos@pitsidianak.is>
pull/492/head
Manos Pitsidianakis 4 weeks ago
parent 2001b4dd06
commit e0cfe8e4d7
No known key found for this signature in database
GPG Key ID: 7729C7707F7E09D0

@ -224,13 +224,24 @@ impl Seek for Data {
#[inline]
fn seek(&mut self, pos: io::SeekFrom) -> io::Result<u64> {
let (off, whence) = match pos {
io::SeekFrom::Start(off) => (off.try_into().unwrap_or(i64::MAX), libc::SEEK_SET),
io::SeekFrom::Start(off) => (
off.try_into()
.map_err(|_| io::Error::from_raw_os_error(libc::EOVERFLOW))?,
libc::SEEK_SET,
),
io::SeekFrom::End(off) => (off.saturating_abs(), libc::SEEK_END),
io::SeekFrom::Current(off) => (off, libc::SEEK_CUR),
};
let result = unsafe { call!(self.lib, gpgme_data_seek)(self.inner.as_ptr(), off, whence) };
let result = unsafe {
call!(self.lib, gpgme_data_seek)(
self.inner.as_ptr(),
libc::off_t::try_from(off)
.map_err(|_| io::Error::from_raw_os_error(libc::EOVERFLOW))?,
whence,
)
};
if result >= 0 {
Ok(result as u64)
Ok(u64::try_from(result).map_err(|_| io::Error::from_raw_os_error(libc::EOVERFLOW))?)
} else {
Err(io::Error::last_os_error())
}

@ -111,12 +111,14 @@ pub struct DbConnection {
impl DbConnection {
pub fn get_revision_uuid(&self) -> u64 {
unsafe {
let ret: ::std::os::raw::c_ulong = unsafe {
call!(self.lib, notmuch_database_get_revision)(
self.inner.lock().unwrap().as_mut(),
std::ptr::null_mut(),
)
}
};
#[allow(clippy::useless_conversion)]
u64::from(ret)
}
#[allow(clippy::too_many_arguments)] // Don't judge me clippy.

@ -207,7 +207,7 @@ fn timestamp_to_string_inner(
) -> String {
let mut new_tm: libc::tm = unsafe { std::mem::zeroed() };
unsafe {
let i: i64 = timestamp.try_into().unwrap_or(0);
let i = timestamp.try_into().unwrap_or(0);
if local {
localtime_r(std::ptr::addr_of!(i), std::ptr::addr_of_mut!(new_tm));
} else {

@ -261,7 +261,7 @@ pub mod impls {
let mut buf: Vec<u8> = vec![0; BUF_SIZE * std::mem::size_of::<::libc::dirent64>()];
let mut entries = Vec::new();
loop {
let n: i64 = unsafe {
let n = unsafe {
::libc::syscall(
::libc::SYS_getdents64,
dir.as_raw_fd(),

Loading…
Cancel
Save