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=FzVr/1/d; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id C00AC5A068E for ; Wed, 07 Jan 2026 01:16:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202512; t=1767744971; bh=QqK7szTWlxLdbMLcwcU2rLPzqAlLTziCEJzc0OSfmXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FzVr/1/dlavnIawbBz+zYnYsEmRJ1OF5ijdhfGkgLyBj/vdpPc1vu2uokNpRsQz8M OSG/plUgNdMnEeidJt4kYt9YPRvFnadK4tIPPe6TXgZW0epgHRMR6RYN4yfma0UUry v10gqC6tRtWZ6AKMAMDkbNlHRfCdRhGJTWBx33+3EX3cH+8Jt5kXYooWohH1COHT0a 844t/sf08vybDlKTxQ3QmwT1KA9Fb47AxvIyYfh43mAuuPTdcUbk6Ypz9xuNI+UNum 4crFb2QfFU1ilzKKEegksv++GK8DYs/NS1yNpqRzZuEd0BbaCzYTEt+eIXwYGsdPbh DRwR7NP2G9iNQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dm7qb1Swmz4wR9; Wed, 07 Jan 2026 11:16:11 +1100 (AEDT) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v2 2/5] migrate: Don't use terminator element for versions[] array Date: Wed, 7 Jan 2026 11:16:06 +1100 Message-ID: <20260107001609.910615-3-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260107001609.910615-1-david@gibson.dropbear.id.au> References: <20260107001609.910615-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: 3KLJIFSOG6H54LFP7FAUDZNXFRPKAPIA X-Message-ID-Hash: 3KLJIFSOG6H54LFP7FAUDZNXFRPKAPIA 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 , Laurent Vivier 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: When scanning the versions[] array we use a dummy entry to detect when we're finished. Use ARRAY_SIZE() instead, which is almost as easy, a little safer, and doesn't cause clang-tidy 21.1.7 to complain. Signed-off-by: David Gibson Reviewed-by: Laurent Vivier --- migrate.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/migrate.c b/migrate.c index 48d63a07..a70ea7b7 100644 --- a/migrate.c +++ b/migrate.c @@ -123,7 +123,6 @@ static const struct migrate_version versions[] = { * MSS and omitted timestamps, which meant it usually wouldn't work. * Therefore we don't attempt to support compatibility with it. */ - { 0 }, }; /* Current encoding version */ @@ -180,6 +179,7 @@ static const struct migrate_version *migrate_target_read_header(int fd) const struct migrate_version *v; struct migrate_header h; uint32_t id, compat_id; + unsigned i; if (read_all_buf(fd, &h, sizeof(h))) return NULL; @@ -196,9 +196,9 @@ static const struct migrate_version *migrate_target_read_header(int fd) return NULL; } - for (v = versions; v->id; v++) - if (v->id <= id && v->id >= compat_id) - return v; + for (i = 0; i < ARRAY_SIZE(versions); v++) + if (versions[i].id <= id && versions[i].id >= compat_id) + return &versions[i]; errno = ENOTSUP; err("Unsupported device state version: %u", id); -- 2.52.0