From 7692f7a6c595cda34c42706a8134e19a5d2fc04f Mon Sep 17 00:00:00 2001 From: ddidderr Date: Mon, 20 Jul 2026 10:16:12 +0200 Subject: [PATCH] refactor(cli): move LZ4 block-size policy leaf to Rust Export FIO_LZ4_GetBlockSize_FromBlockId directly from Rust under the existing caller symbol and remove the redundant C forwarding wrapper. Preserve the block-ID formula and cover its boundary values in the focused Rust test. Test Plan: - worker capped nightly rustfmt check - worker git diff --check - full serial capped native and upstream suites to run at the next parent gate --- programs/fileio.c | 7 +------ rust/src/fileio_prefs.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/programs/fileio.c b/programs/fileio.c index 5688d43b9..866227af3 100644 --- a/programs/fileio.c +++ b/programs/fileio.c @@ -588,7 +588,7 @@ int FIO_rust_decompressLz4Frame( void FIO_rust_displayCompressionParameters(const FIO_prefs_t* prefs); #ifdef ZSTD_LZ4COMPRESS -int FIO_rust_LZ4_GetBlockSize_FromBlockId(int id); +int FIO_LZ4_GetBlockSize_FromBlockId(int id); #endif @@ -2228,11 +2228,6 @@ FIO_compressLzmaFrame(cRess_t* ress, #define LZ4F_max64KB max64KB #endif -static int FIO_LZ4_GetBlockSize_FromBlockId (int id) -{ - return FIO_rust_LZ4_GetBlockSize_FromBlockId(id); -} - typedef struct { LZ4F_compressionContext_t ctx; LZ4F_preferences_t prefs; diff --git a/rust/src/fileio_prefs.rs b/rust/src/fileio_prefs.rs index 4f5bafd2e..b7b79ad70 100644 --- a/rust/src/fileio_prefs.rs +++ b/rust/src/fileio_prefs.rs @@ -2012,7 +2012,7 @@ fn lz4_block_size_from_block_id(id: c_int) -> c_int { } #[no_mangle] -pub extern "C" fn FIO_rust_LZ4_GetBlockSize_FromBlockId(id: c_int) -> c_int { +pub extern "C" fn FIO_LZ4_GetBlockSize_FromBlockId(id: c_int) -> c_int { lz4_block_size_from_block_id(id) } @@ -3678,11 +3678,11 @@ mod tests { } #[test] - fn lz4_block_size_shim_preserves_the_block_id_formula() { - assert_eq!(FIO_rust_LZ4_GetBlockSize_FromBlockId(0), 1 << 8); - assert_eq!(FIO_rust_LZ4_GetBlockSize_FromBlockId(1), 1 << 10); - assert_eq!(FIO_rust_LZ4_GetBlockSize_FromBlockId(3), 1 << 14); - assert_eq!(FIO_rust_LZ4_GetBlockSize_FromBlockId(4), 1 << 16); + fn lz4_block_size_policy_preserves_block_id_boundaries() { + assert_eq!(FIO_LZ4_GetBlockSize_FromBlockId(0), 1 << 8); + assert_eq!(FIO_LZ4_GetBlockSize_FromBlockId(1), 1 << 10); + assert_eq!(FIO_LZ4_GetBlockSize_FromBlockId(3), 1 << 14); + assert_eq!(FIO_LZ4_GetBlockSize_FromBlockId(4), 1 << 16); } #[test]