mirror of
https://github.com/chatmail/core.git
synced 2026-04-25 17:36:30 +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
@@ -42,13 +42,13 @@ pub unsafe fn dc_e2ee_encrypt(
|
||||
mut in_out_message: *mut mailmime,
|
||||
mut helper: *mut dc_e2ee_helper_t,
|
||||
) {
|
||||
let mut p_0: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut p_0: *mut libc::c_char;
|
||||
let mut current_block: u64;
|
||||
let mut col: libc::c_int = 0i32;
|
||||
let mut do_encrypt: libc::c_int = 0i32;
|
||||
let mut autocryptheader: *mut dc_aheader_t = dc_aheader_new();
|
||||
/*just a pointer into mailmime structure, must not be freed*/
|
||||
let mut imffields_unprotected: *mut mailimf_fields = 0 as *mut mailimf_fields;
|
||||
let mut imffields_unprotected: *mut mailimf_fields;
|
||||
let mut keyring: *mut dc_keyring_t = dc_keyring_new();
|
||||
let mut sign_key: *mut dc_key_t = dc_key_new();
|
||||
let mut plain: *mut MMAPString = mmap_string_new(b"\x00" as *const u8 as *const libc::c_char);
|
||||
@@ -99,7 +99,7 @@ pub unsafe fn dc_e2ee_encrypt(
|
||||
/*only for random-seed*/
|
||||
if (*autocryptheader).prefer_encrypt == 1i32 || 0 != e2ee_guaranteed {
|
||||
do_encrypt = 1i32;
|
||||
let mut iter1: *mut clistiter = 0 as *mut clistiter;
|
||||
let mut iter1: *mut clistiter;
|
||||
iter1 = (*recipients_addr).first;
|
||||
while !iter1.is_null() {
|
||||
let mut recipient_addr: *const libc::c_char = (if !iter1.is_null() {
|
||||
@@ -394,7 +394,8 @@ pub unsafe fn dc_e2ee_encrypt(
|
||||
}
|
||||
dc_array_unref(peerstates);
|
||||
}
|
||||
/* ******************************************************************************
|
||||
|
||||
/*******************************************************************************
|
||||
* Tools
|
||||
******************************************************************************/
|
||||
unsafe fn new_data_part(
|
||||
@@ -405,15 +406,15 @@ unsafe fn new_data_part(
|
||||
) -> *mut mailmime {
|
||||
let mut current_block: u64;
|
||||
//char basename_buf[PATH_MAX];
|
||||
let mut encoding: *mut mailmime_mechanism = 0 as *mut mailmime_mechanism;
|
||||
let mut content: *mut mailmime_content = 0 as *mut mailmime_content;
|
||||
let mut mime: *mut mailmime = 0 as *mut mailmime;
|
||||
let mut encoding: *mut mailmime_mechanism;
|
||||
let mut content: *mut mailmime_content;
|
||||
let mut mime: *mut mailmime;
|
||||
//int r;
|
||||
//char * dup_filename;
|
||||
let mut mime_fields: *mut mailmime_fields = 0 as *mut mailmime_fields;
|
||||
let mut encoding_type: libc::c_int = 0;
|
||||
let mut content_type_str: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
let mut do_encoding: libc::c_int = 0;
|
||||
let mut mime_fields: *mut mailmime_fields;
|
||||
let mut encoding_type: libc::c_int;
|
||||
let mut content_type_str: *mut libc::c_char;
|
||||
let mut do_encoding: libc::c_int;
|
||||
encoding = 0 as *mut mailmime_mechanism;
|
||||
if default_content_type.is_null() {
|
||||
content_type_str =
|
||||
@@ -427,7 +428,7 @@ unsafe fn new_data_part(
|
||||
} else {
|
||||
do_encoding = 1i32;
|
||||
if (*(*content).ct_type).tp_type == MAILMIME_TYPE_COMPOSITE_TYPE as libc::c_int {
|
||||
let mut composite: *mut mailmime_composite_type = 0 as *mut mailmime_composite_type;
|
||||
let mut composite: *mut mailmime_composite_type;
|
||||
composite = (*(*content).ct_type).tp_data.tp_composite_type;
|
||||
match (*composite).ct_type {
|
||||
1 => {
|
||||
@@ -502,9 +503,11 @@ unsafe fn new_data_part(
|
||||
}
|
||||
return 0 as *mut mailmime;
|
||||
}
|
||||
/* ******************************************************************************
|
||||
|
||||
/*******************************************************************************
|
||||
* Generate Keypairs
|
||||
******************************************************************************/
|
||||
// TODO should return bool /rtn
|
||||
unsafe fn load_or_generate_self_public_key(
|
||||
mut context: &dc_context_t,
|
||||
mut public_key: *mut dc_key_t,
|
||||
@@ -514,7 +517,7 @@ unsafe fn load_or_generate_self_public_key(
|
||||
let mut current_block: u64;
|
||||
/* avoid double creation (we unlock the database during creation) */
|
||||
static mut s_in_key_creation: libc::c_int = 0i32;
|
||||
let mut key_created: libc::c_int = 0i32;
|
||||
let mut key_created: libc::c_int;
|
||||
let mut success: libc::c_int = 0i32;
|
||||
let mut key_creation_here: libc::c_int = 0i32;
|
||||
if !public_key.is_null() {
|
||||
@@ -531,7 +534,7 @@ unsafe fn load_or_generate_self_public_key(
|
||||
key_creation_here = 1i32;
|
||||
s_in_key_creation = 1i32;
|
||||
if !random_data_mime.is_null() {
|
||||
let mut random_data_mmap: *mut MMAPString = 0 as *mut MMAPString;
|
||||
let mut random_data_mmap: *mut MMAPString;
|
||||
let mut col: libc::c_int = 0i32;
|
||||
random_data_mmap = mmap_string_new(b"\x00" as *const u8 as *const libc::c_char);
|
||||
if random_data_mmap.is_null() {
|
||||
@@ -619,15 +622,17 @@ unsafe fn load_or_generate_self_public_key(
|
||||
if 0 != key_creation_here {
|
||||
s_in_key_creation = 0i32
|
||||
}
|
||||
return success;
|
||||
|
||||
success
|
||||
}
|
||||
|
||||
/* returns 1 if sth. was decrypted, 0 in other cases */
|
||||
pub unsafe fn dc_e2ee_decrypt(
|
||||
mut context: &dc_context_t,
|
||||
mut in_out_message: *mut mailmime,
|
||||
mut helper: *mut dc_e2ee_helper_t,
|
||||
) {
|
||||
let mut iterations: libc::c_int = 0;
|
||||
let mut iterations: libc::c_int;
|
||||
/* return values: 0=nothing to decrypt/cannot decrypt, 1=sth. decrypted
|
||||
(to detect parts that could not be decrypted, simply look for left "multipart/encrypted" MIME types */
|
||||
/*just a pointer into mailmime structure, must not be freed*/
|
||||
@@ -761,13 +766,14 @@ pub unsafe fn dc_e2ee_decrypt(
|
||||
free(from as *mut libc::c_void);
|
||||
free(self_addr as *mut libc::c_void);
|
||||
}
|
||||
|
||||
unsafe fn update_gossip_peerstates(
|
||||
mut context: &dc_context_t,
|
||||
mut message_time: time_t,
|
||||
mut imffields: *mut mailimf_fields,
|
||||
mut gossip_headers: *const mailimf_fields,
|
||||
) -> *mut dc_hash_t {
|
||||
let mut cur1: *mut clistiter = 0 as *mut clistiter;
|
||||
let mut cur1: *mut clistiter;
|
||||
let mut recipients: *mut dc_hash_t = 0 as *mut dc_hash_t;
|
||||
let mut gossipped_addr: *mut dc_hash_t = 0 as *mut dc_hash_t;
|
||||
cur1 = (*(*gossip_headers).fld_list).first;
|
||||
@@ -859,8 +865,11 @@ unsafe fn update_gossip_peerstates(
|
||||
dc_hash_clear(recipients);
|
||||
free(recipients as *mut libc::c_void);
|
||||
}
|
||||
return gossipped_addr;
|
||||
|
||||
gossipped_addr
|
||||
}
|
||||
|
||||
// TODO should return bool /rtn
|
||||
unsafe fn decrypt_recursive(
|
||||
mut context: &dc_context_t,
|
||||
mut mime: *mut mailmime,
|
||||
@@ -870,8 +879,8 @@ unsafe fn decrypt_recursive(
|
||||
mut ret_gossip_headers: *mut *mut mailimf_fields,
|
||||
mut ret_has_unencrypted_parts: *mut libc::c_int,
|
||||
) -> libc::c_int {
|
||||
let mut ct: *mut mailmime_content = 0 as *mut mailmime_content;
|
||||
let mut cur: *mut clistiter = 0 as *mut clistiter;
|
||||
let mut ct: *mut mailmime_content;
|
||||
let mut cur: *mut clistiter;
|
||||
if mime.is_null() {
|
||||
return 0i32;
|
||||
}
|
||||
@@ -964,8 +973,10 @@ unsafe fn decrypt_recursive(
|
||||
} else {
|
||||
*ret_has_unencrypted_parts = 1i32
|
||||
}
|
||||
return 0i32;
|
||||
|
||||
0
|
||||
}
|
||||
|
||||
unsafe fn decrypt_part(
|
||||
mut context: &dc_context_t,
|
||||
mut mime: *mut mailmime,
|
||||
@@ -974,9 +985,9 @@ unsafe fn decrypt_part(
|
||||
mut ret_valid_signatures: *mut dc_hash_t,
|
||||
mut ret_decrypted_mime: *mut *mut mailmime,
|
||||
) -> libc::c_int {
|
||||
let mut add_signatures: *mut dc_hash_t = 0 as *mut dc_hash_t;
|
||||
let mut add_signatures: *mut dc_hash_t;
|
||||
let mut current_block: u64;
|
||||
let mut mime_data: *mut mailmime_data = 0 as *mut mailmime_data;
|
||||
let mut mime_data: *mut mailmime_data;
|
||||
let mut mime_transfer_encoding: libc::c_int = MAILMIME_MECHANISM_BINARY as libc::c_int;
|
||||
/* mmap_string_unref()'d if set */
|
||||
let mut transfer_decoding_buffer: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
@@ -994,7 +1005,7 @@ unsafe fn decrypt_part(
|
||||
|| (*mime_data).dt_data.dt_text.dt_length <= 0)
|
||||
{
|
||||
if !(*mime).mm_mime_fields.is_null() {
|
||||
let mut cur: *mut clistiter = 0 as *mut clistiter;
|
||||
let mut cur: *mut clistiter;
|
||||
cur = (*(*(*mime).mm_mime_fields).fld_list).first;
|
||||
while !cur.is_null() {
|
||||
let mut field: *mut mailmime_field = (if !cur.is_null() {
|
||||
@@ -1030,7 +1041,7 @@ unsafe fn decrypt_part(
|
||||
current_block = 4488286894823169796;
|
||||
}
|
||||
} else {
|
||||
let mut r: libc::c_int = 0;
|
||||
let mut r: libc::c_int;
|
||||
let mut current_index: size_t = 0i32 as size_t;
|
||||
r = mailmime_part_parse(
|
||||
(*mime_data).dt_data.dt_text.dt_data,
|
||||
@@ -1105,11 +1116,14 @@ unsafe fn decrypt_part(
|
||||
if !transfer_decoding_buffer.is_null() {
|
||||
mmap_string_unref(transfer_decoding_buffer);
|
||||
}
|
||||
return sth_decrypted;
|
||||
|
||||
sth_decrypted
|
||||
}
|
||||
/* ******************************************************************************
|
||||
|
||||
/*******************************************************************************
|
||||
* Decrypt
|
||||
******************************************************************************/
|
||||
// TODO should return bool /rtn
|
||||
unsafe fn has_decrypted_pgp_armor(
|
||||
mut str__: *const libc::c_char,
|
||||
mut str_bytes: libc::c_int,
|
||||
@@ -1133,9 +1147,11 @@ unsafe fn has_decrypted_pgp_armor(
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
||||
0
|
||||
}
|
||||
/* *
|
||||
|
||||
/**
|
||||
* Check if a MIME structure contains a multipart/report part.
|
||||
*
|
||||
* As reports are often unencrypted, we do not reset the Autocrypt header in
|
||||
@@ -1149,6 +1165,7 @@ unsafe fn has_decrypted_pgp_armor(
|
||||
* @param mime The mime struture to check
|
||||
* @return 1=multipart/report found in MIME, 0=no multipart/report found
|
||||
*/
|
||||
// TODO should return bool /rtn
|
||||
unsafe fn contains_report(mut mime: *mut mailmime) -> libc::c_int {
|
||||
if (*mime).mm_type == MAILMIME_MULTIPLE as libc::c_int {
|
||||
if (*(*(*mime).mm_content_type).ct_type).tp_type
|
||||
@@ -1165,7 +1182,7 @@ unsafe fn contains_report(mut mime: *mut mailmime) -> libc::c_int {
|
||||
{
|
||||
return 1i32;
|
||||
}
|
||||
let mut cur: *mut clistiter = 0 as *mut clistiter;
|
||||
let mut cur: *mut clistiter;
|
||||
cur = (*(*mime).mm_data.mm_multipart.mm_mp_list).first;
|
||||
while !cur.is_null() {
|
||||
if 0 != contains_report(
|
||||
@@ -1188,8 +1205,10 @@ unsafe fn contains_report(mut mime: *mut mailmime) -> libc::c_int {
|
||||
return 1i32;
|
||||
}
|
||||
}
|
||||
return 0i32;
|
||||
|
||||
0
|
||||
}
|
||||
|
||||
/* frees data referenced by "mailmime" but not freed by mailmime_free(). After calling this function, in_out_message cannot be used any longer! */
|
||||
pub unsafe fn dc_e2ee_thanks(mut helper: *mut dc_e2ee_helper_t) {
|
||||
if helper.is_null() {
|
||||
@@ -1208,7 +1227,9 @@ pub unsafe fn dc_e2ee_thanks(mut helper: *mut dc_e2ee_helper_t) {
|
||||
(*helper).signatures = 0 as *mut dc_hash_t
|
||||
};
|
||||
}
|
||||
|
||||
/* makes sure, the private key exists, needed only for exporting keys and the case no message was sent before */
|
||||
// TODO should return bool /rtn
|
||||
pub unsafe fn dc_ensure_secret_key_exists(mut context: &dc_context_t) -> libc::c_int {
|
||||
/* normally, the key is generated as soon as the first mail is send
|
||||
(this is to gain some extra-random-seed by the message content and the timespan between program start and message sending) */
|
||||
@@ -1238,5 +1259,6 @@ pub unsafe fn dc_ensure_secret_key_exists(mut context: &dc_context_t) -> libc::c
|
||||
}
|
||||
dc_key_unref(public_key);
|
||||
free(self_addr as *mut libc::c_void);
|
||||
return success;
|
||||
|
||||
success
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user