Skip to content

Commit 360136f

Browse files
authored
Merge pull request #1333 from kyz/remove-iomainport
Replace IOMainPort/IOMasterPort() and kIOMainPortDefault/kIOMasterPortDefault with NULL
2 parents 190dfee + e0400cc commit 360136f

File tree

4 files changed

+2
-14
lines changed

4 files changed

+2
-14
lines changed

disk/iostat_darwin.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,15 @@ static int fillstat(io_registry_entry_t d, DriveStats *stat);
1818
int
1919
gopsutil_v3_readdrivestat(DriveStats a[], int n)
2020
{
21-
mach_port_t port;
2221
CFMutableDictionaryRef match;
2322
io_iterator_t drives;
2423
io_registry_entry_t d;
2524
kern_return_t status;
2625
int na, rv;
2726

28-
IOMainPort(bootstrap_port, &port);
2927
match = IOServiceMatching("IOMedia");
3028
CFDictionaryAddValue(match, CFSTR(kIOMediaWholeKey), kCFBooleanTrue);
31-
status = IOServiceGetMatchingServices(port, match, &drives);
29+
status = IOServiceGetMatchingServices(0, match, &drives);
3230
if(status != KERN_SUCCESS)
3331
return -1;
3432

disk/iostat_darwin.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,3 @@ struct CPUStats {
3030
};
3131

3232
extern int gopsutil_v3_readdrivestat(DriveStats a[], int n);
33-
34-
#if (MAC_OS_X_VERSION_MIN_REQUIRED < 120000) // Before macOS 12 Monterey
35-
#define IOMainPort IOMasterPort
36-
#endif

host/smc_darwin.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ kern_return_t gopsutil_v3_open_smc(void) {
7272
kern_return_t result;
7373
io_service_t service;
7474

75-
service = IOServiceGetMatchingService(kIOMainPortDefault,
76-
IOServiceMatching(IOSERVICE_SMC));
75+
service = IOServiceGetMatchingService(0, IOServiceMatching(IOSERVICE_SMC));
7776
if (service == 0) {
7877
// Note: IOServiceMatching documents 0 on failure
7978
printf("ERROR: %s NOT FOUND\n", IOSERVICE_SMC);

host/smc_darwin.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,4 @@ kern_return_t gopsutil_v3_open_smc(void);
2929
kern_return_t gopsutil_v3_close_smc(void);
3030
double gopsutil_v3_get_temperature(char *);
3131

32-
#if (MAC_OS_X_VERSION_MIN_REQUIRED < 120000) // Before macOS 12 Monterey
33-
#define kIOMainPortDefault kIOMasterPortDefault
34-
#endif
35-
36-
3732
#endif // __SMC_H__

0 commit comments

Comments
 (0)