From e0df78c5f7bc141881a2ff5964ebc0d550971b4d Mon Sep 17 00:00:00 2001 From: Dmitry Bogatov Date: Fri, 6 Sep 2019 03:39:44 +0000 Subject: [PATCH] Change type of dc_mimepart_t.is_meta to bool --- src/dc_mimeparser.rs | 14 +++++--------- src/dc_receive_imf.rs | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/dc_mimeparser.rs b/src/dc_mimeparser.rs index 4dee953f0..ef1624df8 100644 --- a/src/dc_mimeparser.rs +++ b/src/dc_mimeparser.rs @@ -32,7 +32,7 @@ dc_mimeparser_t has no deep dependencies to Context or to the database #[repr(C)] pub struct dc_mimepart_t { pub type_0: Viewtype, - pub is_meta: libc::c_int, + pub is_meta: bool, pub int_mimetype: libc::c_int, pub msg: Option, pub msg_raw: *mut libc::c_char, @@ -196,7 +196,7 @@ pub unsafe fn dc_mimeparser_parse<'a>(context: &'a Context, body: &[u8]) -> dc_m if mimeparser.parts.len() >= 2 { let imgpart = &mut mimeparser.parts[1]; if imgpart.type_0 == Viewtype::Image { - imgpart.is_meta = 1i32 + imgpart.is_meta = true; } } } @@ -212,7 +212,7 @@ pub unsafe fn dc_mimeparser_parse<'a>(context: &'a Context, body: &[u8]) -> dc_m || filepart.type_0 == Viewtype::Voice || filepart.type_0 == Viewtype::Video || filepart.type_0 == Viewtype::File) - && 0 == filepart.is_meta + && !filepart.is_meta }; if need_drop { @@ -366,7 +366,7 @@ pub unsafe fn dc_mimeparser_parse<'a>(context: &'a Context, body: &[u8]) -> dc_m unsafe fn dc_mimepart_new() -> dc_mimepart_t { dc_mimepart_t { type_0: Viewtype::Unknown, - is_meta: 0, + is_meta: false, int_mimetype: 0, msg: None, msg_raw: std::ptr::null_mut(), @@ -378,11 +378,7 @@ unsafe fn dc_mimepart_new() -> dc_mimepart_t { pub fn dc_mimeparser_get_last_nonmeta<'a>( mimeparser: &'a mut dc_mimeparser_t, ) -> Option<&'a mut dc_mimepart_t> { - mimeparser - .parts - .iter_mut() - .rev() - .find(|part| part.is_meta == 0) + mimeparser.parts.iter_mut().rev().find(|part| !part.is_meta) } /*the result must be freed*/ diff --git a/src/dc_receive_imf.rs b/src/dc_receive_imf.rs index e4f0e65c4..378966810 100644 --- a/src/dc_receive_imf.rs +++ b/src/dc_receive_imf.rs @@ -625,7 +625,7 @@ unsafe fn add_parts( |mut stmt, conn| { for i in 0..icnt { let part = &mut mime_parser.parts[i]; - if part.is_meta != 0 { + if part.is_meta { continue; }