Make dc_tools::dc_exactly_one_bit_set safe and return bool

This commit is contained in:
Alexander Krotov
2019-07-28 21:07:49 +03:00
committed by Floris Bruynooghe
parent 3eaab07b0b
commit 6c818c6123
2 changed files with 5 additions and 5 deletions

View File

@@ -570,13 +570,13 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
{
param.send_pw = param.mail_pw.clone()
}
if 0 == dc_exactly_one_bit_set(
if !dc_exactly_one_bit_set(
param.server_flags & (0x2 | 0x4),
) {
param.server_flags &= !(0x2 | 0x4);
param.server_flags |= 0x4
}
if 0 == dc_exactly_one_bit_set(
if !dc_exactly_one_bit_set(
param.server_flags & (0x100 | 0x200 | 0x400),
) {
param.server_flags &= !(0x100 | 0x200 | 0x400);
@@ -586,7 +586,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
0x200
}
}
if 0 == dc_exactly_one_bit_set(
if !dc_exactly_one_bit_set(
param.server_flags & (0x10000 | 0x20000 | 0x40000),
) {
param.server_flags &=

View File

@@ -20,8 +20,8 @@ no references to Context and other "larger" classes here. */
// for carray etc.
/* ** library-private **********************************************************/
/* math tools */
pub unsafe fn dc_exactly_one_bit_set(v: libc::c_int) -> libc::c_int {
return (0 != v && 0 == v & v - 1i32) as libc::c_int;
pub fn dc_exactly_one_bit_set(v: libc::c_int) -> bool {
0 != v && 0 == v & v - 1i32
}
/* string tools */