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

@@ -196,9 +196,9 @@ unsafe extern "C" fn poke_spec(
let mut real_spec: *mut libc::c_char = 0 as *mut libc::c_char;
let mut suffix: *mut libc::c_char = 0 as *mut libc::c_char;
let mut dir: *mut DIR = 0 as *mut DIR;
let mut dir_entry: *mut dirent = 0 as *mut dirent;
let mut dir_entry: *mut dirent;
let mut read_cnt: libc::c_int = 0i32;
let mut name: *mut libc::c_char = 0 as *mut libc::c_char;
let mut name: *mut libc::c_char;
if 0 == dc_sqlite3_is_open(&context.sql.clone().read().unwrap()) {
dc_log_error(
context,
@@ -390,7 +390,6 @@ unsafe extern "C" fn log_msglist(mut context: &dc_context_t, mut msglist: *mut d
let mut i: libc::c_int = 0;
let mut cnt: libc::c_int = dc_array_get_cnt(msglist) as libc::c_int;
let mut lines_out: libc::c_int = 0i32;
i = 0i32;
while i < cnt {
let mut msg_id: uint32_t = dc_array_get_id(msglist, i as size_t);
if msg_id == 9i32 as libc::c_uint {
@@ -421,7 +420,7 @@ unsafe extern "C" fn log_msglist(mut context: &dc_context_t, mut msglist: *mut d
};
}
unsafe extern "C" fn log_contactlist(mut context: &dc_context_t, mut contacts: *mut dc_array_t) {
let mut contact: *mut dc_contact_t = 0 as *mut dc_contact_t;
let mut contact: *mut dc_contact_t;
let mut peerstate: *mut dc_apeerstate_t = dc_apeerstate_new(context);
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);
@@ -429,7 +428,7 @@ unsafe extern "C" fn log_contactlist(mut context: &dc_context_t, mut 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 line: *mut libc::c_char;
let mut line2: *mut libc::c_char = 0 as *mut libc::c_char;
contact = dc_get_contact(context, contact_id);
if !contact.is_null() {
@@ -462,7 +461,7 @@ unsafe extern "C" fn log_contactlist(mut context: &dc_context_t, mut contacts: *
let mut peerstate_ok: libc::c_int =
dc_apeerstate_load_by_addr(peerstate, &context.sql.clone().read().unwrap(), addr);
if 0 != peerstate_ok && contact_id != 1i32 as libc::c_uint {
let mut pe: *mut libc::c_char = 0 as *mut libc::c_char;
let mut pe: *mut libc::c_char;
match (*peerstate).prefer_encrypt {
1 => pe = dc_strdup(b"mutual\x00" as *const u8 as *const libc::c_char),
0 => pe = dc_strdup(b"no-preference\x00" as *const u8 as *const libc::c_char),
@@ -521,8 +520,8 @@ pub unsafe extern "C" fn dc_cmdline(
context: &mut dc_context_t,
cmdline: &str,
) -> *mut libc::c_char {
let mut cmd = 0 as *mut libc::c_char;
let mut arg1: *mut libc::c_char = 0 as *mut libc::c_char;
let mut cmd: *mut libc::c_char;
let mut arg1: *mut libc::c_char;
let mut ret: *mut libc::c_char = 1i32 as *mut libc::c_char;
let mut sel_chat: *mut dc_chat_t = 0 as *mut dc_chat_t;
@@ -699,7 +698,7 @@ pub unsafe extern "C" fn dc_cmdline(
b"%s/autocrypt-setup-message.html\x00" as *const u8 as *const libc::c_char,
context.get_blobdir(),
);
let mut file_content: *mut libc::c_char = 0 as *mut libc::c_char;
let mut file_content: *mut libc::c_char;
file_content = dc_render_setup_file(&context, setup_code_0);
if !file_content.is_null()
&& 0 != dc_write_file(
@@ -799,7 +798,7 @@ pub unsafe extern "C" fn dc_cmdline(
let mut chatlist: *mut dc_chatlist_t =
dc_get_chatlist(&context, listflags, arg1, 0i32 as uint32_t);
if !chatlist.is_null() {
let mut i: libc::c_int = 0;
let mut i: libc::c_int;
let mut cnt: libc::c_int = dc_chatlist_get_cnt(chatlist) as libc::c_int;
if cnt > 0i32 {
dc_log_info(&context, 0i32,
@@ -1347,7 +1346,7 @@ pub unsafe extern "C" fn dc_cmdline(
if !sel_chat.is_null() {
let mut images: *mut dc_array_t =
dc_get_chat_media(&context, dc_chat_get_id(sel_chat), 20i32, 21i32, 50i32);
let mut i_0: libc::c_int = 0;
let mut i_0: libc::c_int;
let mut icnt: libc::c_int = dc_array_get_cnt(images) as libc::c_int;
ret = dc_mprintf(
b"%i images or videos: \x00" as *const u8 as *const libc::c_char,
@@ -1707,7 +1706,6 @@ pub unsafe extern "C" fn dc_cmdline(
}
if !sel_chat.is_null() {
dc_chat_unref(sel_chat);
sel_chat = 0 as *mut dc_chat_t
}
free(cmd as *mut libc::c_void);
return ret;

View File

@@ -11,7 +11,6 @@
non_camel_case_types,
non_snake_case,
non_upper_case_globals,
unused_assignments,
unused_mut,
unused_attributes,
non_upper_case_globals,
@@ -294,7 +293,7 @@ unsafe fn start_threads(
}
});
let context = c.clone();
let _context = c.clone();
let h2 = std::thread::spawn(move || {
// let ctx = context.clone();
// let context = ctx.read().unwrap();
@@ -306,7 +305,7 @@ unsafe fn start_threads(
// }
});
let context = c.clone();
let _context = c.clone();
let h3 = std::thread::spawn(move || {
// let ctx = context.clone();
// let context = ctx.read().unwrap();
@@ -318,7 +317,7 @@ unsafe fn start_threads(
// }
});
let context = c.clone();
let _context = c.clone();
let h4 = std::thread::spawn(move || {
// let ctx = context.clone();
// let context = ctx.read().unwrap();
@@ -515,7 +514,6 @@ unsafe fn main_0(mut argc: libc::c_int, mut argv: *mut *mut libc::c_char) -> lib
let mut ctx = ctx.write().unwrap();
free(cmd as *mut libc::c_void);
stop_threads(&ctx, handles);
handles = None;
dc_close(&mut ctx);
dc_context_unref(&mut ctx);
}