From 27a4adb9c6d6378a6dd44fb65b7d3efdcf8fa28b Mon Sep 17 00:00:00 2001 From: Alexander Krotov Date: Thu, 12 Sep 2019 12:56:51 +0300 Subject: [PATCH] Return bool from export_key_to_asc_file --- src/dc_imex.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/dc_imex.rs b/src/dc_imex.rs index abe035fbf..05aa1f389 100644 --- a/src/dc_imex.rs +++ b/src/dc_imex.rs @@ -1026,14 +1026,14 @@ unsafe fn export_self_keys(context: &Context, dir: *const libc::c_char) -> bool for key_pair in keys { let (id, public_key, private_key, is_default) = key_pair?; if let Some(key) = public_key { - if 0 == export_key_to_asc_file(context, dir, id, &key, is_default) { + if export_key_to_asc_file(context, dir, id, &key, is_default) { export_errors += 1; } } else { export_errors += 1; } if let Some(key) = private_key { - if 0 == export_key_to_asc_file(context, dir, id, &key, is_default) { + if export_key_to_asc_file(context, dir, id, &key, is_default) { export_errors += 1; } } else { @@ -1052,15 +1052,14 @@ unsafe fn export_self_keys(context: &Context, dir: *const libc::c_char) -> bool /******************************************************************************* * Classic key export ******************************************************************************/ -// TODO should return bool /rtn unsafe fn export_key_to_asc_file( context: &Context, dir: *const libc::c_char, id: libc::c_int, key: &Key, is_default: libc::c_int, -) -> libc::c_int { - let mut success: libc::c_int = 0i32; +) -> bool { + let mut success = false; let file_name; if 0 != is_default { file_name = dc_mprintf( @@ -1094,7 +1093,7 @@ unsafe fn export_key_to_asc_file( file_name as uintptr_t, 0i32 as uintptr_t, ); - success = 1i32 + success = true; } free(file_name as *mut libc::c_void);