From 3aaa95e0a09ef1d838cc8dd8b89e7caaeba415e6 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 21 Jun 2018 18:50:07 +0200 Subject: [PATCH] efi: add cleanup handler for closing file descriptors --- src/boot/efi/util.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/boot/efi/util.h b/src/boot/efi/util.h index 3e6e610289..6d1a52f618 100644 --- a/src/boot/efi/util.h +++ b/src/boot/efi/util.h @@ -38,3 +38,10 @@ static inline void FreePoolp(void *p) { #define _cleanup_(x) __attribute__((cleanup(x))) #define _cleanup_freepool_ _cleanup_(FreePoolp) + +static inline void FileHandleClosep(EFI_FILE_HANDLE *handle) { + if (!*handle) + return; + + uefi_call_wrapper((*handle)->Close, 1, *handle); +}