]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Fix -Wattribute-warning in dsl layer
authorBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 20 Jun 2022 21:13:26 +0000 (21:13 +0000)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 27 Jun 2022 21:19:12 +0000 (14:19 -0700)
The memcpy(), memmove(), and memset() functions have been annotated
to perform bounds checking when using FORTIFY_SOURCE.  A warning is
now generted when writing beyond the end of the specified field.

Alternately, the new struct_group() macro could be used to create
an anonymous union member for use by memcpy().  However, since this
is the only place the macro would be helpful it's preferable to
restructure the code slights to avoid the need for additional
compatibility code when the macro does not exist.

https://lore.kernel.org/lkml/20211118183807.1283332-1-keescook@chromium.org/T/

Reviewed-by: Ryan Moeller <ryan@iXsystems.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #13528
Closes #13575

module/zfs/dsl_bookmark.c

index 44fc399a6b61d2de5cba63ea3d0bc5626c2c3f26..5d9b674f9d1b0089c3c17a689960f0b523f59347 100644 (file)
@@ -346,6 +346,8 @@ dsl_bookmark_set_phys(zfs_bookmark_phys_t *zbm, dsl_dataset_t *snap)
        spa_t *spa = dsl_dataset_get_spa(snap);
        objset_t *mos = spa_get_dsl(spa)->dp_meta_objset;
        dsl_dataset_phys_t *dsp = dsl_dataset_phys(snap);
+
+       memset(zbm, 0, sizeof (zfs_bookmark_phys_t));
        zbm->zbm_guid = dsp->ds_guid;
        zbm->zbm_creation_txg = dsp->ds_creation_txg;
        zbm->zbm_creation_time = dsp->ds_creation_time;
@@ -379,10 +381,6 @@ dsl_bookmark_set_phys(zfs_bookmark_phys_t *zbm, dsl_dataset_t *snap)
                    &zbm->zbm_compressed_freed_before_next_snap,
                    &zbm->zbm_uncompressed_freed_before_next_snap);
                dsl_dataset_rele(nextds, FTAG);
-       } else {
-               memset(&zbm->zbm_flags, 0,
-                   sizeof (zfs_bookmark_phys_t) -
-                   offsetof(zfs_bookmark_phys_t, zbm_flags));
        }
 }