Stop checking for valid handle in DevInfo.Close()
User should not have called or deferred the Close() method should SetupDiGetClassDevsEx() return an error (and invalid handle). And even if user does that, a SetupDiDestroyDeviceInfoList(INVALID_HANDLE_VALUE) is harmless. It just returns ERROR_INVALID_HANDLE - we have a unit test for this in TestSetupDiDestroyDeviceInfoList(). Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
269944002f
commit
90b6938ca0
@ -25,13 +25,9 @@ type DevInfo windows.Handle
|
|||||||
|
|
||||||
// Close function deletes a device information set and frees all associated memory.
|
// Close function deletes a device information set and frees all associated memory.
|
||||||
func (h DevInfo) Close() error {
|
func (h DevInfo) Close() error {
|
||||||
if h != DevInfo(windows.InvalidHandle) {
|
|
||||||
return SetupDiDestroyDeviceInfoList(h)
|
return SetupDiDestroyDeviceInfoList(h)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// SP_MAX_MACHINENAME_LENGTH defines maximum length of a machine name in the format expected by ConfigMgr32 CM_Connect_Machine (i.e., "\\\\MachineName\0").
|
// SP_MAX_MACHINENAME_LENGTH defines maximum length of a machine name in the format expected by ConfigMgr32 CM_Connect_Machine (i.e., "\\\\MachineName\0").
|
||||||
SP_MAX_MACHINENAME_LENGTH = windows.MAX_PATH + 3
|
SP_MAX_MACHINENAME_LENGTH = windows.MAX_PATH + 3
|
||||||
|
Loading…
Reference in New Issue
Block a user