Override `non_shake_case' warning on per-function basis

This change removes global override of `non_shake_case' warning and replaces it
with per-function overrrides. This way, compiler will complain about style
guide violation in new code.

It should be noted, that `rustc' is not smart enough to emit warning when
override is no longer needed, it must be checked manually.
This commit is contained in:
Dmitry Bogatov
2019-07-28 01:21:42 +00:00
committed by Floris Bruynooghe
parent 39cc93240f
commit c6ccfd824e
15 changed files with 51 additions and 3 deletions

View File

@@ -533,6 +533,7 @@ pub fn dc_get_fresh_msgs(context: &Context) -> *mut dc_array_t {
.unwrap()
}
#[allow(non_snake_case)]
pub fn dc_search_msgs(
context: &Context,
chat_id: uint32_t,

View File

@@ -380,6 +380,7 @@ pub fn msgtype_has_file(msgtype: i32) -> bool {
}
}
#[allow(non_snake_case)]
unsafe fn prepare_msg_common<'a>(
context: &'a Context,
chat_id: uint32_t,
@@ -468,6 +469,7 @@ unsafe fn prepare_msg_common<'a>(
(*msg).id
}
#[allow(non_snake_case)]
unsafe fn prepare_msg_raw(
context: &Context,
chat: *mut Chat,
@@ -997,6 +999,7 @@ pub unsafe fn dc_set_draft(context: &Context, chat_id: uint32_t, msg: *mut dc_ms
}
// TODO should return bool /rtn
#[allow(non_snake_case)]
unsafe fn set_draft_raw(context: &Context, chat_id: uint32_t, msg: *mut dc_msg_t) -> libc::c_int {
let mut OK_TO_CONTINUE = true;
// similar to as dc_set_draft() but does not emit an event
@@ -1554,6 +1557,7 @@ pub unsafe fn dc_add_contact_to_chat(
}
// TODO should return bool /rtn
#[allow(non_snake_case)]
pub unsafe fn dc_add_contact_to_chat_ex(
context: &Context,
chat_id: u32,
@@ -1880,6 +1884,7 @@ pub unsafe fn dc_set_chat_name(
}
// TODO should return bool /rtn
#[allow(non_snake_case)]
pub unsafe fn dc_set_chat_profile_image(
context: &Context,
chat_id: uint32_t,

View File

@@ -99,6 +99,7 @@ pub fn dc_stop_ongoing_process(context: &Context) {
}
// the other dc_job_do_DC_JOB_*() functions are declared static in the c-file
#[allow(non_snake_case)]
pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_job_t) {
let flags: libc::c_int;
let mut current_block: u64;

View File

@@ -454,6 +454,7 @@ pub fn dc_add_or_lookup_contact(
row_id
}
#[allow(non_snake_case)]
pub unsafe fn dc_add_address_book(context: &Context, adr_book: *const libc::c_char) -> libc::c_int {
let mut lines: *mut carray = 0 as *mut carray;
let mut i: size_t;
@@ -526,6 +527,7 @@ pub unsafe fn dc_normalize_name(full_name: *mut libc::c_char) {
};
}
#[allow(non_snake_case)]
pub fn dc_get_contacts(
context: &Context,
listflags: u32,

View File

@@ -54,6 +54,7 @@ impl Default for dc_e2ee_helper_t {
}
}
#[allow(non_snake_case)]
pub unsafe fn dc_e2ee_encrypt(
context: &Context,
recipients_addr: *const clist,

View File

@@ -536,6 +536,7 @@ pub unsafe fn dc_normalize_setup_code(
to_cstring(out)
}
#[allow(non_snake_case)]
pub unsafe fn dc_job_do_DC_JOB_IMEX_IMAP(context: &Context, job: *mut dc_job_t) {
let mut current_block: u64;
let mut success: libc::c_int = 0i32;
@@ -767,6 +768,7 @@ pub unsafe fn dc_job_do_DC_JOB_IMEX_IMAP(context: &Context, job: *mut dc_job_t)
******************************************************************************/
// TODO should return bool /rtn
#[allow(non_snake_case)]
unsafe fn import_backup(context: &Context, backup_to_import: *const libc::c_char) -> libc::c_int {
info!(
context,
@@ -885,6 +887,7 @@ unsafe fn import_backup(context: &Context, backup_to_import: *const libc::c_char
/* the FILE_PROGRESS macro calls the callback with the permille of files processed.
The macro avoids weird values of 0% or 100% while still working. */
// TODO should return bool /rtn
#[allow(non_snake_case)]
unsafe fn export_backup(context: &Context, dir: *const libc::c_char) -> libc::c_int {
let mut current_block: u64;
let mut success: libc::c_int = 0;

View File

@@ -240,6 +240,7 @@ fn dc_job_delete(context: &Context, job: &dc_job_t) -> bool {
/* ******************************************************************************
* Tools
******************************************************************************/
#[allow(non_snake_case)]
unsafe fn get_backoff_time_offset(c_tries: libc::c_int) -> i64 {
// results in ~3 weeks for the last backoff timespan
let mut N = 2_i32.pow((c_tries - 1) as u32);
@@ -279,6 +280,8 @@ unsafe fn dc_suspend_smtp_thread(context: &Context, suspend: libc::c_int) {
}
}
}
#[allow(non_snake_case)]
unsafe fn dc_job_do_DC_JOB_SEND(context: &Context, job: &mut dc_job_t) {
let mut current_block: u64;
let mut filename: *mut libc::c_char = 0 as *mut libc::c_char;
@@ -409,6 +412,7 @@ pub unsafe fn dc_job_try_again_later(
job.pending_error = dc_strdup_keep_null(pending_error);
}
#[allow(non_snake_case)]
unsafe fn dc_job_do_DC_JOB_MOVE_MSG(context: &Context, job: &mut dc_job_t) {
let mut current_block: u64;
let msg = dc_msg_new_untyped(context);
@@ -505,6 +509,7 @@ fn connect_to_inbox(context: &Context, inbox: &Imap) -> libc::c_int {
ret_connected
}
#[allow(non_snake_case)]
unsafe fn dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP(context: &Context, job: &mut dc_job_t) {
let current_block: u64;
let folder: *mut libc::c_char = dc_param_get(
@@ -557,6 +562,7 @@ unsafe fn dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP(context: &Context, job: &mut dc_
free(folder as *mut libc::c_void);
}
#[allow(non_snake_case)]
unsafe fn dc_job_do_DC_JOB_MARKSEEN_MSG_ON_IMAP(context: &Context, job: &mut dc_job_t) {
let mut current_block: u64;
let msg: *mut dc_msg_t = dc_msg_new_untyped(context);
@@ -741,6 +747,7 @@ unsafe fn dc_send_mdn(context: &Context, msg_id: uint32_t) {
* @param mimefactory An instance of dc_mimefactory_t with a loaded and rendered message or MDN
* @return 1=success, 0=error
*/
#[allow(non_snake_case)]
unsafe fn dc_add_smtp_job(
context: &Context,
action: libc::c_int,
@@ -863,6 +870,7 @@ pub unsafe fn dc_interrupt_imap_idle(context: &Context) {
context.inbox.read().unwrap().interrupt_idle();
}
#[allow(non_snake_case)]
unsafe fn dc_job_do_DC_JOB_DELETE_MSG_ON_IMAP(context: &Context, job: &mut dc_job_t) {
let mut current_block: u64;
let mut delete_from_server: libc::c_int = 1i32;
@@ -1141,6 +1149,7 @@ pub fn dc_job_action_exists(context: &Context, action: libc::c_int) -> bool {
}
/* special case for DC_JOB_SEND_MSG_TO_SMTP */
#[allow(non_snake_case)]
pub unsafe fn dc_job_send_msg(context: &Context, msg_id: uint32_t) -> libc::c_int {
let mut success = 0;
let mut mimefactory = dc_mimefactory_t {

View File

@@ -138,6 +138,7 @@ pub unsafe fn dc_send_locations_to_chat(
/*******************************************************************************
* job to send locations out to all chats that want them
******************************************************************************/
#[allow(non_snake_case)]
unsafe fn schedule_MAYBE_SEND_LOCATIONS(context: &Context, flags: libc::c_int) {
if 0 != flags & 0x1 || !dc_job_action_exists(context, 5005) {
dc_job_add(context, 5005, 0, 0 as *const libc::c_char, 60);
@@ -641,6 +642,7 @@ pub unsafe fn dc_kml_unref(kml: *mut dc_kml_t) {
free((*kml).addr as *mut libc::c_void);
}
#[allow(non_snake_case)]
pub unsafe fn dc_job_do_DC_JOB_MAYBE_SEND_LOCATIONS(context: &Context, _job: *mut dc_job_t) {
let now = time();
let mut continue_streaming: libc::c_int = 1;
@@ -721,6 +723,7 @@ pub unsafe fn dc_job_do_DC_JOB_MAYBE_SEND_LOCATIONS(context: &Context, _job: *mu
}
}
#[allow(non_snake_case)]
pub unsafe fn dc_job_do_DC_JOB_MAYBE_SEND_LOC_ENDED(context: &Context, job: &mut dc_job_t) {
// this function is called when location-streaming _might_ have ended for a chat.
// the function checks, if location-streaming is really ended;

View File

@@ -1182,6 +1182,7 @@ unsafe fn build_body_text(text: *mut libc::c_char) -> *mut mailmime {
message_part
}
#[allow(non_snake_case)]
unsafe fn build_body_file(
msg: *const dc_msg_t,
mut base_name: *const libc::c_char,
@@ -1350,7 +1351,7 @@ unsafe fn build_body_file(
/*******************************************************************************
* Render
******************************************************************************/
#[allow(non_snake_case)]
unsafe fn is_file_size_okay(msg: *const dc_msg_t) -> libc::c_int {
let mut file_size_okay: libc::c_int = 1;
let pathNfilename: *mut libc::c_char =

View File

@@ -1448,6 +1448,7 @@ unsafe fn dc_mimeparser_add_single_part_if_known(
};
}
#[allow(non_snake_case)]
unsafe fn do_add_single_file_part(
parser: &dc_mimeparser_t,
msg_type: libc::c_int,
@@ -1755,6 +1756,7 @@ pub unsafe fn mailimf_get_recipients(imffields: *mut mailimf_fields) -> HashSet<
/* ******************************************************************************
* low-level-tools for getting a list of all recipients
******************************************************************************/
#[allow(non_snake_case)]
unsafe fn mailimf_get_recipients__add_addr(
recipients: &mut HashSet<String>,
mb: *mut mailimf_mailbox,

View File

@@ -300,6 +300,7 @@ pub unsafe fn dc_msg_get_filemime(msg: *const dc_msg_t) -> *mut libc::c_char {
};
}
#[allow(non_snake_case)]
pub unsafe fn dc_msg_guess_msgtype_from_suffix(
pathNfilename: *const libc::c_char,
mut ret_msgtype: *mut libc::c_int,
@@ -708,6 +709,7 @@ pub unsafe fn dc_msg_get_text(msg: *const dc_msg_t) -> *mut libc::c_char {
to_cstring(res)
}
#[allow(non_snake_case)]
pub unsafe fn dc_msg_get_filename(msg: *const dc_msg_t) -> *mut libc::c_char {
let mut ret: *mut libc::c_char = 0 as *mut libc::c_char;
let mut pathNfilename: *mut libc::c_char = 0 as *mut libc::c_char;
@@ -831,6 +833,7 @@ pub unsafe fn dc_msg_get_summarytext(
}
/* the returned value must be free()'d */
#[allow(non_snake_case)]
pub unsafe fn dc_msg_get_summarytext_by_raw(
type_0: libc::c_int,
text: *const libc::c_char,

View File

@@ -917,6 +917,7 @@ which tries to create or find out the chat_id by:
So when the function returns, the caller has the group id matching the current
state of the group. */
#[allow(non_snake_case)]
unsafe fn create_or_lookup_group(
context: &Context,
mime_parser: &mut dc_mimeparser_t,
@@ -1540,6 +1541,7 @@ fn hex_hash(s: impl AsRef<str>) -> *const libc::c_char {
unsafe { to_cstring(result_hex) as *const _ }
}
#[allow(non_snake_case)]
unsafe fn search_chat_ids_by_contact_ids(
context: &Context,
unsorted_contact_ids: *const dc_array_t,

View File

@@ -61,6 +61,7 @@ impl dc_simplify_t {
/**
* Simplify Plain Text
*/
#[allow(non_snake_case)]
unsafe fn simplify_plain_text(
&mut self,
buf_terminated: *const libc::c_char,

View File

@@ -359,6 +359,7 @@ pub fn dc_truncate_str(buf: &str, approx_chars: usize) -> Cow<str> {
}
}
#[allow(non_snake_case)]
pub unsafe fn dc_truncate_n_unwrap_str(
buf: *mut libc::c_char,
approx_characters: libc::c_int,
@@ -902,6 +903,7 @@ pub unsafe fn dc_extract_grpid_from_rfc724_mid_list(list: *const clist) -> *mut
}
/* file tools */
#[allow(non_snake_case)]
pub unsafe fn dc_ensure_no_slash(pathNfilename: *mut libc::c_char) {
let path_len = strlen(pathNfilename);
if path_len > 0 {
@@ -934,6 +936,7 @@ pub unsafe fn dc_validate_filename(filename: *mut libc::c_char) {
}
}
#[allow(non_snake_case)]
pub unsafe fn dc_get_filename(pathNfilename: *const libc::c_char) -> *mut libc::c_char {
let mut p: *const libc::c_char = strrchr(pathNfilename, '/' as i32);
if p.is_null() {
@@ -948,6 +951,7 @@ pub unsafe fn dc_get_filename(pathNfilename: *const libc::c_char) -> *mut libc::
}
// the case of the suffix is preserved
#[allow(non_snake_case)]
pub unsafe fn dc_split_filename(
pathNfilename: *const libc::c_char,
ret_basename: *mut *mut libc::c_char,
@@ -980,6 +984,7 @@ pub unsafe fn dc_split_filename(
}
// the returned suffix is lower-case
#[allow(non_snake_case)]
pub unsafe fn dc_get_filesuffix_lc(pathNfilename: *const libc::c_char) -> *mut libc::c_char {
if !pathNfilename.is_null() {
let mut p: *const libc::c_char = strrchr(pathNfilename, '.' as i32);
@@ -1075,6 +1080,7 @@ pub unsafe fn dc_get_filemeta(
0
}
#[allow(non_snake_case)]
pub unsafe fn dc_get_abs_path(
context: &Context,
pathNfilename: *const libc::c_char,
@@ -1104,6 +1110,7 @@ pub unsafe fn dc_get_abs_path(
pathNfilename_abs
}
#[allow(non_snake_case)]
pub unsafe fn dc_file_exist(context: &Context, pathNfilename: *const libc::c_char) -> libc::c_int {
let pathNfilename_abs = dc_get_abs_path(context, pathNfilename);
if pathNfilename_abs.is_null() {
@@ -1119,6 +1126,7 @@ pub unsafe fn dc_file_exist(context: &Context, pathNfilename: *const libc::c_cha
exist as libc::c_int
}
#[allow(non_snake_case)]
pub unsafe fn dc_get_filebytes(context: &Context, pathNfilename: *const libc::c_char) -> uint64_t {
let pathNfilename_abs = dc_get_abs_path(context, pathNfilename);
if pathNfilename_abs.is_null() {
@@ -1139,6 +1147,7 @@ pub unsafe fn dc_get_filebytes(context: &Context, pathNfilename: *const libc::c_
filebytes as uint64_t
}
#[allow(non_snake_case)]
pub unsafe fn dc_delete_file(context: &Context, pathNfilename: *const libc::c_char) -> libc::c_int {
let mut success: libc::c_int = 0i32;
let pathNfilename_abs = dc_get_abs_path(context, pathNfilename);
@@ -1170,6 +1179,7 @@ pub unsafe fn dc_delete_file(context: &Context, pathNfilename: *const libc::c_ch
success
}
#[allow(non_snake_case)]
pub unsafe fn dc_copy_file(
context: &Context,
src: *const libc::c_char,
@@ -1201,6 +1211,7 @@ pub unsafe fn dc_copy_file(
success
}
#[allow(non_snake_case)]
pub unsafe fn dc_create_folder(
context: &Context,
pathNfilename: *const libc::c_char,
@@ -1232,6 +1243,7 @@ pub unsafe fn dc_create_folder(
success
}
#[allow(non_snake_case)]
pub unsafe fn dc_write_file(
context: &Context,
pathNfilename: *const libc::c_char,
@@ -1243,6 +1255,7 @@ pub unsafe fn dc_write_file(
dc_write_file_safe(context, as_str(pathNfilename), bytes) as libc::c_int
}
#[allow(non_snake_case)]
pub fn dc_write_file_safe(context: &Context, pathNfilename: impl AsRef<str>, buf: &[u8]) -> bool {
let pathNfilename_abs = unsafe {
let n = to_cstring(pathNfilename.as_ref());
@@ -1273,6 +1286,7 @@ pub fn dc_write_file_safe(context: &Context, pathNfilename: impl AsRef<str>, buf
success
}
#[allow(non_snake_case)]
pub unsafe fn dc_read_file(
context: &Context,
pathNfilename: *const libc::c_char,
@@ -1292,6 +1306,7 @@ pub unsafe fn dc_read_file(
}
}
#[allow(non_snake_case)]
pub fn dc_read_file_safe(context: &Context, pathNfilename: impl AsRef<str>) -> Option<Vec<u8>> {
let pathNfilename_abs = unsafe {
let n = to_cstring(pathNfilename.as_ref());
@@ -1323,6 +1338,7 @@ pub fn dc_read_file_safe(context: &Context, pathNfilename: impl AsRef<str>) -> O
res
}
#[allow(non_snake_case)]
pub unsafe fn dc_get_fine_pathNfilename(
context: &Context,
pathNfolder: *const libc::c_char,

View File

@@ -1,8 +1,6 @@
#![allow(
non_camel_case_types,
non_snake_case,
non_camel_case_types,
non_snake_case
)]
#![feature(c_variadic, ptr_wrapping_offset_from)]