Skip to content

Commit

Permalink
Replace IOMainPort/IOMasterPort() and kIOMainPortDefault/kIOMasterPor…
Browse files Browse the repository at this point in the history
…tDefault with NULL
  • Loading branch information
kyz committed Jul 25, 2022
1 parent a1701dc commit 55411f1
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 13 deletions.
4 changes: 1 addition & 3 deletions disk/iostat_darwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,15 @@ static int fillstat(io_registry_entry_t d, DriveStats *stat);
int
gopsutil_v3_readdrivestat(DriveStats a[], int n)
{
mach_port_t port;
CFMutableDictionaryRef match;
io_iterator_t drives;
io_registry_entry_t d;
kern_return_t status;
int na, rv;

IOMainPort(bootstrap_port, &port);
match = IOServiceMatching("IOMedia");
CFDictionaryAddValue(match, CFSTR(kIOMediaWholeKey), kCFBooleanTrue);
status = IOServiceGetMatchingServices(port, match, &drives);
status = IOServiceGetMatchingServices((mach_port_t) NULL, match, &drives);
if(status != KERN_SUCCESS)
return -1;

Expand Down
4 changes: 0 additions & 4 deletions disk/iostat_darwin.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,3 @@ struct CPUStats {
};

extern int gopsutil_v3_readdrivestat(DriveStats a[], int n);

#if (MAC_OS_X_VERSION_MIN_REQUIRED < 120000) // Before macOS 12 Monterey
#define IOMainPort IOMasterPort
#endif
2 changes: 1 addition & 1 deletion host/smc_darwin.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ kern_return_t gopsutil_v3_open_smc(void) {
kern_return_t result;
io_service_t service;

service = IOServiceGetMatchingService(kIOMainPortDefault,
service = IOServiceGetMatchingService((mach_port_t) NULL,
IOServiceMatching(IOSERVICE_SMC));
if (service == 0) {
// Note: IOServiceMatching documents 0 on failure
Expand Down
5 changes: 0 additions & 5 deletions host/smc_darwin.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,4 @@ kern_return_t gopsutil_v3_open_smc(void);
kern_return_t gopsutil_v3_close_smc(void);
double gopsutil_v3_get_temperature(char *);

#if (MAC_OS_X_VERSION_MIN_REQUIRED < 120000) // Before macOS 12 Monterey
#define kIOMainPortDefault kIOMasterPortDefault
#endif


#endif // __SMC_H__

0 comments on commit 55411f1

Please sign in to comment.