]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
Stop checking for valid handle in DevInfo.Close()
authorSimon Rozman <simon@rozman.si>
Mon, 4 Feb 2019 07:22:49 +0000 (08:22 +0100)
committerJason A. Donenfeld <Jason@zx2c4.com>
Tue, 5 Feb 2019 11:59:42 +0000 (12:59 +0100)
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>
setupapi/types_windows.go

index e2617a45e6bd8c1845d612c824d490598c623874..bc6f66b28617941c4ca7710780f29c19ceaaa3c2 100644 (file)
@@ -25,11 +25,7 @@ type DevInfo windows.Handle
 
 // Close function deletes a device information set and frees all associated memory.
 func (h DevInfo) Close() error {
-       if h != DevInfo(windows.InvalidHandle) {
-               return SetupDiDestroyDeviceInfoList(h)
-       }
-
-       return nil
+       return SetupDiDestroyDeviceInfoList(h)
 }
 
 const (