Skip to content

Commit 5fb1286

Browse files
committed
Battery (Windows): simplify code
1 parent a4cace4 commit 5fb1286

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/detection/battery/battery_windows.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#include "battery.h"
2+
3+
#include "common/io/io.h"
24
#include "util/windows/unicode.h"
35
#include "util/mallocHelper.h"
46
#include "util/smbiosHelper.h"
@@ -20,11 +22,6 @@ NtPowerInformation(
2022
OUT PVOID OutputBuffer OPTIONAL,
2123
IN ULONG OutputBufferLength);
2224

23-
static inline void wrapCloseHandle(HANDLE* handle)
24-
{
25-
if(*handle)
26-
CloseHandle(*handle);
27-
}
2825
static inline void wrapSetupDiDestroyDeviceInfoList(HDEVINFO* hdev)
2926
{
3027
if(*hdev)
@@ -52,7 +49,7 @@ static const char* detectWithSetupApi(FFBatteryOptions* options, FFlist* results
5249
if(!SetupDiGetDeviceInterfaceDetailW(hdev, &did, pdidd, cbRequired, &cbRequired, NULL))
5350
continue;
5451

55-
HANDLE __attribute__((__cleanup__(wrapCloseHandle))) hBattery =
52+
HANDLE FF_AUTO_CLOSE_FD hBattery =
5653
CreateFileW(pdidd->DevicePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
5754

5855
if(hBattery == INVALID_HANDLE_VALUE)

0 commit comments

Comments
 (0)