mirror of
https://github.com/chatmail/core.git
synced 2026-05-11 19:06: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
@@ -11,7 +11,7 @@ use crate::types::*;
|
||||
use crate::x::*;
|
||||
|
||||
/* prefer-encrypt states */
|
||||
/* *
|
||||
/**
|
||||
* @class dc_apeerstate_t
|
||||
* Library-internal.
|
||||
*/
|
||||
@@ -36,20 +36,22 @@ pub struct dc_apeerstate_t<'a> {
|
||||
|
||||
/* the returned pointer is ref'd and must be unref'd after usage */
|
||||
pub unsafe fn dc_apeerstate_new<'a>(context: &'a dc_context_t) -> *mut dc_apeerstate_t<'a> {
|
||||
let mut peerstate: *mut dc_apeerstate_t = 0 as *mut dc_apeerstate_t;
|
||||
let mut peerstate: *mut dc_apeerstate_t;
|
||||
peerstate = calloc(1, ::std::mem::size_of::<dc_apeerstate_t>()) as *mut dc_apeerstate_t;
|
||||
if peerstate.is_null() {
|
||||
exit(43i32);
|
||||
}
|
||||
(*peerstate).context = context;
|
||||
|
||||
return peerstate;
|
||||
peerstate
|
||||
}
|
||||
|
||||
pub unsafe fn dc_apeerstate_unref(mut peerstate: *mut dc_apeerstate_t) {
|
||||
dc_apeerstate_empty(peerstate);
|
||||
free(peerstate as *mut libc::c_void);
|
||||
}
|
||||
/* ******************************************************************************
|
||||
|
||||
/*******************************************************************************
|
||||
* dc_apeerstate_t represents the state of an Autocrypt peer - Load/save
|
||||
******************************************************************************/
|
||||
unsafe fn dc_apeerstate_empty(mut peerstate: *mut dc_apeerstate_t) {
|
||||
@@ -77,6 +79,8 @@ unsafe fn dc_apeerstate_empty(mut peerstate: *mut dc_apeerstate_t) {
|
||||
(*peerstate).verified_key = 0 as *mut dc_key_t;
|
||||
(*peerstate).degrade_event = 0i32;
|
||||
}
|
||||
|
||||
// TODO should return bool /rtn
|
||||
pub unsafe fn dc_apeerstate_init_from_header(
|
||||
mut peerstate: *mut dc_apeerstate_t,
|
||||
mut header: *const dc_aheader_t,
|
||||
@@ -94,8 +98,11 @@ pub unsafe fn dc_apeerstate_init_from_header(
|
||||
(*peerstate).public_key = dc_key_new();
|
||||
dc_key_set_from_key((*peerstate).public_key, (*header).public_key);
|
||||
dc_apeerstate_recalc_fingerprint(peerstate);
|
||||
return 1i32;
|
||||
|
||||
1
|
||||
}
|
||||
|
||||
// TODO should return bool /rtn
|
||||
pub unsafe fn dc_apeerstate_recalc_fingerprint(mut peerstate: *mut dc_apeerstate_t) -> libc::c_int {
|
||||
let mut success: libc::c_int = 0i32;
|
||||
let mut old_public_fingerprint: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||
@@ -139,10 +146,14 @@ pub unsafe fn dc_apeerstate_recalc_fingerprint(mut peerstate: *mut dc_apeerstate
|
||||
}
|
||||
success = 1i32
|
||||
}
|
||||
|
||||
free(old_public_fingerprint as *mut libc::c_void);
|
||||
free(old_gossip_fingerprint as *mut libc::c_void);
|
||||
return success;
|
||||
|
||||
success
|
||||
}
|
||||
|
||||
// TODO should return bool /rtn
|
||||
pub unsafe extern "C" fn dc_apeerstate_init_from_gossip(
|
||||
mut peerstate: *mut dc_apeerstate_t,
|
||||
mut gossip_header: *const dc_aheader_t,
|
||||
@@ -158,8 +169,11 @@ pub unsafe extern "C" fn dc_apeerstate_init_from_gossip(
|
||||
(*peerstate).gossip_key = dc_key_new();
|
||||
dc_key_set_from_key((*peerstate).gossip_key, (*gossip_header).public_key);
|
||||
dc_apeerstate_recalc_fingerprint(peerstate);
|
||||
return 1i32;
|
||||
|
||||
1
|
||||
}
|
||||
|
||||
// TODO should return bool /rtn
|
||||
pub unsafe fn dc_apeerstate_degrade_encryption(
|
||||
mut peerstate: *mut dc_apeerstate_t,
|
||||
mut message_time: time_t,
|
||||
@@ -173,8 +187,10 @@ pub unsafe fn dc_apeerstate_degrade_encryption(
|
||||
(*peerstate).prefer_encrypt = 20i32;
|
||||
(*peerstate).last_seen = message_time;
|
||||
(*peerstate).to_save |= 0x2i32;
|
||||
return 1i32;
|
||||
|
||||
1
|
||||
}
|
||||
|
||||
pub unsafe fn dc_apeerstate_apply_header(
|
||||
mut peerstate: *mut dc_apeerstate_t,
|
||||
mut header: *const dc_aheader_t,
|
||||
@@ -212,6 +228,7 @@ pub unsafe fn dc_apeerstate_apply_header(
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub unsafe fn dc_apeerstate_apply_gossip(
|
||||
mut peerstate: *mut dc_apeerstate_t,
|
||||
mut gossip_header: *const dc_aheader_t,
|
||||
@@ -239,6 +256,7 @@ pub unsafe fn dc_apeerstate_apply_gossip(
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub unsafe fn dc_apeerstate_render_gossip_header(
|
||||
mut peerstate: *const dc_apeerstate_t,
|
||||
mut min_verified: libc::c_int,
|
||||
@@ -252,8 +270,9 @@ pub unsafe fn dc_apeerstate_render_gossip_header(
|
||||
ret = dc_aheader_render(autocryptheader)
|
||||
}
|
||||
dc_aheader_unref(autocryptheader);
|
||||
return ret;
|
||||
ret
|
||||
}
|
||||
|
||||
pub unsafe fn dc_apeerstate_peek_key(
|
||||
mut peerstate: *const dc_apeerstate_t,
|
||||
mut min_verified: libc::c_int,
|
||||
@@ -277,8 +296,10 @@ pub unsafe fn dc_apeerstate_peek_key(
|
||||
if !(*peerstate).public_key.is_null() {
|
||||
return (*peerstate).public_key;
|
||||
}
|
||||
return (*peerstate).gossip_key;
|
||||
(*peerstate).gossip_key
|
||||
}
|
||||
|
||||
// TODO should return bool /rtn
|
||||
pub unsafe fn dc_apeerstate_set_verified(
|
||||
mut peerstate: *mut dc_apeerstate_t,
|
||||
mut which_key: libc::c_int,
|
||||
@@ -310,8 +331,11 @@ pub unsafe fn dc_apeerstate_set_verified(
|
||||
success = 1i32
|
||||
}
|
||||
}
|
||||
return success;
|
||||
|
||||
success
|
||||
}
|
||||
|
||||
// TODO should return bool /rtn
|
||||
pub unsafe fn dc_apeerstate_load_by_addr(
|
||||
mut peerstate: *mut dc_apeerstate_t,
|
||||
mut sql: &dc_sqlite3_t,
|
||||
@@ -334,8 +358,9 @@ pub unsafe fn dc_apeerstate_load_by_addr(
|
||||
}
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
return success;
|
||||
success
|
||||
}
|
||||
|
||||
unsafe fn dc_apeerstate_set_from_stmt(
|
||||
mut peerstate: *mut dc_apeerstate_t,
|
||||
mut stmt: *mut sqlite3_stmt,
|
||||
@@ -364,6 +389,8 @@ unsafe fn dc_apeerstate_set_from_stmt(
|
||||
dc_key_set_from_stmt((*peerstate).verified_key, stmt, 9i32, 0i32);
|
||||
};
|
||||
}
|
||||
|
||||
// TODO should return bool /rtn
|
||||
pub unsafe fn dc_apeerstate_load_by_fingerprint(
|
||||
mut peerstate: *mut dc_apeerstate_t,
|
||||
mut sql: &dc_sqlite3_t,
|
||||
@@ -388,8 +415,10 @@ pub unsafe fn dc_apeerstate_load_by_fingerprint(
|
||||
}
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
return success;
|
||||
success
|
||||
}
|
||||
|
||||
// TODO should return bool /rtn
|
||||
pub unsafe fn dc_apeerstate_save_to_db(
|
||||
mut peerstate: *const dc_apeerstate_t,
|
||||
mut sql: &dc_sqlite3_t,
|
||||
@@ -522,8 +551,11 @@ pub unsafe fn dc_apeerstate_save_to_db(
|
||||
_ => {}
|
||||
}
|
||||
sqlite3_finalize(stmt);
|
||||
return success;
|
||||
|
||||
success
|
||||
}
|
||||
|
||||
// TODO should return bool /rtn
|
||||
pub unsafe fn dc_apeerstate_has_verified_key(
|
||||
mut peerstate: *const dc_apeerstate_t,
|
||||
mut fingerprints: *const dc_hash_t,
|
||||
@@ -542,5 +574,6 @@ pub unsafe fn dc_apeerstate_has_verified_key(
|
||||
{
|
||||
return 1i32;
|
||||
}
|
||||
return 0i32;
|
||||
|
||||
0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user