]> git.proxmox.com Git - proxmox-backup.git/commitdiff
tape: multi-volume: fix overflow check
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Thu, 30 Dec 2021 12:03:55 +0000 (13:03 +0100)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Thu, 30 Dec 2021 12:55:33 +0000 (13:55 +0100)
the part number cannot go above 255 at the moment, but if it ever gets
bumped to a bigger integer type this boundary wouldn't cause a
compile-error. explicitly checking for overflowing u8 makes this a bit
more future-proof, and shuts up clippy as well ;)

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
src/tape/file_formats/multi_volume_writer.rs

index 8d51969e1ace05097fed6bca37a222d58b2bf183..d1b2c70bf3f7a763e2ddd0285215de3eba0455dc 100644 (file)
@@ -69,7 +69,7 @@ impl <'a> TapeWrite for MultiVolumeWriter<'a> {
         }
 
         if self.writer.is_none() {
-            if self.header.part_number >= 255 {
+            if self.header.part_number == u8::MAX {
                 proxmox_sys::io_bail!("multi-volume writer: too many parts");
             }
             self.writer = Some(