Skip to content

Commit e39c2b7

Browse files
committed
clippy: improve integral type casting
1 parent ab112e5 commit e39c2b7

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/api.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ impl Keyring {
126126

127127
fn get_keyring(id: SpecialKeyring, create: bool) -> Result<Keyring> {
128128
let res = unsafe { keyctl_get_keyring_ID(id.serial(), create as libc::c_int) };
129-
check_call(res as libc::c_long, Keyring::new_impl(res))
129+
check_call(i64::from(res), Keyring::new_impl(res))
130130
}
131131

132132
/// Attach to a special keyring. Fails if the keyring does not already exist.
@@ -142,7 +142,7 @@ impl Keyring {
142142
/// Create a new anonymous keyring and set it as the session keyring.
143143
pub fn join_anonymous_session() -> Result<Self> {
144144
let res = unsafe { keyctl_join_session_keyring(ptr::null()) };
145-
check_call(res as libc::c_long, Keyring::new_impl(res))
145+
check_call(i64::from(res), Keyring::new_impl(res))
146146
}
147147

148148
/// Attached to a named session keyring.
@@ -154,7 +154,7 @@ impl Keyring {
154154
{
155155
let name_cstr = CString::new(name.as_ref()).unwrap();
156156
let res = unsafe { keyctl_join_session_keyring(name_cstr.as_ptr()) };
157-
check_call(res as libc::c_long, Keyring::new_impl(res))
157+
check_call(i64::from(res), Keyring::new_impl(res))
158158
}
159159

160160
/// Clears the contents of the keyring.
@@ -286,7 +286,7 @@ impl Keyring {
286286
payload.len(),
287287
self.id)
288288
};
289-
check_call(res as libc::c_long, Key::new_impl(res))
289+
check_call(i64::from(res), Key::new_impl(res))
290290
}
291291

292292
/// Adds a keyring to the current keyring.
@@ -316,7 +316,7 @@ impl Keyring {
316316
where D: AsRef<str>,
317317
{
318318
let res = self.request_impl("user", description.as_ref())?;
319-
check_call(res as libc::c_long, Key::new_impl(res))
319+
check_call(i64::from(res), Key::new_impl(res))
320320
}
321321

322322
/// Requests a keyring with the given description by searching the thread, process, and session
@@ -327,7 +327,7 @@ impl Keyring {
327327
where D: AsRef<str>,
328328
{
329329
let res = self.request_impl("keyring", description.as_ref())?;
330-
check_call(res as libc::c_long, Keyring::new_impl(res))
330+
check_call(i64::from(res), Keyring::new_impl(res))
331331
}
332332

333333
fn request_fallback_impl(&self, type_: &str, description: &str, info: &str) -> Result<KeyringSerial> {
@@ -353,7 +353,7 @@ impl Keyring {
353353
I: AsRef<str>,
354354
{
355355
let res = self.request_fallback_impl("user", description.as_ref(), info.as_ref())?;
356-
check_call(res as libc::c_long, Key::new_impl(res))
356+
check_call(i64::from(res), Key::new_impl(res))
357357
}
358358

359359
/// Requests a keyring with the given description by searching the thread, process, and session
@@ -367,7 +367,7 @@ impl Keyring {
367367
I: AsRef<str>,
368368
{
369369
let res = self.request_fallback_impl("keyring", description.as_ref(), info.as_ref())?;
370-
check_call(res as libc::c_long, Keyring::new_impl(res))
370+
check_call(i64::from(res), Keyring::new_impl(res))
371371
}
372372

373373
/// Revokes the keyring.
@@ -478,7 +478,7 @@ impl Key {
478478
/// keyrings.
479479
pub fn request_key_auth_key(create: bool) -> Result<Self> {
480480
let res = unsafe { keyctl_get_keyring_ID(KEY_SPEC_REQKEY_AUTH_KEY, create as libc::c_int) };
481-
check_call(res as libc::c_long, Key::new_impl(res))
481+
check_call(i64::from(res), Key::new_impl(res))
482482
}
483483

484484
/// Requests a key with the given description by searching the thread, process, and session

src/keytypes/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ impl AsciiHex {
7171
let hi = (byte >> 4) & NIBBLE_MASK;
7272
let lo = byte & NIBBLE_MASK;
7373

74-
string.push(char::from_digit(hi as u32, 16).unwrap());
75-
string.push(char::from_digit(lo as u32, 16).unwrap());
74+
string.push(char::from_digit(u32::from(hi), 16).unwrap());
75+
string.push(char::from_digit(u32::from(lo), 16).unwrap());
7676

7777
string
7878
})

0 commit comments

Comments
 (0)