]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Fix unitialized variable in `zstream redup` command
authorBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 23 Apr 2020 22:54:38 +0000 (15:54 -0700)
committerGitHub <noreply@github.com>
Thu, 23 Apr 2020 22:54:38 +0000 (15:54 -0700)
Fix uninitialized variable in `zstream redup` command.  The compiler
may determine the 'stream_offset' variable can be uninitialized
because not all rdt_lookup() exit paths set it.  This should never
happen in practice as documented by the assert, but initialize it
regardless to resolve the warning.

Reviewed-by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #10241
Closes #10244

cmd/zstream/zstream_redup.c

index 9ed8df337f01cbc6ffe6421b013f29af0520be88..379025ce59e5a18eb2117b96ec2bef8f350ccb1b 100644 (file)
@@ -308,7 +308,7 @@ zfs_redup_stream(int infd, int outfd, boolean_t verbose)
                         * record with the found WRITE record, but with
                         * drr_object,drr_offset,drr_toguid replaced with ours.
                         */
-                       uint64_t stream_offset;
+                       uint64_t stream_offset = 0;
                        rdt_lookup(&rdt, drrwb.drr_refguid,
                            drrwb.drr_refobject, drrwb.drr_refoffset,
                            &stream_offset);