Skip to content

Commit 90ea096

Browse files
committed
macOS: don't keep variable matchDict
1 parent 3077f88 commit 90ea096

File tree

7 files changed

+7
-29
lines changed

7 files changed

+7
-29
lines changed

src/detection/battery/battery_apple.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,8 @@ static double detectBatteryTemp(void)
1717

1818
const char* ffDetectBattery(FFBatteryOptions* options, FFlist* results)
1919
{
20-
CFMutableDictionaryRef matchDict = IOServiceMatching("AppleSmartBattery");
21-
if (matchDict == NULL)
22-
return "IOServiceMatching(\"AppleSmartBattery\") failed";
23-
2420
io_iterator_t iterator;
25-
if(IOServiceGetMatchingServices(MACH_PORT_NULL, matchDict, &iterator) != kIOReturnSuccess)
21+
if(IOServiceGetMatchingServices(MACH_PORT_NULL, IOServiceMatching("AppleSmartBattery"), &iterator) != kIOReturnSuccess)
2622
return "IOServiceGetMatchingServices() failed";
2723

2824
io_registry_entry_t registryEntry;

src/detection/brightness/brightness_apple.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,8 @@ static const char* detectWithDdcci(FF_MAYBE_UNUSED const FFDisplayServerResult*
5757
if (!IOAVServiceCreate || !IOAVServiceReadI2C)
5858
return "IOAVService is not available";
5959

60-
CFMutableDictionaryRef matchDict = IOServiceMatching("DCPAVServiceProxy");
61-
if (matchDict == NULL)
62-
return "IOServiceMatching(\"DCPAVServiceProxy\") failed";
63-
6460
io_iterator_t iterator;
65-
if(IOServiceGetMatchingServices(MACH_PORT_NULL, matchDict, &iterator) != kIOReturnSuccess)
61+
if(IOServiceGetMatchingServices(MACH_PORT_NULL, IOServiceMatching("DCPAVServiceProxy"), &iterator) != kIOReturnSuccess)
6662
return "IOServiceGetMatchingServices() failed";
6763

6864
FF_STRBUF_AUTO_DESTROY location = ffStrbufCreate();

src/detection/cpu/cpu_apple.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,8 @@ static const char* detectFrequency(FFCPUResult* cpu)
2929
{
3030
// https://github.com/giampaolo/psutil/pull/2222/files
3131

32-
CFMutableDictionaryRef matchDict = IOServiceMatching("AppleARMIODevice");
33-
if (matchDict == NULL)
34-
return "IOServiceMatching(\"AppleARMIODevice\") failed";
35-
3632
io_iterator_t iterator;
37-
if(IOServiceGetMatchingServices(MACH_PORT_NULL, matchDict, &iterator) != kIOReturnSuccess)
33+
if(IOServiceGetMatchingServices(MACH_PORT_NULL, IOServiceMatching("AppleARMIODevice"), &iterator) != kIOReturnSuccess)
3834
return "IOServiceGetMatchingServices() failed";
3935

4036
io_registry_entry_t registryEntry;

src/detection/disk/disk_bsd.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@ void detectDiskType(FFDisk* disk) // Not thread safe
5353

5454
io_iterator_t iterator;
5555
char temp = *numEnd; *numEnd = '\0'; // Check for root disk directly
56-
CFMutableDictionaryRef matchDict = IOBSDNameMatching(MACH_PORT_NULL, 0, disk->mountFrom.chars + strlen("/dev/"));
5756
*numEnd = temp;
58-
if(IOServiceGetMatchingServices(MACH_PORT_NULL, matchDict, &iterator) == kIOReturnSuccess)
57+
if(IOServiceGetMatchingServices(MACH_PORT_NULL, IOBSDNameMatching(MACH_PORT_NULL, 0, disk->mountFrom.chars + strlen("/dev/")), &iterator) == kIOReturnSuccess)
5958
{
6059
for (io_registry_entry_t registryEntry = IOIteratorNext(iterator); registryEntry; IORegistryEntryGetParentEntry(registryEntry, kIOServicePlane, &registryEntry))
6160
{

src/detection/gpu/gpu_apple.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@ static double detectGpuTemp(const FFstrbuf* gpuName)
3030

3131
const char* ffDetectGPUImpl(const FFGPUOptions* options, FFlist* gpus)
3232
{
33-
CFMutableDictionaryRef matchDict = IOServiceMatching(kIOAcceleratorClassName);
3433
io_iterator_t iterator;
35-
if(IOServiceGetMatchingServices(MACH_PORT_NULL, matchDict, &iterator) != kIOReturnSuccess)
34+
if(IOServiceGetMatchingServices(MACH_PORT_NULL, IOServiceMatching(kIOAcceleratorClassName), &iterator) != kIOReturnSuccess)
3635
return "IOServiceGetMatchingServices() failed";
3736

3837
io_registry_entry_t registryEntry;

src/detection/poweradapter/poweradapter_apple.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,8 @@
66

77
const char* ffDetectPowerAdapterImpl(FFlist* results)
88
{
9-
CFMutableDictionaryRef matchDict = IOServiceMatching("AppleSmartBattery");
10-
if (matchDict == NULL)
11-
return "IOServiceMatching(\"AppleSmartBattery\") failed";
12-
139
io_iterator_t iterator;
14-
if(IOServiceGetMatchingServices(MACH_PORT_NULL, matchDict, &iterator) != kIOReturnSuccess)
10+
if(IOServiceGetMatchingServices(MACH_PORT_NULL, IOServiceMatching("AppleSmartBattery"), &iterator) != kIOReturnSuccess)
1511
return "IOServiceGetMatchingServices() failed";
1612

1713
io_registry_entry_t registryEntry;

src/detection/temps/temps_apple.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,12 +140,8 @@ static const char *smcReadSmcVal(io_connect_t conn, const UInt32Char_t key, SmcV
140140

141141
static const char *smcOpen(io_connect_t *conn)
142142
{
143-
CFMutableDictionaryRef matchDict = IOServiceMatching("AppleSMC");
144-
if (matchDict == NULL)
145-
return "IOServiceMatching(\"AppleSmartBattery\") failed";
146-
147143
io_iterator_t iterator;
148-
if (IOServiceGetMatchingServices(MACH_PORT_NULL, matchDict, &iterator) != kIOReturnSuccess)
144+
if (IOServiceGetMatchingServices(MACH_PORT_NULL, IOServiceMatching("AppleSMC"), &iterator) != kIOReturnSuccess)
149145
return "IOServiceGetMatchingServices() failed";
150146

151147
io_object_t device = IOIteratorNext(iterator);

0 commit comments

Comments
 (0)