lib: Use compound initialization for buffer in disk creation

Signed-off-by: Susant Sahani <ssahani@redhat.com>
This commit is contained in:
Susant Sahani
2025-11-26 19:18:08 +05:30
committed by Richard W.M. Jones
parent cf6ac9aeba
commit 3aaaf4f667

View File

@@ -202,13 +202,11 @@ disk_create_raw (guestfs_h *g, const char *filename, int64_t size,
}
#else
/* Slow emulation of posix_fallocate on platforms which don't have it. */
char buffer[BUFSIZ];
char buffer[BUFSIZ] = {0};
size_t remaining = size;
size_t n;
ssize_t r;
memset (buffer, 0, sizeof buffer);
while (remaining > 0) {
n = remaining > sizeof buffer ? sizeof buffer : remaining;
r = write (fd, buffer, n);