refactor: use architecture dependent sizes

This commit is contained in:
dignifiedquire
2019-04-28 15:14:54 +03:00
parent 736ff0afba
commit e8a79f220e
45 changed files with 1155 additions and 1402 deletions

View File

@@ -342,11 +342,9 @@ unsafe extern "C" fn poke_spec(
break;
}
name = (*dir_entry).d_name.as_mut_ptr();
if strlen(name) >= 4i32 as libc::c_ulong
if strlen(name) >= 4
&& strcmp(
&mut *name
.offset(strlen(name).wrapping_sub(4i32 as libc::c_ulong)
as isize),
&mut *name.offset(strlen(name).wrapping_sub(4) as isize),
b".eml\x00" as *const u8 as *const libc::c_char,
) == 0i32
{
@@ -509,8 +507,8 @@ unsafe extern "C" fn log_contactlist(
if 0 == dc_array_search_id(contacts, 1i32 as uint32_t, 0 as *mut size_t) {
dc_array_add_id(contacts, 1i32 as uint32_t);
}
let mut i: libc::c_int = 0i32;
while (i as libc::c_ulong) < dc_array_get_cnt(contacts) {
let mut i = 0;
while i < dc_array_get_cnt(contacts) {
let mut contact_id: uint32_t = dc_array_get_id(contacts, i as size_t);
let mut line: *mut libc::c_char = 0 as *mut libc::c_char;
let mut line2: *mut libc::c_char = 0 as *mut libc::c_char;
@@ -1241,8 +1239,8 @@ pub unsafe extern "C" fn dc_cmdline(
0i32 as time_t,
0i32 as time_t,
);
let mut j: libc::c_int = 0i32;
while (j as libc::c_ulong) < dc_array_get_cnt(loc) {
let mut j = 0;
while j < dc_array_get_cnt(loc) {
let mut timestr_0: *mut libc::c_char =
dc_timestamp_to_str(dc_array_get_timestamp(loc, j as size_t));
let mut marker: *mut libc::c_char = dc_array_get_marker(loc, j as size_t);
@@ -1269,7 +1267,7 @@ pub unsafe extern "C" fn dc_cmdline(
free(marker as *mut libc::c_void);
j += 1
}
if dc_array_get_cnt(loc) == 0i32 as libc::c_ulong {
if dc_array_get_cnt(loc) == 0 {
dc_log_info(
context,
0i32,

View File

@@ -267,8 +267,9 @@ unsafe fn receive_event(
/* ******************************************************************************
* Threads for waiting for messages and for jobs
******************************************************************************/
static mut inbox_thread: pthread_t = 0 as *const _opaque_pthread_t as pthread_t;
static mut inbox_thread: pthread_t = 0 as pthread_t;
static mut run_threads: libc::c_int = 0i32;
unsafe extern "C" fn inbox_thread_entry_point(
mut entry_arg: *mut libc::c_void,
) -> *mut libc::c_void {
@@ -282,7 +283,7 @@ unsafe extern "C" fn inbox_thread_entry_point(
}
return 0 as *mut libc::c_void;
}
static mut mvbox_thread: pthread_t = 0 as *const _opaque_pthread_t as pthread_t;
static mut mvbox_thread: pthread_t = 0 as pthread_t;
unsafe extern "C" fn mvbox_thread_entry_point(
mut entry_arg: *mut libc::c_void,
) -> *mut libc::c_void {
@@ -295,7 +296,7 @@ unsafe extern "C" fn mvbox_thread_entry_point(
}
return 0 as *mut libc::c_void;
}
static mut sentbox_thread: pthread_t = 0 as *const _opaque_pthread_t as pthread_t;
static mut sentbox_thread: pthread_t = 0 as pthread_t;
unsafe extern "C" fn sentbox_thread_entry_point(
mut entry_arg: *mut libc::c_void,
) -> *mut libc::c_void {
@@ -308,7 +309,7 @@ unsafe extern "C" fn sentbox_thread_entry_point(
}
return 0 as *mut libc::c_void;
}
static mut smtp_thread: pthread_t = 0 as *const _opaque_pthread_t as pthread_t;
static mut smtp_thread: pthread_t = 0 as pthread_t;
unsafe extern "C" fn smtp_thread_entry_point(
mut entry_arg: *mut libc::c_void,
) -> *mut libc::c_void {
@@ -323,7 +324,7 @@ unsafe extern "C" fn smtp_thread_entry_point(
}
unsafe extern "C" fn start_threads(mut context: *mut dc_context_t) {
run_threads = 1i32;
if inbox_thread.is_null() {
if inbox_thread == 0 {
pthread_create(
&mut inbox_thread,
0 as *const pthread_attr_t,
@@ -331,7 +332,7 @@ unsafe extern "C" fn start_threads(mut context: *mut dc_context_t) {
context as *mut libc::c_void,
);
}
if mvbox_thread.is_null() {
if mvbox_thread == 0 {
pthread_create(
&mut mvbox_thread,
0 as *const pthread_attr_t,
@@ -339,7 +340,7 @@ unsafe extern "C" fn start_threads(mut context: *mut dc_context_t) {
context as *mut libc::c_void,
);
}
if sentbox_thread.is_null() {
if sentbox_thread == 0 {
pthread_create(
&mut sentbox_thread,
0 as *const pthread_attr_t,
@@ -347,7 +348,7 @@ unsafe extern "C" fn start_threads(mut context: *mut dc_context_t) {
context as *mut libc::c_void,
);
}
if smtp_thread.is_null() {
if smtp_thread == 0 {
pthread_create(
&mut smtp_thread,
0 as *const pthread_attr_t,
@@ -374,24 +375,24 @@ unsafe extern "C" fn stop_threads(mut context: *mut dc_context_t) {
/* ******************************************************************************
* The main loop
******************************************************************************/
#[cfg(not(target_os = "android"))]
unsafe extern "C" fn read_cmd() -> *mut libc::c_char {
printf(b"> \x00" as *const u8 as *const libc::c_char);
static mut cmdbuffer: [libc::c_char; 1024] = [0; 1024];
fgets(cmdbuffer.as_mut_ptr(), 1000i32, __stdinp);
while strlen(cmdbuffer.as_mut_ptr()) > 0i32 as libc::c_ulong
&& (cmdbuffer[strlen(cmdbuffer.as_mut_ptr()).wrapping_sub(1i32 as libc::c_ulong) as usize]
as libc::c_int
while strlen(cmdbuffer.as_mut_ptr()) > 0
&& (cmdbuffer[strlen(cmdbuffer.as_mut_ptr()).wrapping_sub(1) as usize] as libc::c_int
== '\n' as i32
|| cmdbuffer
[strlen(cmdbuffer.as_mut_ptr()).wrapping_sub(1i32 as libc::c_ulong) as usize]
as libc::c_int
|| cmdbuffer[strlen(cmdbuffer.as_mut_ptr()).wrapping_sub(1) as usize] as libc::c_int
== ' ' as i32)
{
cmdbuffer[strlen(cmdbuffer.as_mut_ptr()).wrapping_sub(1i32 as libc::c_ulong) as usize] =
cmdbuffer[strlen(cmdbuffer.as_mut_ptr()).wrapping_sub(1) as usize] =
'\u{0}' as i32 as libc::c_char
}
return cmdbuffer.as_mut_ptr();
}
#[cfg(not(target_os = "android"))]
unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> libc::c_int {
let mut cmd: *mut libc::c_char = 0 as *mut libc::c_char;
let mut context: *mut dc_context_t = dc_context_new(
@@ -496,7 +497,7 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib
);
if !qrstr.is_null() && 0 != *qrstr.offset(0isize) as libc::c_int {
if strcmp(cmd, b"getbadqr\x00" as *const u8 as *const libc::c_char) == 0i32
&& strlen(qrstr) > 40i32 as libc::c_ulong
&& strlen(qrstr) > 40
{
let mut i: libc::c_int = 12i32;
while i < 22i32 {
@@ -541,6 +542,8 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib
context = 0 as *mut dc_context_t;
return 0i32;
}
#[cfg(not(target_os = "android"))]
pub fn main() {
let mut args: Vec<*mut libc::c_char> = Vec::new();
for arg in ::std::env::args() {
@@ -558,3 +561,6 @@ pub fn main() {
) as i32)
}
}
#[cfg(target_os = "android")]
fn main() {}

View File

@@ -161,9 +161,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
);
} else {
};
if 0 != !(dc_array_get_cnt((*kml).locations) == 2i32 as libc::c_ulong) as libc::c_int
as libc::c_long
{
if 0 != !(dc_array_get_cnt((*kml).locations) == 2) as libc::c_int as libc::c_long {
__assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(),
@@ -464,7 +462,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
);
} else {
};
if 0 != !(buf_bytes == 7i32 as libc::c_ulong) as libc::c_int as libc::c_long {
if 0 != !(buf_bytes == 7) as libc::c_int as libc::c_long {
__assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(),
@@ -1917,7 +1915,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
free(buf1 as *mut libc::c_void);
free(buf2 as *mut libc::c_void);
buf1 = dc_create_id();
if 0 != !(strlen(buf1) == 11i32 as libc::c_ulong) as libc::c_int as libc::c_long {
if 0 != !(strlen(buf1) == 11) as libc::c_int as libc::c_long {
__assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(),
@@ -1980,11 +1978,8 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
buf1 = dc_encode_header_words(
b"test\xc3\xa4\xc3\xb6\xc3\xbc.txt\x00" as *const u8 as *const libc::c_char,
);
if 0 != !(strncmp(
buf1,
b"=?utf-8\x00" as *const u8 as *const libc::c_char,
7i32 as libc::c_ulong,
) == 0i32) as libc::c_int as libc::c_long
if 0 != !(strncmp(buf1, b"=?utf-8\x00" as *const u8 as *const libc::c_char, 7) == 0i32)
as libc::c_int as libc::c_long
{
__assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
@@ -2423,9 +2418,9 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
);
} else {
};
if 0 != !(dc_utf8_strlen(b"c\x00" as *const u8 as *const libc::c_char) == 1i32 as libc::c_ulong
&& strlen(b"c\x00" as *const u8 as *const libc::c_char) == 1i32 as libc::c_ulong)
as libc::c_int as libc::c_long
if 0 != !(dc_utf8_strlen(b"c\x00" as *const u8 as *const libc::c_char) == 1
&& strlen(b"c\x00" as *const u8 as *const libc::c_char) == 1) as libc::c_int
as libc::c_long
{
__assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
@@ -2436,9 +2431,8 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
);
} else {
};
if 0 != !(dc_utf8_strlen(b"\xc3\xa4\x00" as *const u8 as *const libc::c_char)
== 1i32 as libc::c_ulong
&& strlen(b"\xc3\xa4\x00" as *const u8 as *const libc::c_char) == 2i32 as libc::c_ulong)
if 0 != !(dc_utf8_strlen(b"\xc3\xa4\x00" as *const u8 as *const libc::c_char) == 1
&& strlen(b"\xc3\xa4\x00" as *const u8 as *const libc::c_char) == 2)
as libc::c_int as libc::c_long
{
__assert_rtn(
@@ -2452,7 +2446,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
} else {
};
let mut arr: *mut dc_array_t = dc_array_new(0 as *mut dc_context_t, 7i32 as size_t);
if 0 != !(dc_array_get_cnt(arr) == 0i32 as libc::c_ulong) as libc::c_int as libc::c_long {
if 0 != !(dc_array_get_cnt(arr) == 0) as libc::c_int as libc::c_long {
__assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(),
@@ -2468,7 +2462,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
dc_array_add_id(arr, (i + 1i32 * 2i32) as uint32_t);
i += 1
}
if 0 != !(dc_array_get_cnt(arr) == 1000i32 as libc::c_ulong) as libc::c_int as libc::c_long {
if 0 != !(dc_array_get_cnt(arr) == 1000) as libc::c_int as libc::c_long {
__assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(),
@@ -2531,7 +2525,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
} else {
};
dc_array_empty(arr);
if 0 != !(dc_array_get_cnt(arr) == 0i32 as libc::c_ulong) as libc::c_int as libc::c_long {
if 0 != !(dc_array_get_cnt(arr) == 0) as libc::c_int as libc::c_long {
__assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(),
@@ -3268,7 +3262,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
&& strncmp(
(*(*ah).public_key).binary as *mut libc::c_char,
b"Delta Chat\x00" as *const u8 as *const libc::c_char,
10i32 as libc::c_ulong,
10,
) == 0i32) as libc::c_int as libc::c_long
{
__assert_rtn((*::std::mem::transmute::<&[u8; 17],
@@ -3339,7 +3333,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
&& strncmp(
(*(*ah).public_key).binary as *mut libc::c_char,
b"Delta Chat\x00" as *const u8 as *const libc::c_char,
10i32 as libc::c_ulong,
10,
) == 0i32) as libc::c_int as libc::c_long
{
__assert_rtn((*::std::mem::transmute::<&[u8; 17],
@@ -4008,7 +4002,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
);
} else {
};
if 0 != !(strlen(setupcode) == 44i32 as libc::c_ulong) as libc::c_int as libc::c_long {
if 0 != !(strlen(setupcode) == 44) as libc::c_int as libc::c_long {
__assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(),
@@ -4087,9 +4081,9 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
} else {
};
if 0 != !(!setupcodebegin_1.is_null()
&& strlen(setupcodebegin_1) == 2i32 as libc::c_ulong
&& strncmp(setupcodebegin_1, setupcode, 2i32 as libc::c_ulong) == 0i32)
as libc::c_int as libc::c_long
&& strlen(setupcodebegin_1) == 2
&& strncmp(setupcodebegin_1, setupcode, 2) == 0i32) as libc::c_int
as libc::c_long
{
__assert_rtn((*::std::mem::transmute::<&[u8; 17],
&[libc::c_char; 17]>(b"stress_functions\x00")).as_ptr(),
@@ -4259,8 +4253,8 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
&mut ctext_signed as *mut *mut libc::c_void,
&mut ctext_signed_bytes,
);
if 0 != !(0 != ok_0 && !ctext_signed.is_null() && ctext_signed_bytes > 0i32 as libc::c_ulong)
as libc::c_int as libc::c_long
if 0 != !(0 != ok_0 && !ctext_signed.is_null() && ctext_signed_bytes > 0) as libc::c_int
as libc::c_long
{
__assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
@@ -4274,7 +4268,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
if 0 != !(strncmp(
ctext_signed as *mut libc::c_char,
b"-----BEGIN PGP MESSAGE-----\x00" as *const u8 as *const libc::c_char,
27i32 as libc::c_ulong,
27,
) == 0i32) as libc::c_int as libc::c_long
{
__assert_rtn(
@@ -4288,8 +4282,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
} else {
};
if 0 != !(*(ctext_signed as *mut libc::c_char)
.offset(ctext_signed_bytes.wrapping_sub(1i32 as libc::c_ulong) as isize)
as libc::c_int
.offset(ctext_signed_bytes.wrapping_sub(1) as isize) as libc::c_int
!= 0i32) as libc::c_int as libc::c_long
{
__assert_rtn(
@@ -4312,9 +4305,8 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
&mut ctext_unsigned as *mut *mut libc::c_void,
&mut ctext_unsigned_bytes,
);
if 0 != !(0 != ok_0
&& !ctext_unsigned.is_null()
&& ctext_unsigned_bytes > 0i32 as libc::c_ulong) as libc::c_int as libc::c_long
if 0 != !(0 != ok_0 && !ctext_unsigned.is_null() && ctext_unsigned_bytes > 0) as libc::c_int
as libc::c_long
{
__assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
@@ -4329,7 +4321,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
if 0 != !(strncmp(
ctext_unsigned as *mut libc::c_char,
b"-----BEGIN PGP MESSAGE-----\x00" as *const u8 as *const libc::c_char,
27i32 as libc::c_ulong,
27,
) == 0i32) as libc::c_int as libc::c_long
{
__assert_rtn(
@@ -4381,9 +4373,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
&mut plain_bytes,
&mut valid_signatures,
);
if 0 != !(0 != ok_1 && !plain_0.is_null() && plain_bytes > 0i32 as libc::c_ulong) as libc::c_int
as libc::c_long
{
if 0 != !(0 != ok_1 && !plain_0.is_null() && plain_bytes > 0) as libc::c_int as libc::c_long {
__assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(),
@@ -4433,9 +4423,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
&mut plain_bytes,
&mut valid_signatures,
);
if 0 != !(0 != ok_1 && !plain_0.is_null() && plain_bytes > 0i32 as libc::c_ulong) as libc::c_int
as libc::c_long
{
if 0 != !(0 != ok_1 && !plain_0.is_null() && plain_bytes > 0) as libc::c_int as libc::c_long {
__assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(),
@@ -4485,9 +4473,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
&mut plain_bytes,
&mut valid_signatures,
);
if 0 != !(0 != ok_1 && !plain_0.is_null() && plain_bytes > 0i32 as libc::c_ulong) as libc::c_int
as libc::c_long
{
if 0 != !(0 != ok_1 && !plain_0.is_null() && plain_bytes > 0) as libc::c_int as libc::c_long {
__assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(),
@@ -4538,9 +4524,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
&mut plain_bytes,
&mut valid_signatures,
);
if 0 != !(0 != ok_1 && !plain_0.is_null() && plain_bytes > 0i32 as libc::c_ulong) as libc::c_int
as libc::c_long
{
if 0 != !(0 != ok_1 && !plain_0.is_null() && plain_bytes > 0) as libc::c_int as libc::c_long {
__assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(),
@@ -4590,9 +4574,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
&mut plain_bytes,
&mut valid_signatures,
);
if 0 != !(0 != ok_1 && !plain_0.is_null() && plain_bytes > 0i32 as libc::c_ulong) as libc::c_int
as libc::c_long
{
if 0 != !(0 != ok_1 && !plain_0.is_null() && plain_bytes > 0) as libc::c_int as libc::c_long {
__assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(),
@@ -4640,9 +4622,7 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
&mut plain_bytes,
0 as *mut dc_hash_t,
);
if 0 != !(0 != ok_2 && !plain_1.is_null() && plain_bytes > 0i32 as libc::c_ulong) as libc::c_int
as libc::c_long
{
if 0 != !(0 != ok_2 && !plain_1.is_null() && plain_bytes > 0) as libc::c_int as libc::c_long {
__assert_rtn(
(*::std::mem::transmute::<&[u8; 17], &[libc::c_char; 17]>(b"stress_functions\x00"))
.as_ptr(),
@@ -4715,16 +4695,16 @@ pub unsafe extern "C" fn stress_functions(mut context: *mut dc_context_t) {
free(fingerprint as *mut libc::c_void);
if 0 != dc_is_configured(context) {
let mut qr: *mut libc::c_char = dc_get_securejoin_qr(context, 0i32 as uint32_t);
if 0 != !(strlen(qr) > 55i32 as libc::c_ulong
if 0 != !(strlen(qr) > 55
&& strncmp(
qr,
b"OPENPGP4FPR:\x00" as *const u8 as *const libc::c_char,
12i32 as libc::c_ulong,
12,
) == 0i32
&& strncmp(
&mut *qr.offset(52isize),
b"#a=\x00" as *const u8 as *const libc::c_char,
3i32 as libc::c_ulong,
3,
) == 0i32) as libc::c_int as libc::c_long
{
__assert_rtn((*::std::mem::transmute::<&[u8; 17],

View File

@@ -16,7 +16,7 @@ use deltachat::dc_job::{
};
use deltachat::dc_lot::*;
fn cb(_ctx: *mut dc_context_t, event: Event, data1: u64, data2: u64) -> u64 {
fn cb(_ctx: *mut dc_context_t, event: Event, data1: usize, data2: usize) -> usize {
println!("[{:?}]", event);
match event {
@@ -28,7 +28,7 @@ fn cb(_ctx: *mut dc_context_t, event: Event, data1: u64, data2: u64) -> u64 {
let c_res = CString::new(res.text().unwrap()).unwrap();
// need to use strdup to allocate the result with malloc
// so it can be `free`d later.
unsafe { libc::strdup(c_res.as_ptr()) as u64 }
unsafe { libc::strdup(c_res.as_ptr()) as usize }
}
Err(err) => {
println!("failed to download: {}: {:?}", url, err);