diff options
author | Attila Fülöp <[email protected]> | 2021-06-24 01:57:06 +0200 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2021-06-24 13:13:40 -0700 |
commit | 088712793eb1a9cca2496edc4b63d4d79e4f1d9c (patch) | |
tree | 96b402b4722ac54bd887e8df3e3380aaf04076f0 /contrib | |
parent | e0886c96a81e411e018f70bca362f9d284f003bf (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); |