Silence _ykpiv_end_transaction "unused Result" clippy warnings

These calls will be replaced when the pcsc crate is introduced.
This commit is contained in:
Jack Grigg
2019-11-20 12:38:38 +00:00
parent ce55e08af8
commit 683e463824
2 changed files with 53 additions and 53 deletions
+25 -25
View File
@@ -110,7 +110,7 @@ pub unsafe fn ykpiv_util_get_cardid(
} }
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -158,7 +158,7 @@ pub unsafe fn ykpiv_util_set_cardid(
); );
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -188,7 +188,7 @@ pub unsafe fn ykpiv_util_get_cccid(state: &mut YubiKey, ccc: *mut CCCID) -> Resu
if res.is_ok() { if res.is_ok() {
if len != CCC_TMPL.len() { if len != CCC_TMPL.len() {
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
return Err(ErrorKind::GenericError); return Err(ErrorKind::GenericError);
} }
@@ -245,7 +245,7 @@ pub unsafe fn ykpiv_util_set_cccid(
res = _ykpiv_save_object(state, YKPIV_OBJ_CAPABILITY as i32, buf.as_mut_ptr(), len); res = _ykpiv_save_object(state, YKPIV_OBJ_CAPABILITY as i32, buf.as_mut_ptr(), len);
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -337,7 +337,7 @@ pub unsafe fn ykpiv_util_list_keys(
p_data = calloc(CB_PAGE, 1) as (*mut u8); p_data = calloc(CB_PAGE, 1) as (*mut u8);
if p_data.is_null() { if p_data.is_null() {
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
return Err(ErrorKind::MemoryError); return Err(ErrorKind::MemoryError);
} }
@@ -429,7 +429,7 @@ pub unsafe fn ykpiv_util_list_keys(
free(p_data as (*mut c_void)); free(p_data as (*mut c_void));
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -476,7 +476,7 @@ pub unsafe fn ykpiv_util_read_cert(
} }
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -496,7 +496,7 @@ pub unsafe fn ykpiv_util_write_cert(
res = _write_certificate(state, slot, data, data_len, certinfo); res = _write_certificate(state, slot, data, data_len, certinfo);
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -615,7 +615,7 @@ pub unsafe fn ykpiv_util_block_puk(state: &mut YubiKey) -> Result<(), ErrorKind>
} }
} }
} else { } else {
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
return res; return res;
} }
} }
@@ -682,14 +682,14 @@ pub unsafe fn ykpiv_util_read_mscmap(
); );
if res.is_err() { if res.is_err() {
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
return res; return res;
} }
ptr = buf.as_mut_ptr(); ptr = buf.as_mut_ptr();
if cb_buf < CB_OBJ_TAG_MIN { if cb_buf < CB_OBJ_TAG_MIN {
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
return Ok(()); return Ok(());
} }
@@ -698,7 +698,7 @@ pub unsafe fn ykpiv_util_read_mscmap(
ptr = ptr.add(_ykpiv_get_length(ptr, &mut len)); ptr = ptr.add(_ykpiv_get_length(ptr, &mut len));
if len > cb_buf - (ptr as isize - buf.as_mut_ptr() as isize) as usize { if len > cb_buf - (ptr as isize - buf.as_mut_ptr() as isize) as usize {
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
return Ok(()); return Ok(());
} }
@@ -746,14 +746,14 @@ pub unsafe fn ykpiv_util_write_mscmap(
res = _ykpiv_save_object(state, YKPIV_OBJ_MSCMAP as i32, ptr::null_mut(), 0); res = _ykpiv_save_object(state, YKPIV_OBJ_MSCMAP as i32, ptr::null_mut(), 0);
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
return res; return res;
} }
let req_len = 1 + _ykpiv_set_length(buf.as_mut_ptr(), data_len) + data_len; let req_len = 1 + _ykpiv_set_length(buf.as_mut_ptr(), data_len) + data_len;
if req_len > _obj_size_max(state) { if req_len > _obj_size_max(state) {
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
return Err(ErrorKind::SizeError); return Err(ErrorKind::SizeError);
} }
@@ -769,7 +769,7 @@ pub unsafe fn ykpiv_util_write_mscmap(
res = _ykpiv_save_object(state, YKPIV_OBJ_MSCMAP as i32, buf.as_mut_ptr(), offset); res = _ykpiv_save_object(state, YKPIV_OBJ_MSCMAP as i32, buf.as_mut_ptr(), offset);
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -897,7 +897,7 @@ pub unsafe fn ykpiv_util_read_msroots(
free(p_data as (*mut c_void)); free(p_data as (*mut c_void));
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -925,14 +925,14 @@ pub unsafe fn ykpiv_util_write_msroots(
res = _ykpiv_save_object(state, YKPIV_OBJ_MSROOTS1 as i32, ptr::null_mut(), 0); res = _ykpiv_save_object(state, YKPIV_OBJ_MSROOTS1 as i32, ptr::null_mut(), 0);
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
return res; return res;
} }
n_objs = (data_len / (cb_obj_max - 4)) + 1; n_objs = (data_len / (cb_obj_max - 4)) + 1;
if n_objs > 5 { if n_objs > 5 {
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
return Err(ErrorKind::SizeError); return Err(ErrorKind::SizeError);
} }
@@ -977,7 +977,7 @@ pub unsafe fn ykpiv_util_write_msroots(
} }
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -1356,7 +1356,7 @@ pub unsafe fn ykpiv_util_generate_key(
free(ptr_exp as (*mut c_void)); free(ptr_exp as (*mut c_void));
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -1517,7 +1517,7 @@ pub unsafe fn ykpiv_util_get_config(
} }
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -1562,7 +1562,7 @@ pub unsafe fn ykpiv_util_set_pin_last_changed(state: &mut YubiKey) -> Result<(),
} }
} }
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -1645,7 +1645,7 @@ pub unsafe fn ykpiv_util_get_derived_mgm(
} }
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -1705,7 +1705,7 @@ pub unsafe fn ykpiv_util_get_protected_mgm(
} }
data.zeroize(); data.zeroize();
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -1917,7 +1917,7 @@ pub unsafe fn ykpiv_util_set_protected_mgm(
data.zeroize(); data.zeroize();
mgm_key.zeroize(); mgm_key.zeroize();
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
+28 -28
View File
@@ -491,7 +491,7 @@ pub unsafe fn ykpiv_connect(state: &mut YubiKey, wanted: *const c_char) -> Resul
_ykpiv_begin_transaction(state)?; _ykpiv_begin_transaction(state)?;
let res = _ykpiv_select_application(state); let res = _ykpiv_select_application(state);
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -782,7 +782,7 @@ pub unsafe fn ykpiv_transfer_data(
} }
let res = _ykpiv_transfer_data(state, templ, in_data, in_len, out_data, out_len, sw); let res = _ykpiv_transfer_data(state, templ, in_data, in_len, out_data, out_len, sw);
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -878,7 +878,7 @@ pub unsafe fn ykpiv_authenticate(state: &mut YubiKey, mut key: *const u8) -> Res
mgm_key.is_null(), mgm_key.is_null(),
"didn't expect mgm key to be set by failing op!" "didn't expect mgm key to be set by failing op!"
); );
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
return Err(ErrorKind::AlgorithmError); return Err(ErrorKind::AlgorithmError);
} }
@@ -895,12 +895,12 @@ pub unsafe fn ykpiv_authenticate(state: &mut YubiKey, mut key: *const u8) -> Res
res = _send_data(state, &mut apdu, data.as_mut_ptr(), &mut recv_len, &mut sw); res = _send_data(state, &mut apdu, data.as_mut_ptr(), &mut recv_len, &mut sw);
if res.is_err() { if res.is_err() {
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
return res; return res;
} }
if sw != SW_SUCCESS { if sw != SW_SUCCESS {
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
return Err(ErrorKind::AuthenticationError); return Err(ErrorKind::AuthenticationError);
} }
@@ -923,7 +923,7 @@ pub unsafe fn ykpiv_authenticate(state: &mut YubiKey, mut key: *const u8) -> Res
); );
if drc != DesErrorKind::Ok { if drc != DesErrorKind::Ok {
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
return Err(ErrorKind::AuthenticationError); return Err(ErrorKind::AuthenticationError);
} }
@@ -949,7 +949,7 @@ pub unsafe fn ykpiv_authenticate(state: &mut YubiKey, mut key: *const u8) -> Res
eprintln!("Failed getting randomness for authentication."); eprintln!("Failed getting randomness for authentication.");
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
return Err(ErrorKind::RandomnessError); return Err(ErrorKind::RandomnessError);
} }
@@ -963,12 +963,12 @@ pub unsafe fn ykpiv_authenticate(state: &mut YubiKey, mut key: *const u8) -> Res
res = _send_data(state, &mut apdu, data.as_mut_ptr(), &mut recv_len, &mut sw); res = _send_data(state, &mut apdu, data.as_mut_ptr(), &mut recv_len, &mut sw);
if res.is_err() { if res.is_err() {
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
return res; return res;
} }
if sw != SW_SUCCESS { if sw != SW_SUCCESS {
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
return Err(ErrorKind::AuthenticationError); return Err(ErrorKind::AuthenticationError);
} }
@@ -1001,7 +1001,7 @@ pub unsafe fn ykpiv_authenticate(state: &mut YubiKey, mut key: *const u8) -> Res
des_destroy_key(mgm_key); des_destroy_key(mgm_key);
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -1040,7 +1040,7 @@ pub(crate) unsafe fn ykpiv_set_mgmkey2(
0 => 0xff, 0 => 0xff,
1 => 0xfe, 1 => 0xfe,
_ => { _ => {
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
return Err(ErrorKind::GenericError); return Err(ErrorKind::GenericError);
} }
}; };
@@ -1065,7 +1065,7 @@ pub(crate) unsafe fn ykpiv_set_mgmkey2(
} }
apdu.zeroize(); apdu.zeroize();
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -1220,7 +1220,7 @@ pub unsafe fn ykpiv_sign_data(
state, raw_in, in_len, sign_out, out_len, algorithm, key, false, state, raw_in, in_len, sign_out, out_len, algorithm, key, false,
); );
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -1239,7 +1239,7 @@ pub unsafe fn ykpiv_decrypt_data(
// don't attempt to reselect in crypt operations to avoid problems with PIN_ALWAYS // don't attempt to reselect in crypt operations to avoid problems with PIN_ALWAYS
let res = _general_authenticate(state, input, input_len, out, out_len, algorithm, key, true); let res = _general_authenticate(state, input, input_len, out, out_len, algorithm, key, true);
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -1285,7 +1285,7 @@ pub unsafe fn ykpiv_get_version(state: &mut YubiKey) -> Result<String, ErrorKind
res = _ykpiv_get_version(state); res = _ykpiv_get_version(state);
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res.map(|ver| format!("{}.{}.{}", ver.major, ver.minor, ver.patch)) res.map(|ver| format!("{}.{}.{}", ver.major, ver.minor, ver.patch))
} }
@@ -1426,7 +1426,7 @@ pub unsafe fn ykpiv_get_serial(state: &mut YubiKey) -> Result<u32, ErrorKind> {
res = _ykpiv_get_serial(state, false); res = _ykpiv_get_serial(state, false);
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -1563,7 +1563,7 @@ pub unsafe fn ykpiv_verify_select(
res = _verify(state, pin, pin_len); res = _verify(state, pin, pin_len);
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -1630,7 +1630,7 @@ pub unsafe fn ykpiv_set_pin_retries(
} }
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -1744,7 +1744,7 @@ pub unsafe fn ykpiv_change_pin(
} }
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -1770,7 +1770,7 @@ pub unsafe fn ykpiv_change_puk(
res = _ykpiv_change_pin(state, 2, current_puk, current_puk_len, new_puk, new_puk_len); res = _ykpiv_change_pin(state, 2, current_puk, current_puk_len, new_puk, new_puk_len);
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -1791,7 +1791,7 @@ pub unsafe fn ykpiv_unblock_pin(
res = _ykpiv_change_pin(state, 1, puk, puk_len, new_pin, new_pin_len); res = _ykpiv_change_pin(state, 1, puk, puk_len, new_pin, new_pin_len);
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -1810,7 +1810,7 @@ pub unsafe fn ykpiv_fetch_object(
res = _ykpiv_fetch_object(state, object_id, data, len); res = _ykpiv_fetch_object(state, object_id, data, len);
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -1894,7 +1894,7 @@ pub unsafe fn ykpiv_save_object(
res = _ykpiv_save_object(state, object_id, indata, len); res = _ykpiv_save_object(state, object_id, indata, len);
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -2135,7 +2135,7 @@ pub unsafe fn ykpiv_import_private_key(
} }
key_data.zeroize(); key_data.zeroize();
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -2184,7 +2184,7 @@ pub unsafe fn ykpiv_attest(
} }
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -2219,7 +2219,7 @@ pub unsafe fn ykpiv_auth_getchallenge(state: &mut YubiKey) -> Result<[u8; 8], Er
} }
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -2253,7 +2253,7 @@ pub unsafe fn ykpiv_auth_verifyresponse(
} }
apdu.zeroize(); apdu.zeroize();
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }
@@ -2292,6 +2292,6 @@ pub unsafe fn ykpiv_auth_deauthenticate(state: &mut YubiKey) -> Result<(), Error
res = Err(ErrorKind::GenericError); res = Err(ErrorKind::GenericError);
} }
_ykpiv_end_transaction(state); let _ = _ykpiv_end_transaction(state);
res res
} }