Skip to content

Commit dd893af

Browse files
committed
doc: move struct fields docs to proper place
1. A newer gofumpt misformats the documentation which is indented, such as the second line of this code: // Val: return value for the syscall that created the notification. Only // relevant if Error is 0. This happens because in recent Go versions (1.18?) this is treated as code blocks. This was definitely not an intention. 2. Godoc blocks should be placed right before the identifiers it documents. Solve both issues my moving the docstrings where they belong. Signed-off-by: Kir Kolyshkin <[email protected]>
1 parent 9006a28 commit dd893af

File tree

1 file changed

+27
-32
lines changed

1 file changed

+27
-32
lines changed

seccomp.go

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -79,49 +79,44 @@ type ScmpSyscall int32
7979
type ScmpFd int32
8080

8181
// ScmpNotifData describes the system call context that triggered a notification.
82-
//
83-
// Syscall: the syscall number
84-
// Arch: the filter architecture
85-
// InstrPointer: address of the instruction that triggered a notification
86-
// Args: arguments (up to 6) for the syscall
87-
//
8882
type ScmpNotifData struct {
89-
Syscall ScmpSyscall `json:"syscall,omitempty"`
90-
Arch ScmpArch `json:"arch,omitempty"`
91-
InstrPointer uint64 `json:"instr_pointer,omitempty"`
92-
Args []uint64 `json:"args,omitempty"`
83+
// Syscall is the syscall number.
84+
Syscall ScmpSyscall `json:"syscall,omitempty"`
85+
// Arch is the filter architecture.
86+
Arch ScmpArch `json:"arch,omitempty"`
87+
// InstrPointer is the address of the instruction that triggered a notification.
88+
InstrPointer uint64 `json:"instr_pointer,omitempty"`
89+
// Args are the arguments (up to 6) for the syscall.
90+
Args []uint64 `json:"args,omitempty"`
9391
}
9492

9593
// ScmpNotifReq represents a seccomp userspace notification. See NotifReceive() for
9694
// info on how to pull such a notification.
97-
//
98-
// ID: notification ID
99-
// Pid: process that triggered the notification event
100-
// Flags: filter flags (see seccomp(2))
101-
// Data: system call context that triggered the notification
102-
//
10395
type ScmpNotifReq struct {
104-
ID uint64 `json:"id,omitempty"`
105-
Pid uint32 `json:"pid,omitempty"`
106-
Flags uint32 `json:"flags,omitempty"`
107-
Data ScmpNotifData `json:"data,omitempty"`
96+
// ID is the notification ID.
97+
ID uint64 `json:"id,omitempty"`
98+
// Pid is the process that triggered the notification event.
99+
Pid uint32 `json:"pid,omitempty"`
100+
// Flags is filter flags (see seccomp(2)).
101+
Flags uint32 `json:"flags,omitempty"`
102+
// Data is system call context that triggered the notification.
103+
Data ScmpNotifData `json:"data,omitempty"`
108104
}
109105

110106
// ScmpNotifResp represents a seccomp userspace notification response. See NotifRespond()
111107
// for info on how to push such a response.
112-
//
113-
// ID: notification ID (must match the corresponding ScmpNotifReq ID)
114-
// Error: must be 0 if no error occurred, or an error constant from package
115-
// syscall (e.g., syscall.EPERM, etc). In the latter case, it's used
116-
// as an error return from the syscall that created the notification.
117-
// Val: return value for the syscall that created the notification. Only
118-
// relevant if Error is 0.
119-
// Flags: userspace notification response flag (e.g., NotifRespFlagContinue)
120-
//
121108
type ScmpNotifResp struct {
122-
ID uint64 `json:"id,omitempty"`
123-
Error int32 `json:"error,omitempty"`
124-
Val uint64 `json:"val,omitempty"`
109+
// ID is the notification ID (must match the corresponding ScmpNotifReq ID).
110+
ID uint64 `json:"id,omitempty"`
111+
// Error must be 0 if no error occurred, or an error constant from
112+
// package syscall (e.g., syscall.EPERM, etc). In the latter case, it
113+
// is used as an error return from the syscall that created the
114+
// notification.
115+
Error int32 `json:"error,omitempty"`
116+
// Val is a return value for the syscall that created the notification.
117+
// Only relevant if Error is 0.
118+
Val uint64 `json:"val,omitempty"`
119+
// Flags is userspace notification response flag (e.g., NotifRespFlagContinue).
125120
Flags uint32 `json:"flags,omitempty"`
126121
}
127122

0 commit comments

Comments
 (0)