]> git.ipfire.org Git - pakfire.git/commitdiff
libpakfire: arch: Refactor search using a static array size
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 10 Jan 2021 16:10:58 +0000 (16:10 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 10 Jan 2021 16:10:58 +0000 (16:10 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/arch.c

index 5cf3017302bb97037252fab2b262f7587c01c78d..6b3e7f618d095eddfce7adb62379befc7e6d706a 100644 (file)
@@ -76,11 +76,14 @@ static const struct pakfire_arch PAKFIRE_ARCHES[] = {
                .name = "armv5tel",
                .platform = "arm",
        },
-       NULL,
 };
 
 static const struct pakfire_arch* pakfire_arch_find(const char* name) {
-       for (const struct pakfire_arch* arch = PAKFIRE_ARCHES; arch; arch++) {
+       const size_t length = sizeof(PAKFIRE_ARCHES) / sizeof(*PAKFIRE_ARCHES);
+
+       for (unsigned int i = 0; i < length; i++) {
+               const struct pakfire_arch* arch = &PAKFIRE_ARCHES[i];
+
                if (strcmp(arch->name, name) == 0)
                        return arch;
        }