From b983586eb381ba3fd80b84312c5ac49eb0cb2af0 Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Thu, 20 Nov 2025 15:15:21 +0530 Subject: [PATCH] daemon: modernize send_file_write() with compound literal Signed-off-by: Susant Sahani --- daemon/proto.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/daemon/proto.c b/daemon/proto.c index 806664b18..0f75dfec9 100644 --- a/daemon/proto.c +++ b/daemon/proto.c @@ -469,7 +469,6 @@ static int send_chunk (const guestfs_chunk *); int send_file_write (const void *buf, size_t len) { - guestfs_chunk chunk; int cancel; if (len > GUESTFS_MAX_CHUNK_SIZE) { @@ -480,15 +479,13 @@ send_file_write (const void *buf, size_t len) cancel = check_for_library_cancellation (); - if (cancel) { - chunk.cancel = 1; - chunk.data.data_len = 0; - chunk.data.data_val = NULL; - } else { - chunk.cancel = 0; - chunk.data.data_len = len; - chunk.data.data_val = (char *) buf; - } + const guestfs_chunk chunk = { + .cancel = cancel ? 1 : 0, + .data = { + .data_len = cancel ? 0 : len, + .data_val = cancel ? NULL : (char *)buf + } + }; if (send_chunk (&chunk) == -1) return -1;