From 0ee2d5b2a9a872a886f63bf4326efeba729928b8 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 4 Apr 2022 11:27:58 +0200 Subject: virt: move array iterators to smaller scope, and use right type --- src/basic/virt.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/basic/virt.c') diff --git a/src/basic/virt.c b/src/basic/virt.c index d3ac64c7e1..4194c239ea 100644 --- a/src/basic/virt.c +++ b/src/basic/virt.c @@ -173,7 +173,6 @@ static Virtualization detect_vm_dmi_vendor(void) { for (size_t i = 0; i < ELEMENTSOF(dmi_vendors); i++) { _cleanup_free_ char *s = NULL; - unsigned j; r = read_one_line_file(dmi_vendors[i], &s); if (r < 0) { @@ -183,7 +182,7 @@ static Virtualization detect_vm_dmi_vendor(void) { return r; } - for (j = 0; j < ELEMENTSOF(dmi_vendor_table); j++) + for (size_t j = 0; j < ELEMENTSOF(dmi_vendor_table); j++) if (startswith(s, dmi_vendor_table[j].vendor)) { log_debug("Virtualization %s found in DMI (%s)", s, dmi_vendors[i]); return dmi_vendor_table[j].id; @@ -610,8 +609,6 @@ static int running_in_cgroupns(void) { } static Virtualization detect_container_files(void) { - unsigned i; - static const struct { const char *file_path; Virtualization id; @@ -624,7 +621,7 @@ static Virtualization detect_container_files(void) { { "/.dockerenv", VIRTUALIZATION_DOCKER }, }; - for (i = 0; i < ELEMENTSOF(container_file_table); i++) { + for (size_t i = 0; i < ELEMENTSOF(container_file_table); i++) { if (access(container_file_table[i].file_path, F_OK) >= 0) return container_file_table[i].id; -- cgit v1.2.3