]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
efi: modernize reconnect_all_drivers() a bit
authorLennart Poettering <lennart@poettering.net>
Tue, 11 Feb 2025 18:22:09 +0000 (19:22 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 21 Feb 2025 09:04:15 +0000 (10:04 +0100)
src/boot/drivers.c

index 078c6cb993a23394eb72d16ed316905cd70635f9..414e27a0f401dca9e4d284865338f5b33fc64cb3 100644 (file)
@@ -55,15 +55,23 @@ EFI_STATUS reconnect_all_drivers(void) {
 
         /* Reconnects all handles, so that any loaded drivers can take effect. */
 
-        err = BS->LocateHandleBuffer(AllHandles, NULL, NULL, &n_handles, &handles);
-        if (err != EFI_SUCCESS)
+        err = BS->LocateHandleBuffer(
+                        AllHandles,
+                        /* Protocol= */ NULL,
+                        /* SearchKey= */ NULL,
+                        &n_handles, &handles);
+        if (!IN_SET(err, EFI_SUCCESS, EFI_NOT_FOUND))
                 return log_error_status(err, "Failed to get list of handles: %m");
 
-        for (size_t i = 0; i < n_handles; i++)
+        FOREACH_ARRAY(h, handles, n_handles)
                 /* Some firmware gives us some bogus handles (or they might become bad due to
                  * reconnecting everything). Security policy may also prevent us from doing so too.
                  * There is nothing we can realistically do on errors anyways, so just ignore them. */
-                (void) BS->ConnectController(handles[i], NULL, NULL, true);
+                (void) BS->ConnectController(
+                                *h,
+                                /* DriverImageHandle= */ NULL,
+                                /* RemainingDevicePath= */ NULL,
+                                /* Recursive= */ true);
 
         return EFI_SUCCESS;
 }