Fix gcc uninitialized warning in FreeBSD zio_crypt.c
With gcc we are seeing the following -Werror warning:
In file included from /workspace/src/sys/contrib/openzfs/include/os/freebsd/spl/sys/sunddi.h:28,
from /workspace/src/sys/contrib/openzfs/include/sys/zfs_context.h:69:
In function 'zfs_uio_init',
inlined from 'zio_do_crypt_data' at /workspace/src/sys/contrib/openzfs/module/os/freebsd/zfs/zio_crypt.c:1690:2:
/workspace/src/sys/contrib/openzfs/include/os/freebsd/spl/sys/uio.h:102:45: error: 'puio_s.uio_offset' is used uninitialized [-Werror=uninitialized]
102 | zfs_uio_soffset(uio) = uio_s->uio_offset;
| ~~~~~^~~~~~~~~~~~
/workspace/src/sys/contrib/openzfs/module/os/freebsd/zfs/zio_crypt.c: In function 'zio_do_crypt_data':
/workspace/src/sys/contrib/openzfs/module/os/freebsd/zfs/zio_crypt.c:1683:20: note: 'puio_s' declared here
1683 | struct uio puio_s, cuio_s;
| ^~~~~~
In function 'zfs_uio_init',
inlined from 'zio_do_crypt_data' at /workspace/src/sys/contrib/openzfs/module/os/freebsd/zfs/zio_crypt.c:1691:2:
/workspace/src/sys/contrib/openzfs/include/os/freebsd/spl/sys/uio.h:102:45: error: 'cuio_s.uio_offset' is used uninitialized [-Werror=uninitialized]
102 | zfs_uio_soffset(uio) = uio_s->uio_offset;
| ~~~~~^~~~~~~~~~~~
/workspace/src/sys/contrib/openzfs/module/os/freebsd/zfs/zio_crypt.c: In function 'zio_do_crypt_data':
/workspace/src/sys/contrib/openzfs/module/os/freebsd/zfs/zio_crypt.c:1683:28: note: 'cuio_s' declared here
1683 | struct uio puio_s, cuio_s;
| ^~~~~~
Fix gcc uninitialized warning in FreeBSD zio_crypt.c
With gcc we are seeing the following -Werror warning:
Indeed,
zfs_uio_init()
does:while the code in
zio_crypt.c
has:So between the declaration of
puio_s
andcuio_s
, there is no initialization of these variables beforezfs_uio_init()
gets called.Similar to the Linux variant of
zio_crypt.c
, I think it would be better to memset the structspuio_s
andcuis_s
before callingzfs_uio_init()
.