From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202512 header.b=rUJS1b2e; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 073635A0624 for ; Tue, 13 Jan 2026 04:54:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202512; t=1768276457; bh=dzmVo4yS0xAiVxXCCUSWCwhblNvZwTOn+AqAVUodW/o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rUJS1b2eViJXxocO2b9TzsccHBJxvvaMOoU2Ooj3DJI1C/GdNvtDc3q+lZ/kuvqVT fIFyTIBW1j7O7EVJc4XFKbr15cj3Y/o5Zii0rjukf3BShrJWdYrg4eX2ru8HhbVQ2q ut56Lghv1ZxfVKlXnRi7gCaL7IRiKpN4CblQHXBKnET7JazC///p6K5lz3iX83/K7j 5Ew0x6LzWmNBRaGEiNGhwIGGsKv8VEjtLmd2iscmcvCmovNEa92PPnGalZeJRtVts6 uzmBHV/ON3nZ3zcVkxYa1KvJhyhY5+dJboSxZ2ISrujrWmJJMpLGPyozTHD9Ke0w3S NzPlsk8r6V4Bg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dqwNT6b8Gz4wRB; Tue, 13 Jan 2026 14:54:17 +1100 (AEDT) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH 2/3] epoll_ctl: Move u64 variant first for safer initialisation Date: Tue, 13 Jan 2026 14:54:14 +1100 Message-ID: <20260113035415.685242-3-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260113035415.685242-1-david@gibson.dropbear.id.au> References: <20260113035415.685242-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: XYYFVNVIIWQKRDUGPZJD75WKPFFSKTEN X-Message-ID-Hash: XYYFVNVIIWQKRDUGPZJD75WKPFFSKTEN X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: cppcheck-2.19.1 pointed out that an initialiser like: union epoll_ref foo = { 0 }; doesn't necessarily zero the whole union, because the first variant listed may not be the full length. I don't think this is actually broken in practice, but I'm not 100% certain about that. In any case, make it more clearly correct, and stop cppcheck complaining by moving the @u64 variant to be the first one. Signed-off-by: David Gibson --- epoll_ctl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/epoll_ctl.h b/epoll_ctl.h index 3f802e76..2c103cde 100644 --- a/epoll_ctl.h +++ b/epoll_ctl.h @@ -17,6 +17,7 @@ /** * union epoll_ref - Breakdown of reference for epoll fd bookkeeping + * @u64: Opaque reference for epoll_ctl() and epoll_wait() * @type: Type of fd (tells us what to do with events) * @fd: File descriptor number (implies < 2^24 total descriptors) * @flow: Index of the flow this fd is linked to @@ -25,9 +26,9 @@ * @data: Data handled by protocol handlers * @nsdir_fd: netns dirfd for fallback timer checking if namespace is gone * @queue: vhost-user queue index for this fd - * @u64: Opaque reference for epoll_ctl() and epoll_wait() */ union epoll_ref { + uint64_t u64; struct { enum epoll_type type:8; int32_t fd:FD_REF_BITS; @@ -40,7 +41,6 @@ union epoll_ref { int queue; }; }; - uint64_t u64; }; static_assert(sizeof(union epoll_ref) <= sizeof(union epoll_data), "epoll_ref must have same size as epoll_data"); -- 2.52.0