GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Push — master ( b588b4...b187c4 )
by
unknown
10:06
created

credentials/providers/lock_windows.go   A

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 31
dl 0
loc 56
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A providers.unlockFile 0 13 2
A providers.lockFile 0 21 2
1
// +build windows
2
3
package providers
4
5
import (
6
	"syscall"
7
	"unsafe"
8
)
9
10
var (
11
	modkernel32      = syscall.NewLazyDLL("kernel32.dll")
12
	procLockFileEx   = modkernel32.NewProc("LockFileEx")
13
	procUnlockFileEx = modkernel32.NewProc("UnlockFileEx")
14
)
15
16
const (
17
	// LOCKFILE_EXCLUSIVE_LOCK - request exclusive lock
18
	lockfileExclusiveLock = 0x00000002
19
)
20
21
// lockFile acquires an exclusive lock on the file using Windows LockFileEx
22
func lockFile(fd int) error {
23
	// LockFileEx parameters:
24
	// - hFile: file handle
25
	// - dwFlags: LOCKFILE_EXCLUSIVE_LOCK for exclusive lock
26
	// - dwReserved: must be 0
27
	// - nNumberOfBytesToLockLow: low-order 32 bits of lock range (1 byte is enough)
28
	// - nNumberOfBytesToLockHigh: high-order 32 bits of lock range
29
	// - lpOverlapped: pointer to OVERLAPPED structure
30
	var overlapped syscall.Overlapped
31
	r1, _, err := procLockFileEx.Call(
32
		uintptr(fd),
33
		uintptr(lockfileExclusiveLock),
34
		0,
35
		1,
36
		0,
37
		uintptr(unsafe.Pointer(&overlapped)),
38
	)
39
	if r1 == 0 {
40
		return err
41
	}
42
	return nil
43
}
44
45
// unlockFile releases the lock on the file using Windows UnlockFileEx
46
func unlockFile(fd int) error {
47
	var overlapped syscall.Overlapped
48
	r1, _, err := procUnlockFileEx.Call(
49
		uintptr(fd),
50
		0,
51
		1,
52
		0,
53
		uintptr(unsafe.Pointer(&overlapped)),
54
	)
55
	if r1 == 0 {
56
		return err
57
	}
58
	return nil
59
}
60