mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
gcc 11 cleanup
Compiling with gcc 11.1.0 produces three new warnings. Change the code slightly to avoid them. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Matthew Ahrens <mahrens@delphix.com> Signed-off-by: Attila Fülöp <attila@fueloep.org> Closes #12130 Closes #12188 Closes #12237
This commit is contained in:
committed by
Tony Hutter
parent
820c95750b
commit
fb9eee4cc2
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user