File tree Expand file tree Collapse file tree 1 file changed +12
-13
lines changed Expand file tree Collapse file tree 1 file changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -83,19 +83,18 @@ pub struct Shadow {
83
83
84
84
impl From < & libc:: spwd > for Shadow {
85
85
fn from ( spwd : & libc:: spwd ) -> Shadow {
86
- unsafe {
87
- Shadow {
88
- name : CStr :: from_ptr ( ( * spwd) . sp_namp )
89
- . to_string_lossy ( )
90
- . into_owned ( ) ,
91
- password : CString :: new ( CStr :: from_ptr ( ( * spwd) . sp_pwdp ) . to_bytes ( ) ) . unwrap ( ) ,
92
- last_change : ( * spwd) . sp_lstchg ,
93
- min : ( * spwd) . sp_min ,
94
- max : ( * spwd) . sp_max ,
95
- warn : ( * spwd) . sp_warn ,
96
- inactive : ( * spwd) . sp_inact ,
97
- expire : ( * spwd) . sp_expire ,
98
- }
86
+ Shadow {
87
+ name : unsafe { CStr :: from_ptr ( spwd. sp_namp ) . to_string_lossy ( ) . into_owned ( ) } ,
88
+ password : unsafe { CString :: new ( CStr :: from_ptr ( spwd. sp_pwdp ) . to_bytes ( ) ) . unwrap ( ) } ,
89
+ // These casts are necessary to convert the C `long int`
90
+ // integers (which can be either 32 or 64 bits, depending on
91
+ // the CPU architecture) into 64 bit integers.
92
+ last_change : spwd. sp_lstchg as i64 ,
93
+ min : spwd. sp_min as i64 ,
94
+ max : spwd. sp_max as i64 ,
95
+ warn : spwd. sp_warn as i64 ,
96
+ inactive : spwd. sp_inact as i64 ,
97
+ expire : spwd. sp_expire as i64 ,
99
98
}
100
99
}
101
100
}
You can’t perform that action at this time.
0 commit comments