Skip to content

Commit 6bb8848

Browse files
antonok-edmmvines
authored andcommitted
address review feedback - use u64 instead of usize
1 parent adbf31b commit 6bb8848

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

runtime/src/append_vec.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use solana_sdk::{
1515
};
1616
use std::{
1717
borrow::Borrow,
18+
convert::TryFrom,
1819
fs::{remove_file, OpenOptions},
1920
io,
2021
io::{Seek, SeekFrom, Write},
@@ -33,10 +34,7 @@ macro_rules! u64_align {
3334
};
3435
}
3536

36-
#[cfg(target_pointer_width = "64")]
37-
const MAXIMUM_APPEND_VEC_FILE_SIZE: usize = 16 * 1024 * 1024 * 1024; // 16 GiB
38-
#[cfg(target_pointer_width = "32")]
39-
const MAXIMUM_APPEND_VEC_FILE_SIZE: usize = 2 * 1024 * 1024 * 1024; // 2 GiB
37+
const MAXIMUM_APPEND_VEC_FILE_SIZE: u64 = 16 * 1024 * 1024 * 1024; // 16 GiB
4038

4139
pub type StoredMetaWriteVersion = u64;
4240

@@ -259,7 +257,10 @@ impl AppendVec {
259257
std::io::ErrorKind::Other,
260258
format!("too small file size {} for AppendVec", file_size),
261259
))
262-
} else if file_size > MAXIMUM_APPEND_VEC_FILE_SIZE {
260+
} else if usize::try_from(MAXIMUM_APPEND_VEC_FILE_SIZE)
261+
.map(|max| file_size > max)
262+
.unwrap_or(true)
263+
{
263264
Err(std::io::Error::new(
264265
std::io::ErrorKind::Other,
265266
format!("too large file size {} for AppendVec", file_size),

0 commit comments

Comments
 (0)