@@ -136,27 +136,27 @@ pub enum RegSize {
136
136
137
137
impl RegSize {
138
138
/// Size of u8 register in bytes
139
- pub const U8_SIZE : u64 = 1 ;
139
+ pub const U8_SIZE : usize = 1 ;
140
140
/// Size of u16 register in bytes
141
- pub const U16_SIZE : u64 = 2 ;
141
+ pub const U16_SIZE : usize = 2 ;
142
142
/// Size of u32 register in bytes
143
- pub const U32_SIZE : u64 = 4 ;
143
+ pub const U32_SIZE : usize = 4 ;
144
144
/// Size of u64 register in bytes
145
- pub const U64_SIZE : u64 = 8 ;
145
+ pub const U64_SIZE : usize = 8 ;
146
146
/// Size of u128 register in bytes
147
- pub const U128_SIZE : u64 = 16 ;
147
+ pub const U128_SIZE : usize = 16 ;
148
148
/// Size of u256 register in bytes
149
- pub const U256_SIZE : u64 = 32 ;
149
+ pub const U256_SIZE : usize = 32 ;
150
150
/// Size of u512 register in bytes
151
- pub const U512_SIZE : u64 = 64 ;
151
+ pub const U512_SIZE : usize = 64 ;
152
152
/// Size of u1024 register in bytes
153
- pub const U1024_SIZE : u64 = 128 ;
153
+ pub const U1024_SIZE : usize = 128 ;
154
154
/// Size of u2048 register in bytes
155
- pub const U2048_SIZE : u64 = 256 ;
155
+ pub const U2048_SIZE : usize = 256 ;
156
156
}
157
157
158
- impl From < u64 > for RegSize {
159
- fn from ( value : u64 ) -> Self {
158
+ impl From < usize > for RegSize {
159
+ fn from ( value : usize ) -> Self {
160
160
match value {
161
161
RegSize :: U8_SIZE => RegSize :: U8 ,
162
162
RegSize :: U16_SIZE => RegSize :: U16 ,
@@ -172,7 +172,7 @@ impl From<u64> for RegSize {
172
172
}
173
173
}
174
174
175
- impl From < RegSize > for u64 {
175
+ impl From < RegSize > for usize {
176
176
fn from ( value : RegSize ) -> Self {
177
177
match value {
178
178
RegSize :: U8 => RegSize :: U8_SIZE ,
@@ -189,8 +189,8 @@ impl From<RegSize> for u64 {
189
189
}
190
190
191
191
/// Returns register size in bytes
192
- pub fn reg_size ( reg_id : u64 ) -> u64 {
193
- 2_u64 . pow ( ( ( reg_id & KVM_REG_SIZE_MASK ) >> KVM_REG_SIZE_SHIFT ) as u32 )
192
+ pub fn reg_size ( reg_id : u64 ) -> usize {
193
+ 2_usize . pow ( ( ( reg_id & KVM_REG_SIZE_MASK ) >> KVM_REG_SIZE_SHIFT ) as u32 )
194
194
}
195
195
196
196
/// Storage for aarch64 registers with different sizes.
@@ -294,7 +294,7 @@ impl Versionize for Aarch64RegisterVec {
294
294
Self : Sized ,
295
295
{
296
296
let inner = Aarch64RegisterVecInner :: deserialize ( reader, version_map, source_version) ?;
297
- let mut total_size: u64 = 0 ;
297
+ let mut total_size: usize = 0 ;
298
298
for id in inner. ids . iter ( ) {
299
299
let reg_size = reg_size ( * id) ;
300
300
if RegSize :: U2048_SIZE < reg_size {
@@ -306,7 +306,7 @@ impl Versionize for Aarch64RegisterVec {
306
306
}
307
307
total_size += reg_size;
308
308
}
309
- if total_size as usize != inner. data . len ( ) {
309
+ if total_size != inner. data . len ( ) {
310
310
Err ( VersionizeError :: Deserialize (
311
311
"Failed to deserialize aarch64 registers. Sum of registers sizes is not equal to \
312
312
registers data length"
@@ -337,7 +337,7 @@ impl<'a> Iterator for Aarch64RegisterVecIterator<'a> {
337
337
fn next ( & mut self ) -> Option < Self :: Item > {
338
338
if self . index < self . ids . len ( ) {
339
339
let id = self . ids [ self . index ] ;
340
- let reg_size = reg_size ( id) as usize ;
340
+ let reg_size = reg_size ( id) ;
341
341
let reg_ref = Aarch64RegisterRef {
342
342
id,
343
343
data : & self . data [ self . offset ..self . offset + reg_size] ,
@@ -366,7 +366,7 @@ impl<'a> Iterator for Aarch64RegisterVecIteratorMut<'a> {
366
366
fn next ( & mut self ) -> Option < Self :: Item > {
367
367
if self . index < self . ids . len ( ) {
368
368
let id = self . ids [ self . index ] ;
369
- let reg_size = reg_size ( id) as usize ;
369
+ let reg_size = reg_size ( id) ;
370
370
371
371
let data = std:: mem:: take ( & mut self . data ) ;
372
372
let ( head, tail) = data. split_at_mut ( reg_size) ;
@@ -396,7 +396,7 @@ impl<'a> Aarch64RegisterRef<'a> {
396
396
/// will panic.
397
397
pub fn new ( id : u64 , data : & ' a [ u8 ] ) -> Self {
398
398
assert_eq ! (
399
- reg_size( id) as usize ,
399
+ reg_size( id) ,
400
400
data. len( ) ,
401
401
"Attempt to create a register reference with incompatible id and data length"
402
402
) ;
@@ -438,7 +438,7 @@ impl<'a> Aarch64RegisterRefMut<'a> {
438
438
/// will panic.
439
439
pub fn new ( id : u64 , data : & ' a mut [ u8 ] ) -> Self {
440
440
assert_eq ! (
441
- reg_size( id) as usize ,
441
+ reg_size( id) ,
442
442
data. len( ) ,
443
443
"Attempt to create a register reference with incompatible id and data length"
444
444
) ;
0 commit comments