From: Lennart Poettering Date: Tue, 11 Feb 2025 18:22:09 +0000 (+0100) Subject: efi: modernize reconnect_all_drivers() a bit X-Git-Tag: v258-rc1~1280^2~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e577d7d94a738282b4dc7562871198264e3927ce;p=thirdparty%2Fsystemd.git efi: modernize reconnect_all_drivers() a bit --- diff --git a/src/boot/drivers.c b/src/boot/drivers.c index 078c6cb993a..414e27a0f40 100644 --- a/src/boot/drivers.c +++ b/src/boot/drivers.c @@ -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; }