Skip to content

Commit

Permalink
*: gofumpt
Browse files Browse the repository at this point in the history
This is a result of running "gofumpt -w *.go" on the source code.

gofumpt[1] is a tool similar to (and based on) gofmt, which adds some
some extra rules for better code formatting. Here, it removes some extra
vertical whitespace, and replaces a var() block with a single element
inside with a mere var declaration. Both make sense.

Enable gofumpt in golangci-lint config to make sure future commits are
gofumpt-ed.

[1] https://github.com/mvdan/gofumpt

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed Sep 17, 2021
1 parent f0a12ff commit 5178695
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# For documentation, see https://golangci-lint.run/usage/configuration/
linters:
enable:
- gofumpt
9 changes: 3 additions & 6 deletions seccomp.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func (e VersionError) Error() string {
}
return fmt.Sprintf("%s requires libseccomp >= %s (current version: %d.%d.%d)",
e.op, e.minVer, verMajor, verMinor, verMicro)

}

// ScmpArch represents a CPU architecture. Seccomp can restrict syscalls on a
Expand Down Expand Up @@ -252,11 +251,9 @@ const (
CompareMaskedEqual ScmpCompareOp = iota
)

var (
// ErrSyscallDoesNotExist represents an error condition where
// libseccomp is unable to resolve the syscall
ErrSyscallDoesNotExist = fmt.Errorf("could not resolve syscall name")
)
// ErrSyscallDoesNotExist represents an error condition where
// libseccomp is unable to resolve the syscall
var ErrSyscallDoesNotExist = fmt.Errorf("could not resolve syscall name")

const (
// Userspace notification response flags
Expand Down
8 changes: 8 additions & 0 deletions seccomp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func APILevelIsSupported() bool {
func TestGetAPILevel(t *testing.T) {
execInSubprocess(t, subprocessGetAPILevel)
}

func subprocessGetAPILevel(t *testing.T) {
api, err := GetAPI()
if !APILevelIsSupported() {
Expand All @@ -88,6 +89,7 @@ func subprocessGetAPILevel(t *testing.T) {
func TestSetAPILevel(t *testing.T) {
execInSubprocess(t, subprocessSetAPILevel)
}

func subprocessSetAPILevel(t *testing.T) {
const expectedAPI = uint(1)

Expand Down Expand Up @@ -560,6 +562,7 @@ func TestMergeFilters(t *testing.T) {
func TestRuleAddAndLoad(t *testing.T) {
execInSubprocess(t, subprocessRuleAddAndLoad)
}

func subprocessRuleAddAndLoad(t *testing.T) {
// Test #1: Add a trivial filter
filter1, err := NewFilter(ActAllow)
Expand Down Expand Up @@ -636,6 +639,7 @@ func subprocessRuleAddAndLoad(t *testing.T) {
func TestLogAct(t *testing.T) {
execInSubprocess(t, subprocessLogAct)
}

func subprocessLogAct(t *testing.T) {
expectedPid := syscall.Getpid()

Expand Down Expand Up @@ -681,6 +685,7 @@ func subprocessLogAct(t *testing.T) {
func TestCreateActKillThreadFilter(t *testing.T) {
execInSubprocess(t, subprocessCreateActKillThreadFilter)
}

func subprocessCreateActKillThreadFilter(t *testing.T) {
filter, err := NewFilter(ActKillThread)
if err != nil {
Expand All @@ -695,6 +700,7 @@ func subprocessCreateActKillThreadFilter(t *testing.T) {
func TestCreateActKillProcessFilter(t *testing.T) {
execInSubprocess(t, subprocessCreateActKillProcessFilter)
}

func subprocessCreateActKillProcessFilter(t *testing.T) {
api, err := GetAPI()
if err != nil {
Expand Down Expand Up @@ -786,6 +792,7 @@ func notifHandler(ch chan error, fd ScmpFd, tests []notifTest) {
func TestNotif(t *testing.T) {
execInSubprocess(t, subprocessNotif)
}

func subprocessNotif(t *testing.T) {
// seccomp notification requires API level >= 6
api, err := GetAPI()
Expand Down Expand Up @@ -953,6 +960,7 @@ L:
func TestNotifUnsupported(t *testing.T) {
execInSubprocess(t, subprocessNotifUnsupported)
}

func subprocessNotifUnsupported(t *testing.T) {
// seccomp notification requires API level >= 6
api := 0
Expand Down

0 comments on commit 5178695

Please sign in to comment.