Skip to content

Commit

Permalink
fix: remove unchecked unwrap, rename _err to _
Browse files Browse the repository at this point in the history
  • Loading branch information
gboutry committed Feb 24, 2022
1 parent c2eefaa commit 038c6e4
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/krb5_rs/src/ccache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl<'a> CCache<'a> {
pub fn resolve(context: &'a Context, cc_name: &str) -> Result<CCache<'a>> {
let mut ccache: MaybeUninit<krb5_ccache> = MaybeUninit::uninit();

let cc_name = CString::new(cc_name).unwrap();
let cc_name = CString::new(cc_name).map_err(|_| Krb5Error::StringConversionError)?;

let error_code =
unsafe { krb5_cc_resolve(context.inner, cc_name.as_ptr(), ccache.as_mut_ptr()) };
Expand Down
2 changes: 1 addition & 1 deletion crates/krb5_rs/src/credentials.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl<'a> Credentials<'a> {
password: &str,
) -> Result<Credentials<'a>> {
let mut credentials: MaybeUninit<krb5_creds> = MaybeUninit::uninit();
let password = CString::new(password).map_err(|_err| Krb5Error::StringConversionError)?;
let password = CString::new(password).map_err(|_| Krb5Error::StringConversionError)?;
let error_code = unsafe {
krb5_get_init_creds_password(
context.inner,
Expand Down
2 changes: 1 addition & 1 deletion crates/krb5_rs/src/gssapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub fn import_name(principal: &str, input_name_type: &str) -> Result<Name, Strin
pub fn krb5_ccache_name(ccache_name: &str) -> Result<(), String> {
let mut minor = 0;
let ccache_name =
CString::new(ccache_name).map_err(|_err| "Failed to convert ccache name to a c string")?;
CString::new(ccache_name).map_err(|_| "Failed to convert ccache name to a c string")?;

let error_code =
unsafe { gss_krb5_ccache_name(&mut minor, ccache_name.as_ptr(), std::ptr::null_mut()) };
Expand Down
2 changes: 1 addition & 1 deletion crates/krb5_rs/src/keytab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub struct Keytab<'a> {
impl<'a> Keytab<'a> {
pub fn resolve(context: &'a Context, name: &str) -> Result<Keytab<'a>> {
let mut keytab: MaybeUninit<krb5_keytab> = MaybeUninit::uninit();
let name = CString::new(name).unwrap();
let name = CString::new(name).map_err(|_| Krb5Error::StringConversionError)?;
let error_code =
unsafe { krb5_kt_resolve(context.inner, name.as_ptr(), keytab.as_mut_ptr()) };
Krb5Error::exit_if_library_error(context, error_code)?;
Expand Down

0 comments on commit 038c6e4

Please sign in to comment.