diff options
author | Attila Fülöp <[email protected]> | 2021-06-24 01:57:06 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2021-06-23 17:57:06 -0600 |
commit | 1b610ae45f59bd15e75b2bb058c4d9ab552e9214 (patch) | |
tree | 8512674af613ae721b4e5ad646e3fc1f37e36df6 /contrib | |
parent | 63f4b959a6826088c3eda7d17326a6bcf2f4ced8 (diff) |
gcc 11 cleanup
Compiling with gcc 11.1.0 produces three new warnings.
Change the code slightly to avoid them.
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Matthew Ahrens <[email protected]>
Signed-off-by: Attila Fülöp <[email protected]>
Closes #12130
Closes #12188
Closes #12237
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/pam_zfs_key/pam_zfs_key.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/contrib/pam_zfs_key/pam_zfs_key.c b/contrib/pam_zfs_key/pam_zfs_key.c index 4cafc37b9..0856c7534 100644 --- a/contrib/pam_zfs_key/pam_zfs_key.c +++ b/contrib/pam_zfs_key/pam_zfs_key.c @@ -82,7 +82,11 @@ alloc_pw_size(size_t len) return (NULL); } pw->len = len; - pw->value = malloc(len); + /* + * The use of malloc() triggers a spurious gcc 11 -Wmaybe-uninitialized + * warning in the mlock() function call below, so use calloc(). + */ + pw->value = calloc(len, 1); if (!pw->value) { free(pw); return (NULL); @@ -99,7 +103,11 @@ alloc_pw_string(const char *source) return (NULL); } pw->len = strlen(source) + 1; - pw->value = malloc(pw->len); + /* + * The use of malloc() triggers a spurious gcc 11 -Wmaybe-uninitialized + * warning in the mlock() function call below, so use calloc(). + */ + pw->value = calloc(pw->len, 1); if (!pw->value) { free(pw); return (NULL); |