aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2026-01-07 12:46:03 +1100
committerStefano Brivio <sbrivio@redhat.com>2026-01-10 19:27:43 +0100
commit4a0c1a6f728a808822d5d912fc968470659ff97d (patch)
treec7d9efe7f47070133af0bead7d949e5c4f2a81eb
parent0bd2e6883d560c038e49a3cf68984d63f87ca67a (diff)
downloadpasst-4a0c1a6f728a808822d5d912fc968470659ff97d.tar
passt-4a0c1a6f728a808822d5d912fc968470659ff97d.tar.gz
passt-4a0c1a6f728a808822d5d912fc968470659ff97d.tar.bz2
passt-4a0c1a6f728a808822d5d912fc968470659ff97d.tar.lz
passt-4a0c1a6f728a808822d5d912fc968470659ff97d.tar.xz
passt-4a0c1a6f728a808822d5d912fc968470659ff97d.tar.zst
passt-4a0c1a6f728a808822d5d912fc968470659ff97d.zip
migrate: Don't use terminator element for versions[] array
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 <david@gibson.dropbear.id.au> Reviewed-by: Laurent Vivier <lvivier@redhat.com> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--migrate.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/migrate.c b/migrate.c
index 48d63a0..13bacab 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 */
@@ -177,9 +176,9 @@ static int migrate_source(struct ctx *c, int fd)
*/
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 +195,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); i++)
+ if (versions[i].id <= id && versions[i].id >= compat_id)
+ return &versions[i];
errno = ENOTSUP;
err("Unsupported device state version: %u", id);