Skip to content

Commit b54b9d7

Browse files
committed
capability: fix QF1003 (staticcheck)
Error: capability/syscall_linux.go:144:2: QF1003: could use tagged switch on data.version (staticcheck) if data.version == 1 { ^ Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 8d553c0 commit b54b9d7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Diff for: capability/syscall_linux.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -141,16 +141,17 @@ func setVfsCap(path string, data *vfscapData) (err error) {
141141
return
142142
}
143143
var size uintptr
144-
if data.version == 1 {
144+
switch data.version {
145+
case 1:
145146
data.magic = vfsCapVer1
146147
size = vfscapDataSizeV1
147-
} else if data.version == 2 {
148+
case 2:
148149
data.magic = vfsCapVer2
149150
if data.effective[0] != 0 || data.effective[1] != 0 {
150151
data.magic |= vfsCapFlageffective
151152
}
152153
size = vfscapDataSizeV2
153-
} else {
154+
default:
154155
return syscall.EINVAL
155156
}
156157
_, _, e1 := syscall.RawSyscall6(syscall.SYS_SETXATTR, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(_vfsXattrName)), uintptr(unsafe.Pointer(data)), size, 0, 0)

0 commit comments

Comments
 (0)