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