[pbs-devel] [PATCH vma-to-pbs 3/4] replace hard coded values with constants

Fabian Grünbichler f.gruenbichler at proxmox.com
Wed Sep 4 11:16:42 CEST 2024


On July 24, 2024 6:18 pm, Filip Schauer wrote:
> Signed-off-by: Filip Schauer <f.schauer at proxmox.com>
> ---
>  src/vma.rs     | 2 +-
>  src/vma2pbs.rs | 5 +++--
>  2 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/src/vma.rs b/src/vma.rs
> index 518de8a..63ee3b5 100644
> --- a/src/vma.rs
> +++ b/src/vma.rs
> @@ -22,7 +22,7 @@ const VMA_MAX_CONFIGS: usize = 256;
>  
>  /// Maximum number of block devices
>  /// See VMA Header in pve-qemu.git/vma_spec.txt
> -const VMA_MAX_DEVICES: usize = 256;
> +pub const VMA_MAX_DEVICES: usize = 256;
>  
>  /// VMA magic string
>  /// See VMA Header in pve-qemu.git/vma_spec.txt
> diff --git a/src/vma2pbs.rs b/src/vma2pbs.rs
> index 3e9689d..5c0d03f 100644
> --- a/src/vma2pbs.rs
> +++ b/src/vma2pbs.rs
> @@ -175,11 +175,12 @@ where
>  fn register_block_devices<T>(
>      vma_reader: &VmaReader<T>,
>      pbs: *mut ProxmoxBackupHandle,
> -) -> Result<[Option<BlockDeviceInfo>; 256], Error>
> +) -> Result<[Option<BlockDeviceInfo>; VMA_MAX_DEVICES], Error>
>  where
>      T: Read,
>  {
> -    let mut block_device_infos: [Option<BlockDeviceInfo>; 256] = [None; 256];
> +    let mut block_device_infos: [Option<BlockDeviceInfo>; VMA_MAX_DEVICES] =
> +        [None; VMA_MAX_DEVICES];
>      let mut pbs_err: *mut c_char = ptr::null_mut();
>  
>      for device_id in 0..255 {

this range here is also derived from the constant value, and should
probably be actually derived from it?

there's another `take(255)` call in the same file further below where I
guess the same applies as well..

> -- 
> 2.39.2
> 
> 
> 
> _______________________________________________
> pbs-devel mailing list
> pbs-devel at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
> 
> 
> 




More information about the pbs-devel mailing list