Skip to content

Commit

Permalink
Merge pull request #101 from younata/master
Browse files Browse the repository at this point in the history
Use kIOMainPortDefault instead of kIOMasterPortDefault when possible.
  • Loading branch information
tikhop authored Jul 29, 2022
2 parents 2b9946f + 4b2b4ec commit 5b830d6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Sources/Validation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,12 @@ func getMacAddress() -> Data?

func ioService(named name: String, wantBuiltIn: Bool) -> io_service_t?
{
let master_port = kIOMasterPortDefault
let main_port: mach_port_t
if #available(macOS 12.0, macCatalyst 15.0, *) {
main_port = kIOMainPortDefault
} else {
main_port = 0 // the kIOMasterPortDefault symbol is unavailable on xcode 14 and later.
}
var iterator = io_iterator_t()

defer
Expand All @@ -334,8 +339,8 @@ func ioService(named name: String, wantBuiltIn: Bool) -> io_service_t?
}
}

guard let matchingDict = IOBSDNameMatching(master_port, 0, name),
IOServiceGetMatchingServices(master_port, matchingDict as CFDictionary, &iterator) == KERN_SUCCESS,
guard let matchingDict = IOBSDNameMatching(main_port, 0, name),
IOServiceGetMatchingServices(main_port, matchingDict as CFDictionary, &iterator) == KERN_SUCCESS,
iterator != IO_OBJECT_NULL
else
{
Expand Down

0 comments on commit 5b830d6

Please sign in to comment.