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:
Lars-Magnus Skog
2019-05-05 21:58:59 +02:00
committed by Friedel Ziegelmayer
parent 67f1d67de7
commit 2cf6cde5d1
40 changed files with 1635 additions and 888 deletions

View File

@@ -12,6 +12,7 @@ use crate::x::*;
pub unsafe fn dc_pgp_exit() {}
// TODO should return bool /rtn
pub unsafe fn dc_split_armored_data(
mut buf: *mut libc::c_char,
mut ret_headerline: *mut *const libc::c_char,
@@ -23,7 +24,7 @@ pub unsafe fn dc_split_armored_data(
let mut line_chars: size_t = 0i32 as size_t;
let mut line: *mut libc::c_char = buf;
let mut p1: *mut libc::c_char = buf;
let mut p2: *mut libc::c_char = 0 as *mut libc::c_char;
let mut p2: *mut libc::c_char;
let mut headerline: *mut libc::c_char = 0 as *mut libc::c_char;
let mut base64: *mut libc::c_char = 0 as *mut libc::c_char;
if !ret_headerline.is_null() {
@@ -126,9 +127,12 @@ pub unsafe fn dc_split_armored_data(
}
}
}
return success;
success
}
/* public key encryption */
// TODO should return bool /rtn
pub unsafe fn dc_pgp_create_keypair(
mut context: &dc_context_t,
mut addr: *const libc::c_char,
@@ -136,11 +140,11 @@ pub unsafe fn dc_pgp_create_keypair(
mut ret_private_key: *mut dc_key_t,
) -> libc::c_int {
let mut success: libc::c_int = 0i32;
let mut skey: *mut rpgp::signed_secret_key = 0 as *mut rpgp::signed_secret_key;
let mut skey: *mut rpgp::signed_secret_key;
let mut pkey: *mut rpgp::signed_public_key = 0 as *mut rpgp::signed_public_key;
let mut skey_bytes: *mut rpgp::cvec = 0 as *mut rpgp::cvec;
let mut pkey_bytes: *mut rpgp::cvec = 0 as *mut rpgp::cvec;
let mut user_id: *mut libc::c_char = 0 as *mut libc::c_char;
let mut user_id: *mut libc::c_char;
user_id = dc_mprintf(b"<%s>\x00" as *const u8 as *const libc::c_char, addr);
skey = rpgp::rpgp_create_rsa_skey(2048i32 as uint32_t, user_id);
if !(0 != dc_pgp_handle_rpgp_error(context)) {
@@ -187,12 +191,15 @@ pub unsafe fn dc_pgp_create_keypair(
if !user_id.is_null() {
free(user_id as *mut libc::c_void);
}
return success;
success
}
/* returns 0 if there is no error, otherwise logs the error if a context is provided and returns 1*/
// TODO should return bool /rtn
pub unsafe fn dc_pgp_handle_rpgp_error(mut context: &dc_context_t) -> libc::c_int {
let mut success: libc::c_int = 0i32;
let mut len: libc::c_int = 0i32;
let mut len: libc::c_int;
let mut msg: *mut libc::c_char = 0 as *mut libc::c_char;
len = rpgp::rpgp_last_error_length();
if !(len == 0i32) {
@@ -208,8 +215,11 @@ pub unsafe fn dc_pgp_handle_rpgp_error(mut context: &dc_context_t) -> libc::c_in
if !msg.is_null() {
rpgp::rpgp_string_drop(msg);
}
return success;
success
}
// TODO should return bool /rtn
pub unsafe fn dc_pgp_is_valid_key(
mut context: &dc_context_t,
mut raw_key: *const dc_key_t,
@@ -233,8 +243,11 @@ pub unsafe fn dc_pgp_is_valid_key(
if !key.is_null() {
rpgp::rpgp_key_drop(key);
}
return key_is_valid;
key_is_valid
}
// TODO should return bool /rtn
pub unsafe fn dc_pgp_calc_fingerprint(
context: &dc_context_t,
raw_key: *const dc_key_t,
@@ -276,8 +289,11 @@ pub unsafe fn dc_pgp_calc_fingerprint(
if !fingerprint.is_null() {
rpgp::rpgp_cvec_drop(fingerprint);
}
return success;
success
}
// TODO should return bool /rtn
pub unsafe fn dc_pgp_split_key(
mut context: &dc_context_t,
mut private_in: *const dc_key_t,
@@ -325,8 +341,11 @@ pub unsafe fn dc_pgp_split_key(
if !buf.is_null() {
rpgp::rpgp_cvec_drop(buf);
}
return success;
success
}
// TODO should return bool /rtn
pub unsafe fn dc_pgp_pk_encrypt(
mut context: &dc_context_t,
mut plain_text: *const libc::c_void,
@@ -338,7 +357,7 @@ pub unsafe fn dc_pgp_pk_encrypt(
mut ret_ctext_bytes: *mut size_t,
) -> libc::c_int {
let mut current_block: u64;
let mut i: libc::c_int = 0i32;
let mut i: libc::c_int;
let mut success: libc::c_int = 0i32;
let mut public_keys_len: libc::c_int = 0i32;
let mut public_keys: *mut *mut rpgp::signed_public_key = 0 as *mut *mut rpgp::signed_public_key;
@@ -406,7 +425,7 @@ pub unsafe fn dc_pgp_pk_encrypt(
2132137392766895896 => {}
_ => {
/* sign & encrypt */
let mut op_clocks: libc::clock_t = 0i32 as libc::clock_t;
let mut op_clocks: libc::clock_t;
let mut start: libc::clock_t = clock();
if private_key.is_null() {
encrypted = rpgp::rpgp_encrypt_bytes_to_keys(
@@ -493,8 +512,11 @@ pub unsafe fn dc_pgp_pk_encrypt(
if !encrypted.is_null() {
rpgp::rpgp_msg_drop(encrypted);
}
return success;
success
}
// TODO should return bool /rtn
pub unsafe fn dc_pgp_pk_decrypt(
mut context: &dc_context_t,
mut ctext: *const libc::c_void,
@@ -507,7 +529,7 @@ pub unsafe fn dc_pgp_pk_decrypt(
mut ret_signature_fingerprints: *mut dc_hash_t,
) -> libc::c_int {
let mut current_block: u64;
let mut i: libc::c_int = 0i32;
let mut i: libc::c_int;
let mut success: libc::c_int = 0i32;
let mut encrypted: *mut rpgp::Message = 0 as *mut rpgp::Message;
let mut decrypted: *mut rpgp::message_decrypt_result = 0 as *mut rpgp::message_decrypt_result;
@@ -654,9 +676,12 @@ pub unsafe fn dc_pgp_pk_decrypt(
if !decrypted.is_null() {
rpgp::rpgp_message_decrypt_result_drop(decrypted);
}
return success;
success
}
/* symm. encryption */
// TODO should return bool /rtn
pub unsafe fn dc_pgp_symm_encrypt(
mut context: &dc_context_t,
mut passphrase: *const libc::c_char,
@@ -686,8 +711,11 @@ pub unsafe fn dc_pgp_symm_encrypt(
if !decrypted.is_null() {
rpgp::rpgp_msg_drop(decrypted);
}
return success;
success
}
// TODO should return bool /rtn
pub unsafe fn dc_pgp_symm_decrypt(
mut context: &dc_context_t,
mut passphrase: *const libc::c_char,
@@ -696,9 +724,9 @@ pub unsafe fn dc_pgp_symm_decrypt(
mut ret_plain_text: *mut *mut libc::c_void,
mut ret_plain_bytes: *mut size_t,
) -> libc::c_int {
let mut decrypted_bytes: *mut rpgp::cvec = 0 as *mut rpgp::cvec;
let mut decrypted_bytes: *mut rpgp::cvec;
let mut success: libc::c_int = 0i32;
let mut encrypted: *mut rpgp::Message = 0 as *mut rpgp::Message;
let mut encrypted: *mut rpgp::Message;
let mut decrypted: *mut rpgp::Message = 0 as *mut rpgp::Message;
encrypted = rpgp::rpgp_msg_from_bytes(ctext as *const uint8_t, ctext_bytes as usize);
if !(0 != dc_pgp_handle_rpgp_error(context)) {
@@ -719,5 +747,6 @@ pub unsafe fn dc_pgp_symm_decrypt(
if !decrypted.is_null() {
rpgp::rpgp_msg_drop(decrypted);
}
return success;
success
}