mirror of
https://github.com/chatmail/core.git
synced 2026-04-19 14:36:29 +03:00
chore: fix compiler warnings (mut + unused assignments) (#40)
* Stop allowing unused assignments
* test: remove unused assignments in cmdline
* chore: fix compiler warnings in dc_tools.rs
* chore: fix compiler warnings in dc_token.rs
* chore: fix compiler warnings in dc_strencode.rs
* chore: fix compiler warnings in dc_stock.rs
* chore: fix compiler warnings in dc_sqlite3.rs
* chore: fix compiler warnings in dc_simplify.rs
* chore: fix compiler warnings in dc_securejoin.rs
* chore: fix compiler warnings in dc_saxparser.rs
* chore: fix compiler warnings in dc_pgp.rs
* chore: fix compiler warnings in dc_param.rs
* chore: fix compiler warnings in dc_oauth2.rs
* chore: fix compiler warnings in dc_msg.rs
* chore: fix compiler warnings in dc_mimeparser.rs
* chore: fix compiler warnings in dc_mimefactory.rs
* chore: fix compiler warnings in dc_lot.rs
* chore: fix compiler warnings in dc_loginparams.rs
* chore: fix compiler warnings in dc_log.rs
* chore: fix compiler warnings in dc_location.rs
* chore: fix compiler warnings in dc_keyring.rs
* chore: fix compiler warnings in dc_key.rs
* chore: fix compiler warnings in dc_jsmn.rs
* chore: fix compiler warnings in dc_jobthread.rs
* chore: fix compiler warnings in dc_imex.rs
* chore: fix compiler warnings in dc_hash.rs
* chore: fix compiler warnings in dc_e2ee.rs
* chore: fix compiler warnings in dc_context.rs
* chore: fix compiler warnings in dc_contact.rs
* chore: fix compiler warnings in dc_chatlist.rs
* chore: fix compiler warnings in dc_chat.rs
* chore: fix compiler warnings in dc_array.rs
* chore: fix compiler warnings in dc_apeerstate.rs
* chore: fix compiler warnings in dc_aheader.rs
* chore: fix compiler warnings in dc_array.rs
* test: remove compiler warnings in test/stress.rs
* test: reduce compiler warnings in examples/repl/main.rs
* test: std:🧵:sleep_ms() is deprecated
* chore: remove unused variable in dc_sqlite3.rs
* chore: fix compiler warnings in dc_receive_imf.rs
* chore: fix compiler warnings in dc_job.rs
* chore: fix compiler warnings in dc_configure.rs
* Fix formatting
This commit is contained in:
committed by
Friedel Ziegelmayer
parent
67f1d67de7
commit
2cf6cde5d1
@@ -16,7 +16,7 @@ pub struct dc_array_t {
|
||||
pub array: *mut uintptr_t,
|
||||
}
|
||||
|
||||
/* *
|
||||
/**
|
||||
* @class dc_array_t
|
||||
*
|
||||
* An object containing a simple array.
|
||||
@@ -35,6 +35,7 @@ pub unsafe fn dc_array_unref(mut array: *mut dc_array_t) {
|
||||
(*array).magic = 0i32 as uint32_t;
|
||||
free(array as *mut libc::c_void);
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_free_ptr(mut array: *mut dc_array_t) {
|
||||
if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint {
|
||||
return;
|
||||
@@ -52,6 +53,7 @@ pub unsafe fn dc_array_free_ptr(mut array: *mut dc_array_t) {
|
||||
i = i.wrapping_add(1)
|
||||
}
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_add_uint(mut array: *mut dc_array_t, mut item: uintptr_t) {
|
||||
if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint {
|
||||
return;
|
||||
@@ -70,24 +72,29 @@ pub unsafe fn dc_array_add_uint(mut array: *mut dc_array_t, mut item: uintptr_t)
|
||||
*(*array).array.offset((*array).count as isize) = item;
|
||||
(*array).count = (*array).count.wrapping_add(1);
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_add_id(mut array: *mut dc_array_t, mut item: uint32_t) {
|
||||
dc_array_add_uint(array, item as uintptr_t);
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_add_ptr(mut array: *mut dc_array_t, mut item: *mut libc::c_void) {
|
||||
dc_array_add_uint(array, item as uintptr_t);
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_get_cnt(mut array: *const dc_array_t) -> size_t {
|
||||
if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint {
|
||||
return 0i32 as size_t;
|
||||
}
|
||||
return (*array).count;
|
||||
(*array).count
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_get_uint(mut array: *const dc_array_t, mut index: size_t) -> uintptr_t {
|
||||
if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint || index >= (*array).count {
|
||||
return 0i32 as uintptr_t;
|
||||
}
|
||||
return *(*array).array.offset(index as isize);
|
||||
*(*array).array.offset(index as isize)
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_get_id(mut array: *const dc_array_t, mut index: size_t) -> uint32_t {
|
||||
if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint || index >= (*array).count {
|
||||
return 0i32 as uint32_t;
|
||||
@@ -95,8 +102,9 @@ pub unsafe fn dc_array_get_id(mut array: *const dc_array_t, mut index: size_t) -
|
||||
if (*array).type_0 == 1i32 {
|
||||
return (*(*(*array).array.offset(index as isize) as *mut _dc_location)).location_id;
|
||||
}
|
||||
return *(*array).array.offset(index as isize) as uint32_t;
|
||||
*(*array).array.offset(index as isize) as uint32_t
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_get_ptr(
|
||||
mut array: *const dc_array_t,
|
||||
mut index: size_t,
|
||||
@@ -104,8 +112,9 @@ pub unsafe fn dc_array_get_ptr(
|
||||
if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint || index >= (*array).count {
|
||||
return 0 as *mut libc::c_void;
|
||||
}
|
||||
return *(*array).array.offset(index as isize) as *mut libc::c_void;
|
||||
*(*array).array.offset(index as isize) as *mut libc::c_void
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_get_latitude(
|
||||
mut array: *const dc_array_t,
|
||||
mut index: size_t,
|
||||
@@ -118,8 +127,9 @@ pub unsafe fn dc_array_get_latitude(
|
||||
{
|
||||
return 0i32 as libc::c_double;
|
||||
}
|
||||
return (*(*(*array).array.offset(index as isize) as *mut _dc_location)).latitude;
|
||||
(*(*(*array).array.offset(index as isize) as *mut _dc_location)).latitude
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_get_longitude(
|
||||
mut array: *const dc_array_t,
|
||||
mut index: size_t,
|
||||
@@ -132,8 +142,9 @@ pub unsafe fn dc_array_get_longitude(
|
||||
{
|
||||
return 0i32 as libc::c_double;
|
||||
}
|
||||
return (*(*(*array).array.offset(index as isize) as *mut _dc_location)).longitude;
|
||||
(*(*(*array).array.offset(index as isize) as *mut _dc_location)).longitude
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_get_accuracy(
|
||||
mut array: *const dc_array_t,
|
||||
mut index: size_t,
|
||||
@@ -146,8 +157,9 @@ pub unsafe fn dc_array_get_accuracy(
|
||||
{
|
||||
return 0i32 as libc::c_double;
|
||||
}
|
||||
return (*(*(*array).array.offset(index as isize) as *mut _dc_location)).accuracy;
|
||||
(*(*(*array).array.offset(index as isize) as *mut _dc_location)).accuracy
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_get_timestamp(mut array: *const dc_array_t, mut index: size_t) -> time_t {
|
||||
if array.is_null()
|
||||
|| (*array).magic != 0xa11aai32 as libc::c_uint
|
||||
@@ -157,8 +169,9 @@ pub unsafe fn dc_array_get_timestamp(mut array: *const dc_array_t, mut index: si
|
||||
{
|
||||
return 0i32 as time_t;
|
||||
}
|
||||
return (*(*(*array).array.offset(index as isize) as *mut _dc_location)).timestamp;
|
||||
(*(*(*array).array.offset(index as isize) as *mut _dc_location)).timestamp
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_get_chat_id(mut array: *const dc_array_t, mut index: size_t) -> uint32_t {
|
||||
if array.is_null()
|
||||
|| (*array).magic != 0xa11aai32 as libc::c_uint
|
||||
@@ -168,8 +181,9 @@ pub unsafe fn dc_array_get_chat_id(mut array: *const dc_array_t, mut index: size
|
||||
{
|
||||
return 0i32 as uint32_t;
|
||||
}
|
||||
return (*(*(*array).array.offset(index as isize) as *mut _dc_location)).chat_id;
|
||||
(*(*(*array).array.offset(index as isize) as *mut _dc_location)).chat_id
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_get_contact_id(mut array: *const dc_array_t, mut index: size_t) -> uint32_t {
|
||||
if array.is_null()
|
||||
|| (*array).magic != 0xa11aai32 as libc::c_uint
|
||||
@@ -179,8 +193,9 @@ pub unsafe fn dc_array_get_contact_id(mut array: *const dc_array_t, mut index: s
|
||||
{
|
||||
return 0i32 as uint32_t;
|
||||
}
|
||||
return (*(*(*array).array.offset(index as isize) as *mut _dc_location)).contact_id;
|
||||
(*(*(*array).array.offset(index as isize) as *mut _dc_location)).contact_id
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_get_msg_id(mut array: *const dc_array_t, mut index: size_t) -> uint32_t {
|
||||
if array.is_null()
|
||||
|| (*array).magic != 0xa11aai32 as libc::c_uint
|
||||
@@ -190,8 +205,9 @@ pub unsafe fn dc_array_get_msg_id(mut array: *const dc_array_t, mut index: size_
|
||||
{
|
||||
return 0i32 as uint32_t;
|
||||
}
|
||||
return (*(*(*array).array.offset(index as isize) as *mut _dc_location)).msg_id;
|
||||
(*(*(*array).array.offset(index as isize) as *mut _dc_location)).msg_id
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_get_marker(
|
||||
mut array: *const dc_array_t,
|
||||
mut index: size_t,
|
||||
@@ -204,9 +220,7 @@ pub unsafe fn dc_array_get_marker(
|
||||
{
|
||||
return 0 as *mut libc::c_char;
|
||||
}
|
||||
return dc_strdup_keep_null(
|
||||
(*(*(*array).array.offset(index as isize) as *mut _dc_location)).marker,
|
||||
);
|
||||
dc_strdup_keep_null((*(*(*array).array.offset(index as isize) as *mut _dc_location)).marker)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -232,6 +246,7 @@ pub unsafe fn dc_array_is_independent(array: *const dc_array_t, index: size_t) -
|
||||
(*(*(*array).array.offset(index as isize) as *mut _dc_location)).independent as libc::c_int
|
||||
}
|
||||
|
||||
// TODO should return bool /rtn
|
||||
pub unsafe fn dc_array_search_id(
|
||||
mut array: *const dc_array_t,
|
||||
mut needle: uint32_t,
|
||||
@@ -243,7 +258,6 @@ pub unsafe fn dc_array_search_id(
|
||||
let mut data: *mut uintptr_t = (*array).array;
|
||||
let mut i: size_t = 0;
|
||||
let mut cnt: size_t = (*array).count;
|
||||
i = 0i32 as size_t;
|
||||
while i < cnt {
|
||||
if *data.offset(i as isize) == needle as size_t {
|
||||
if !ret_index.is_null() {
|
||||
@@ -253,14 +267,16 @@ pub unsafe fn dc_array_search_id(
|
||||
}
|
||||
i = i.wrapping_add(1)
|
||||
}
|
||||
return 0i32;
|
||||
0
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_get_raw(mut array: *const dc_array_t) -> *const uintptr_t {
|
||||
if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint {
|
||||
return 0 as *const uintptr_t;
|
||||
}
|
||||
return (*array).array;
|
||||
(*array).array
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_new(initsize: size_t) -> *mut dc_array_t {
|
||||
dc_array_new_typed(0, initsize)
|
||||
}
|
||||
@@ -269,7 +285,7 @@ pub unsafe extern "C" fn dc_array_new_typed(
|
||||
mut type_0: libc::c_int,
|
||||
mut initsize: size_t,
|
||||
) -> *mut dc_array_t {
|
||||
let mut array: *mut dc_array_t = 0 as *mut dc_array_t;
|
||||
let mut array: *mut dc_array_t;
|
||||
array = calloc(1, ::std::mem::size_of::<dc_array_t>()) as *mut dc_array_t;
|
||||
if array.is_null() {
|
||||
exit(47i32);
|
||||
@@ -295,8 +311,9 @@ pub unsafe fn dc_array_empty(mut array: *mut dc_array_t) {
|
||||
}
|
||||
(*array).count = 0i32 as size_t;
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_duplicate(mut array: *const dc_array_t) -> *mut dc_array_t {
|
||||
let mut ret: *mut dc_array_t = 0 as *mut dc_array_t;
|
||||
let mut ret: *mut dc_array_t;
|
||||
if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint {
|
||||
return 0 as *mut dc_array_t;
|
||||
}
|
||||
@@ -309,8 +326,9 @@ pub unsafe fn dc_array_duplicate(mut array: *const dc_array_t) -> *mut dc_array_
|
||||
.count
|
||||
.wrapping_mul(::std::mem::size_of::<uintptr_t>()),
|
||||
);
|
||||
return ret;
|
||||
ret
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_sort_ids(mut array: *mut dc_array_t) {
|
||||
if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint || (*array).count <= 1 {
|
||||
return;
|
||||
@@ -322,6 +340,7 @@ pub unsafe fn dc_array_sort_ids(mut array: *mut dc_array_t) {
|
||||
Some(cmp_intptr_t),
|
||||
);
|
||||
}
|
||||
|
||||
unsafe extern "C" fn cmp_intptr_t(
|
||||
mut p1: *const libc::c_void,
|
||||
mut p2: *const libc::c_void,
|
||||
@@ -336,6 +355,7 @@ unsafe extern "C" fn cmp_intptr_t(
|
||||
0i32
|
||||
};
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_sort_strings(mut array: *mut dc_array_t) {
|
||||
if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint || (*array).count <= 1 {
|
||||
return;
|
||||
@@ -347,19 +367,22 @@ pub unsafe fn dc_array_sort_strings(mut array: *mut dc_array_t) {
|
||||
Some(cmp_strings_t),
|
||||
);
|
||||
}
|
||||
|
||||
unsafe extern "C" fn cmp_strings_t(
|
||||
mut p1: *const libc::c_void,
|
||||
mut p2: *const libc::c_void,
|
||||
) -> libc::c_int {
|
||||
let mut v1: *const libc::c_char = *(p1 as *mut *const libc::c_char);
|
||||
let mut v2: *const libc::c_char = *(p2 as *mut *const libc::c_char);
|
||||
return strcmp(v1, v2);
|
||||
|
||||
strcmp(v1, v2)
|
||||
}
|
||||
|
||||
pub unsafe fn dc_array_get_string(
|
||||
mut array: *const dc_array_t,
|
||||
mut sep: *const libc::c_char,
|
||||
) -> *mut libc::c_char {
|
||||
let mut ret: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut ret: *mut libc::c_char;
|
||||
if array.is_null() || (*array).magic != 0xa11aai32 as libc::c_uint || sep.is_null() {
|
||||
return dc_strdup(b"\x00" as *const u8 as *const libc::c_char);
|
||||
}
|
||||
@@ -374,7 +397,6 @@ pub unsafe fn dc_array_get_string(
|
||||
exit(35i32);
|
||||
}
|
||||
*ret.offset(0isize) = 0i32 as libc::c_char;
|
||||
i = 0;
|
||||
while i < (*array).count {
|
||||
if 0 != i {
|
||||
strcat(ret, sep);
|
||||
@@ -386,19 +408,21 @@ pub unsafe fn dc_array_get_string(
|
||||
);
|
||||
i += 1
|
||||
}
|
||||
return ret;
|
||||
|
||||
ret
|
||||
}
|
||||
|
||||
pub unsafe fn dc_arr_to_string(
|
||||
mut arr: *const uint32_t,
|
||||
mut cnt: libc::c_int,
|
||||
) -> *mut libc::c_char {
|
||||
/* return comma-separated value-string from integer array */
|
||||
let mut ret: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut ret: *mut libc::c_char;
|
||||
let mut sep: *const libc::c_char = b",\x00" as *const u8 as *const libc::c_char;
|
||||
if arr.is_null() || cnt <= 0i32 {
|
||||
return dc_strdup(b"\x00" as *const u8 as *const libc::c_char);
|
||||
}
|
||||
let mut i: libc::c_int = 0;
|
||||
let mut i: libc::c_int;
|
||||
ret = malloc(
|
||||
(cnt as usize)
|
||||
.wrapping_mul((11usize).wrapping_add(strlen(sep)))
|
||||
@@ -420,5 +444,6 @@ pub unsafe fn dc_arr_to_string(
|
||||
);
|
||||
i += 1
|
||||
}
|
||||
return ret;
|
||||
|
||||
ret
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user