diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2025-12-19 12:52:30 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2025-12-22 02:13:00 +0000 |
| commit | a83befa0d111a0ba6fac52d763e93c76a2ef94d4 (patch) | |
| tree | 7d3c28b24229429936a631e8ceb24135856b257d /pkg | |
| parent | 8fb7048c5117ccb592deb5e8e4a62027e6d399cf (diff) | |
all: use any instead of interface{}
Any is the preferred over interface{} now in Go.
Diffstat (limited to 'pkg')
34 files changed, 82 insertions, 82 deletions
diff --git a/pkg/ast/parser_test.go b/pkg/ast/parser_test.go index bc66ed4be..199bd7490 100644 --- a/pkg/ast/parser_test.go +++ b/pkg/ast/parser_test.go @@ -97,24 +97,24 @@ func TestParse(t *testing.T) { var parseTests = []struct { name string input string - result []interface{} + result []any }{ { "empty", ``, - []interface{}{}, + []any{}, }, { "new-line", ` `, - []interface{}{}, + []any{}, }, { "nil", "\x00", - []interface{}{}, + []any{}, }, } diff --git a/pkg/ast/scanner.go b/pkg/ast/scanner.go index 67dd80e52..326a0b9bb 100644 --- a/pkg/ast/scanner.go +++ b/pkg/ast/scanner.go @@ -289,7 +289,7 @@ func (s *scanner) scanIdent(pos Pos) (tok token, lit string) { return } -func (s *scanner) Errorf(pos Pos, msg string, args ...interface{}) { +func (s *scanner) Errorf(pos Pos, msg string, args ...any) { s.errors++ s.errorHandler(pos, fmt.Sprintf(msg, args...)) } diff --git a/pkg/bisect/bisect.go b/pkg/bisect/bisect.go index a37436495..adf2bd971 100644 --- a/pkg/bisect/bisect.go +++ b/pkg/bisect/bisect.go @@ -1057,7 +1057,7 @@ func (env *env) log(msg string) { env.logf("%v", msg) } -func (env *env) logf(msg string, args ...interface{}) { +func (env *env) logf(msg string, args ...any) { if false { _ = fmt.Sprintf(msg, args...) // enable printf checker } diff --git a/pkg/bisect/minimize/slice.go b/pkg/bisect/minimize/slice.go index d5fbc6c6a..949174ad4 100644 --- a/pkg/bisect/minimize/slice.go +++ b/pkg/bisect/minimize/slice.go @@ -24,7 +24,7 @@ type Config[T any] struct { // anongside the intermediate bisection result (a valid, but not fully minimized slice). MaxChunks int // Logf is used for sharing debugging output. - Logf func(string, ...interface{}) + Logf func(string, ...any) } // Slice() finds a minimal subsequence of slice elements that still gives Pred() == true. @@ -33,7 +33,7 @@ type Config[T any] struct { // The expected number of Pred() runs is O(|result|*log2(|elements|)). func Slice[T any](config Config[T], slice []T) ([]T, error) { if config.Logf == nil { - config.Logf = func(string, ...interface{}) {} + config.Logf = func(string, ...any) {} } ctx := &sliceCtx[T]{ Config: config, diff --git a/pkg/compiler/compiler.go b/pkg/compiler/compiler.go index 3022def7f..7b22cef42 100644 --- a/pkg/compiler/compiler.go +++ b/pkg/compiler/compiler.go @@ -148,12 +148,12 @@ type warn struct { msg string } -func (comp *compiler) error(pos ast.Pos, msg string, args ...interface{}) { +func (comp *compiler) error(pos ast.Pos, msg string, args ...any) { comp.errors++ comp.eh(pos, fmt.Sprintf(msg, args...)) } -func (comp *compiler) warning(pos ast.Pos, msg string, args ...interface{}) { +func (comp *compiler) warning(pos ast.Pos, msg string, args ...any) { comp.warnings = append(comp.warnings, warn{pos, fmt.Sprintf(msg, args...)}) } diff --git a/pkg/compiler/const_file.go b/pkg/compiler/const_file.go index 0220da555..620c73f7b 100644 --- a/pkg/compiler/const_file.go +++ b/pkg/compiler/const_file.go @@ -204,7 +204,7 @@ func DeserializeConstFile(glob string, eh ast.ErrorHandler) *ConstFile { func (cf *ConstFile) deserializeFile(data []byte, file, arch string, eh ast.ErrorHandler) bool { pos := ast.Pos{File: file, Line: 1} - errf := func(msg string, args ...interface{}) bool { + errf := func(msg string, args ...any) bool { eh(pos, fmt.Sprintf(msg, args...)) return false } @@ -247,7 +247,7 @@ func (cf *ConstFile) deserializeFile(data []byte, file, arch string, eh ast.Erro return true } -type errft func(msg string, args ...interface{}) bool +type errft func(msg string, args ...any) bool func (cf *ConstFile) parseConst(arches []string, name, line string, weak bool, errf errft) bool { var dflt map[string]uint64 diff --git a/pkg/config/config.go b/pkg/config/config.go index 5af99ba0f..0a0346f83 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -13,7 +13,7 @@ import ( "github.com/google/syzkaller/pkg/osutil" ) -func LoadFile(filename string, cfg interface{}) error { +func LoadFile(filename string, cfg any) error { if filename == "" { return fmt.Errorf("no config file specified") } @@ -24,7 +24,7 @@ func LoadFile(filename string, cfg interface{}) error { return LoadData(data, cfg) } -func LoadData(data []byte, cfg interface{}) error { +func LoadData(data []byte, cfg any) error { // Remove comment lines starting with #. data = regexp.MustCompile(`(^|\n)\s*#[^\n]*`).ReplaceAll(data, nil) dec := json.NewDecoder(bytes.NewReader(data)) @@ -35,7 +35,7 @@ func LoadData(data []byte, cfg interface{}) error { return nil } -func SaveFile(filename string, cfg interface{}) error { +func SaveFile(filename string, cfg any) error { data, err := json.MarshalIndent(cfg, "", "\t") if err != nil { return err diff --git a/pkg/config/merge.go b/pkg/config/merge.go index 3d8193c02..ae4320946 100644 --- a/pkg/config/merge.go +++ b/pkg/config/merge.go @@ -23,7 +23,7 @@ func MergeJSONs(left, right []byte) ([]byte, error) { // Recursively apply a patch to a raw JSON data. // Patch is supposed to be a map, which possibly nests other map objects. -func PatchJSON(left []byte, patch map[string]interface{}) ([]byte, error) { +func PatchJSON(left []byte, patch map[string]any) ([]byte, error) { vLeft, err := parseFragment(left) if err != nil { return nil, err @@ -31,7 +31,7 @@ func PatchJSON(left []byte, patch map[string]interface{}) ([]byte, error) { return json.Marshal(mergeRecursive(vLeft, patch)) } -func parseFragment(input []byte) (parsed interface{}, err error) { +func parseFragment(input []byte) (parsed any, err error) { if len(input) == 0 { // For convenience, we allow empty strings to be passed to the function that merges JSONs. return @@ -42,15 +42,15 @@ func parseFragment(input []byte) (parsed interface{}, err error) { // If one of the elements is not a map, use the new one. // Otherwise, recursively merge map elements. -func mergeRecursive(left, right interface{}) interface{} { +func mergeRecursive(left, right any) any { if left == nil { return right } if right == nil { return left } - mLeft, okLeft := left.(map[string]interface{}) - mRight, okRight := right.(map[string]interface{}) + mLeft, okLeft := left.(map[string]any) + mRight, okRight := right.(map[string]any) if !okLeft || !okRight { return right } diff --git a/pkg/config/merge_test.go b/pkg/config/merge_test.go index 6785534f1..53d8a2116 100644 --- a/pkg/config/merge_test.go +++ b/pkg/config/merge_test.go @@ -51,19 +51,19 @@ func TestMergeJSONs(t *testing.T) { func TestPatchJSON(t *testing.T) { tests := []struct { left string - patch map[string]interface{} + patch map[string]any result string }{ { `{"a":1,"b":2}`, - map[string]interface{}{"b": "string val"}, + map[string]any{"b": "string val"}, `{"a":1,"b":"string val"}`, }, { `{"a":1,"b":2}`, - map[string]interface{}{ - "a": map[string]interface{}{ - "b": map[string]interface{}{ + map[string]any{ + "a": map[string]any{ + "b": map[string]any{ "c": 5, }, }, @@ -72,9 +72,9 @@ func TestPatchJSON(t *testing.T) { }, { `{}`, - map[string]interface{}{ - "a": map[string]interface{}{ - "b": map[string]interface{}{ + map[string]any{ + "a": map[string]any{ + "b": map[string]any{ "c": 0, }, }, diff --git a/pkg/coveragedb/coveragedb.go b/pkg/coveragedb/coveragedb.go index 8272ce6ff..7ae10047b 100644 --- a/pkg/coveragedb/coveragedb.go +++ b/pkg/coveragedb/coveragedb.go @@ -149,7 +149,7 @@ from merge_history on merge_history.session = files.session where namespace=$1 and dateto=$2 and duration=$3 and filepath=$4 and commit=$5 and manager=$6`, - Params: map[string]interface{}{ + Params: map[string]any{ "p1": ns, "p2": timePeriod.DateTo, "p3": timePeriod.Days, @@ -267,7 +267,7 @@ func NsDataMerged(ctx context.Context, client spannerclient.SpannerClient, ns st from merge_history where namespace=$1`, - Params: map[string]interface{}{ + Params: map[string]any{ "p1": ns, }, } @@ -485,7 +485,7 @@ from merge_history on merge_history.namespace = file_subsystems.namespace and files.filepath = file_subsystems.filepath where merge_history.namespace=$1 and dateto=$2 and duration=$3 and manager=$4`, - Params: map[string]interface{}{ + Params: map[string]any{ "p1": scope.Ns, "p2": scope.Periods[0].DateTo, "p3": scope.Periods[0].Days, @@ -647,7 +647,7 @@ func RegenerateSubsystems(ctx context.Context, ns string, sss []*subsystem.Subsy func getFilePaths(ctx context.Context, ns string, client spannerclient.SpannerClient) ([]string, error) { iter := client.Single().Query(ctx, spanner.Statement{ SQL: `select filepath from file_subsystems where namespace=$1`, - Params: map[string]interface{}{ + Params: map[string]any{ "p1": ns, }, }) diff --git a/pkg/coveragedb/functions.go b/pkg/coveragedb/functions.go index 6e1240881..929f2a620 100644 --- a/pkg/coveragedb/functions.go +++ b/pkg/coveragedb/functions.go @@ -30,7 +30,7 @@ from merge_history on merge_history.session = functions.session where merge_history.namespace=$1 and dateto=$2 and duration=$3`, - Params: map[string]interface{}{ + Params: map[string]any{ "p1": ns, "p2": timePeriod.DateTo, "p3": timePeriod.Days, diff --git a/pkg/coveragedb/mocks/Row.go b/pkg/coveragedb/mocks/Row.go index 3ea716173..0359f6031 100644 --- a/pkg/coveragedb/mocks/Row.go +++ b/pkg/coveragedb/mocks/Row.go @@ -36,7 +36,7 @@ func (_m *Row) EXPECT() *Row_Expecter { } // ToStruct provides a mock function for the type Row -func (_mock *Row) ToStruct(p interface{}) error { +func (_mock *Row) ToStruct(p any) error { ret := _mock.Called(p) if len(ret) == 0 { @@ -44,7 +44,7 @@ func (_mock *Row) ToStruct(p interface{}) error { } var r0 error - if returnFunc, ok := ret.Get(0).(func(interface{}) error); ok { + if returnFunc, ok := ret.Get(0).(func(any) error); ok { r0 = returnFunc(p) } else { r0 = ret.Error(0) @@ -58,16 +58,16 @@ type Row_ToStruct_Call struct { } // ToStruct is a helper method to define mock.On call -// - p interface{} +// - p any func (_e *Row_Expecter) ToStruct(p interface{}) *Row_ToStruct_Call { return &Row_ToStruct_Call{Call: _e.mock.On("ToStruct", p)} } -func (_c *Row_ToStruct_Call) Run(run func(p interface{})) *Row_ToStruct_Call { +func (_c *Row_ToStruct_Call) Run(run func(p any)) *Row_ToStruct_Call { _c.Call.Run(func(args mock.Arguments) { - var arg0 interface{} + var arg0 any if args[0] != nil { - arg0 = args[0].(interface{}) + arg0 = args[0].(any) } run( arg0, @@ -81,7 +81,7 @@ func (_c *Row_ToStruct_Call) Return(err error) *Row_ToStruct_Call { return _c } -func (_c *Row_ToStruct_Call) RunAndReturn(run func(p interface{}) error) *Row_ToStruct_Call { +func (_c *Row_ToStruct_Call) RunAndReturn(run func(p any) error) *Row_ToStruct_Call { _c.Call.Return(run) return _c } diff --git a/pkg/coveragedb/spannerclient/spanner_client.go b/pkg/coveragedb/spannerclient/spanner_client.go index 4f655c6ed..d9409381d 100644 --- a/pkg/coveragedb/spannerclient/spanner_client.go +++ b/pkg/coveragedb/spannerclient/spanner_client.go @@ -26,7 +26,7 @@ type RowIterator interface { } type Row interface { - ToStruct(p interface{}) error + ToStruct(p any) error } type SpannerClientProxy struct { diff --git a/pkg/debugtracer/debug.go b/pkg/debugtracer/debug.go index 10259e788..fa30c244a 100644 --- a/pkg/debugtracer/debug.go +++ b/pkg/debugtracer/debug.go @@ -14,7 +14,7 @@ import ( ) type DebugTracer interface { - Log(msg string, args ...interface{}) + Log(msg string, args ...any) SaveFile(filename string, data []byte) } @@ -31,10 +31,10 @@ type TestTracer struct { type NullTracer struct { } -func (gt *GenericTracer) Log(msg string, args ...interface{}) { +func (gt *GenericTracer) Log(msg string, args ...any) { if gt.WithTime { timeStr := time.Now().Format("02-Jan-2006 15:04:05") - newArgs := append([]interface{}{timeStr}, args...) + newArgs := append([]any{timeStr}, args...) fmt.Fprintf(gt.TraceWriter, "%s: "+msg+"\n", newArgs...) } else { fmt.Fprintf(gt.TraceWriter, msg+"\n", args...) @@ -49,7 +49,7 @@ func (gt *GenericTracer) SaveFile(filename string, data []byte) { osutil.WriteFile(filepath.Join(gt.OutDir, filename), data) } -func (tt *TestTracer) Log(msg string, args ...interface{}) { +func (tt *TestTracer) Log(msg string, args ...any) { tt.T.Log(msg, args) } @@ -57,7 +57,7 @@ func (tt *TestTracer) SaveFile(filename string, data []byte) { // Not implemented. } -func (nt *NullTracer) Log(msg string, args ...interface{}) { +func (nt *NullTracer) Log(msg string, args ...any) { // Not implemented. } diff --git a/pkg/fuzzer/fuzzer.go b/pkg/fuzzer/fuzzer.go index fdfe95518..bd55ca9c6 100644 --- a/pkg/fuzzer/fuzzer.go +++ b/pkg/fuzzer/fuzzer.go @@ -210,7 +210,7 @@ func (fuzzer *Fuzzer) processResult(req *queue.Request, res *queue.Result, flags type Config struct { Debug bool Corpus *corpus.Corpus - Logf func(level int, msg string, args ...interface{}) + Logf func(level int, msg string, args ...any) Snapshot bool Coverage bool FaultInjection bool @@ -338,7 +338,7 @@ func (fuzzer *Fuzzer) Next() *queue.Request { return req } -func (fuzzer *Fuzzer) Logf(level int, msg string, args ...interface{}) { +func (fuzzer *Fuzzer) Logf(level int, msg string, args ...any) { if fuzzer.Config.Logf == nil { return } diff --git a/pkg/fuzzer/fuzzer_test.go b/pkg/fuzzer/fuzzer_test.go index b12d7634b..971e6d683 100644 --- a/pkg/fuzzer/fuzzer_test.go +++ b/pkg/fuzzer/fuzzer_test.go @@ -49,7 +49,7 @@ func TestFuzz(t *testing.T) { fuzzer := NewFuzzer(ctx, &Config{ Debug: true, Corpus: corpus.NewMonitoredCorpus(ctx, corpusUpdates), - Logf: func(level int, msg string, args ...interface{}) { + Logf: func(level int, msg string, args ...any) { if level > 1 { return } diff --git a/pkg/html/html.go b/pkg/html/html.go index e077153d1..0da3674ea 100644 --- a/pkg/html/html.go +++ b/pkg/html/html.go @@ -205,7 +205,7 @@ func formatStringList(list []string) string { return strings.Join(list, ", ") } -func dereferencePointer(v interface{}) interface{} { +func dereferencePointer(v any) any { reflectValue := reflect.ValueOf(v) if !reflectValue.IsNil() && reflectValue.Kind() == reflect.Ptr { elem := reflectValue.Elem() diff --git a/pkg/ifuzz/x86/gen/gen.go b/pkg/ifuzz/x86/gen/gen.go index c1af7a44e..b79b8dabf 100644 --- a/pkg/ifuzz/x86/gen/gen.go +++ b/pkg/ifuzz/x86/gen/gen.go @@ -39,7 +39,7 @@ func main() { var insn, insn1 *x86.Insn s := bufio.NewScanner(f) for i := 1; s.Scan(); i++ { - reportError := func(msg string, args ...interface{}) { + reportError := func(msg string, args ...any) { fmt.Fprintf(os.Stderr, "line %v: %v\n", i, s.Text()) tool.Failf(msg, args...) } diff --git a/pkg/image/compression_optimized.go b/pkg/image/compression_optimized.go index 819debc6e..e9effb477 100644 --- a/pkg/image/compression_optimized.go +++ b/pkg/image/compression_optimized.go @@ -25,7 +25,7 @@ type decompressScratch struct { // This is just for memory consumption estimation, does not need to be precise. const pageSize = 4 << 10 -var decompressPool = sync.Pool{New: func() interface{} { +var decompressPool = sync.Pool{New: func() any { return &decompressScratch{ buf: make([]byte, pageSize), } diff --git a/pkg/instance/execprog.go b/pkg/instance/execprog.go index 564889ba2..6a365cdb7 100644 --- a/pkg/instance/execprog.go +++ b/pkg/instance/execprog.go @@ -18,7 +18,7 @@ import ( "github.com/google/syzkaller/vm" ) -type ExecutorLogger func(int, string, ...interface{}) +type ExecutorLogger func(int, string, ...any) type OptionalConfig struct { Logf ExecutorLogger @@ -84,7 +84,7 @@ func SetupExecProg(vmInst *vm.Instance, mgrCfg *mgrconfig.Config, reporter *repo } } if ret.Logf == nil { - ret.Logf = func(int, string, ...interface{}) {} + ret.Logf = func(int, string, ...any) {} } return ret, nil } diff --git a/pkg/instance/instance.go b/pkg/instance/instance.go index 1d0adc5d6..d8b3a8f71 100644 --- a/pkg/instance/instance.go +++ b/pkg/instance/instance.go @@ -193,7 +193,7 @@ func SetConfigImage(cfg *mgrconfig.Config, imageDir string, reliable bool) error if keyFile := filepath.Join(imageDir, "key"); osutil.IsExist(keyFile) { cfg.SSHKey = keyFile } - vmConfig := make(map[string]interface{}) + vmConfig := make(map[string]any) if err := json.Unmarshal(cfg.VM, &vmConfig); err != nil { return fmt.Errorf("failed to parse VM config: %w", err) } @@ -218,7 +218,7 @@ func SetConfigImage(cfg *mgrconfig.Config, imageDir string, reliable bool) error } func OverrideVMCount(cfg *mgrconfig.Config, n int) error { - vmConfig := make(map[string]interface{}) + vmConfig := make(map[string]any) if err := json.Unmarshal(cfg.VM, &vmConfig); err != nil { return fmt.Errorf("failed to parse VM config: %w", err) } diff --git a/pkg/kconfig/parser.go b/pkg/kconfig/parser.go index 60bfc54a1..08c9600ce 100644 --- a/pkg/kconfig/parser.go +++ b/pkg/kconfig/parser.go @@ -77,7 +77,7 @@ func (p *parser) identLevel() int { return level } -func (p *parser) failf(msg string, args ...interface{}) { +func (p *parser) failf(msg string, args ...any) { if p.err == nil { p.err = fmt.Errorf("%v:%v:%v: %v\n%v", p.file, p.line, p.col, fmt.Sprintf(msg, args...), p.current) } diff --git a/pkg/log/log.go b/pkg/log/log.go index 19ff6fd9b..e2edf02b4 100644 --- a/pkg/log/log.go +++ b/pkg/log/log.go @@ -79,7 +79,7 @@ func Log(v int, msg string) { Logf(v, "%v", msg) } -func Logf(v int, msg string, args ...interface{}) { +func Logf(v int, msg string, args ...any) { writeMessage(v, "", msg, args...) } @@ -87,7 +87,7 @@ func Error(err error) { Errorf("%v", err) } -func Errorf(msg string, args ...interface{}) { +func Errorf(msg string, args ...any) { writeMessage(0, "ERROR", msg, args...) } @@ -95,11 +95,11 @@ func Fatal(err error) { Fatalf("%v", err) } -func Fatalf(msg string, args ...interface{}) { +func Fatalf(msg string, args ...any) { golog.Fatal(message("FATAL", msg, args...)) } -func message(severity, msg string, args ...interface{}) string { +func message(severity, msg string, args ...any) string { var sb strings.Builder if severity != "" { fmt.Fprintf(&sb, "[%s] ", severity) @@ -111,7 +111,7 @@ func message(severity, msg string, args ...interface{}) string { return sb.String() } -func writeMessage(v int, severity, msg string, args ...interface{}) { +func writeMessage(v int, severity, msg string, args ...any) { cache := v <= 1 && cachingEnabled.Load() if !V(v) && !cache { return diff --git a/pkg/manager/diff.go b/pkg/manager/diff.go index 18dd0df48..4ad759244 100644 --- a/pkg/manager/diff.go +++ b/pkg/manager/diff.go @@ -564,7 +564,7 @@ func (kc *kernelContext) setupFuzzer(features flatrpc.Feature, syscalls map[*pro EnabledCalls: syscalls, NoMutateCalls: kc.cfg.NoMutateCalls, PatchTest: true, - Logf: func(level int, msg string, args ...interface{}) { + Logf: func(level int, msg string, args ...any) { if level != 0 { return } diff --git a/pkg/manager/http.go b/pkg/manager/http.go index 881c8154d..3e47994c3 100644 --- a/pkg/manager/http.go +++ b/pkg/manager/http.go @@ -1034,7 +1034,7 @@ func reproStatus(hasRepro, hasCRepro, reproducing, nonReproducible bool) string return status } -func executeTemplate(w http.ResponseWriter, templ *template.Template, data interface{}) { +func executeTemplate(w http.ResponseWriter, templ *template.Template, data any) { buf := new(bytes.Buffer) if err := templ.Execute(buf, data); err != nil { log.Logf(0, "failed to execute template: %v", err) diff --git a/pkg/mgrconfig/mgrconfig_test.go b/pkg/mgrconfig/mgrconfig_test.go index d4a37e941..2873bff20 100644 --- a/pkg/mgrconfig/mgrconfig_test.go +++ b/pkg/mgrconfig/mgrconfig_test.go @@ -25,7 +25,7 @@ func TestCanned(t *testing.T) { if err != nil { t.Fatal(err) } - var vmCfg interface{} + var vmCfg any switch cfg.Type { case "qemu": vmCfg = new(qemu.Config) diff --git a/pkg/repro/repro.go b/pkg/repro/repro.go index b10d29784..9442acfb2 100644 --- a/pkg/repro/repro.go +++ b/pkg/repro/repro.go @@ -51,7 +51,7 @@ type Stats struct { type reproContext struct { ctx context.Context exec execInterface - logf func(string, ...interface{}) + logf func(string, ...any) target *targets.Target crashTitle string crashType crash.Type @@ -82,7 +82,7 @@ type Environment struct { // it skips multiple simpifications and C repro generation. Fast bool - logf func(string, ...interface{}) + logf func(string, ...any) } func Run(ctx context.Context, log []byte, env Environment) (*Result, *Stats, error) { @@ -766,7 +766,7 @@ func (ctx *reproContext) testCProg(p *prog.Prog, duration time.Duration, opts cs }, strict) } -func (ctx *reproContext) reproLogf(level int, format string, args ...interface{}) { +func (ctx *reproContext) reproLogf(level int, format string, args ...any) { if ctx.logf != nil { ctx.logf(format, args...) } @@ -795,7 +795,7 @@ func (ctx *reproContext) bisectProgs(progs []*prog.LogEntry, pred func([]*prog.L ret, err := minimize.SliceWithFixed(minimize.Config[*prog.LogEntry]{ Pred: minimizePred, MaxChunks: chunks, - Logf: func(msg string, args ...interface{}) { + Logf: func(msg string, args ...any) { ctx.reproLogf(3, "bisect: "+msg, args...) }, }, progs, func(elem *prog.LogEntry) bool { diff --git a/pkg/rpctype/rpc.go b/pkg/rpctype/rpc.go index f3a05eeae..2f666c0f3 100644 --- a/pkg/rpctype/rpc.go +++ b/pkg/rpctype/rpc.go @@ -19,7 +19,7 @@ type RPCServer struct { s *rpc.Server } -func NewRPCServer(addr, name string, receiver interface{}) (*RPCServer, error) { +func NewRPCServer(addr, name string, receiver any) (*RPCServer, error) { ln, err := net.Listen("tcp", addr) if err != nil { return nil, fmt.Errorf("failed to listen on %v: %w", addr, err) @@ -69,7 +69,7 @@ func NewRPCClient(addr string) (*RPCClient, error) { return cli, nil } -func (cli *RPCClient) Call(method string, args, reply interface{}) error { +func (cli *RPCClient) Call(method string, args, reply any) error { // Note: SetDeadline is not implemented on fuchsia, so don't fail on error. cli.conn.SetDeadline(time.Now().Add(10 * time.Minute)) defer cli.conn.SetDeadline(time.Time{}) diff --git a/pkg/runtest/run.go b/pkg/runtest/run.go index ffd791c68..7b3f1517f 100644 --- a/pkg/runtest/run.go +++ b/pkg/runtest/run.go @@ -80,7 +80,7 @@ func (ctx *Context) Init() { ctx.buildSem = make(chan bool, runtime.GOMAXPROCS(0)) } -func (ctx *Context) log(msg string, args ...interface{}) { +func (ctx *Context) log(msg string, args ...any) { ctx.LogFunc(fmt.Sprintf(msg, args...)) } diff --git a/pkg/serializer/serializer.go b/pkg/serializer/serializer.go index 3f7770009..c9063c510 100644 --- a/pkg/serializer/serializer.go +++ b/pkg/serializer/serializer.go @@ -16,7 +16,7 @@ import ( // does not write package names before types, omits struct fields with default values, // omits type names where possible, etc. On the other hand, it currently does not // support all types (e.g. channels and maps). -func Write(ww io.Writer, i interface{}) { +func Write(ww io.Writer, i any) { w := writer{ww} v := reflect.ValueOf(i) if v.Kind() == reflect.Slice && (v.IsNil() || v.Len() == 0) { @@ -27,7 +27,7 @@ func Write(ww io.Writer, i interface{}) { w.do(v, false) } -func WriteString(i interface{}) string { +func WriteString(i any) string { var sb strings.Builder Write(&sb, i) return sb.String() @@ -92,7 +92,7 @@ func (w *writer) doInterface(v reflect.Value) { elem := v.Elem() // Handling of user types that has underlying primitive types. Consider: // type T int - // var obj interface{} = T(42) + // var obj any = T(42) // T has kind reflect.Int. But if we serialize obj as just "42", it will be turned into plain int. // Detect this case and serialize obj as "T(42)". if (elem.Kind() == reflect.Bool || elem.Kind() == reflect.String || diff --git a/pkg/serializer/serializer_test.go b/pkg/serializer/serializer_test.go index e4efa6719..94e8fc445 100644 --- a/pkg/serializer/serializer_test.go +++ b/pkg/serializer/serializer_test.go @@ -18,7 +18,7 @@ func TestSerializer(t *testing.T) { B: true, S: "a\x09b", T: T1, - I: []interface{}{ + I: []any{ nil, Y{V: 42}, new(Y), @@ -71,7 +71,7 @@ type X struct { B bool S string T T - I []interface{} + I []any F func() } diff --git a/pkg/signal/signal.go b/pkg/signal/signal.go index 506d65aac..da3aca538 100644 --- a/pkg/signal/signal.go +++ b/pkg/signal/signal.go @@ -101,10 +101,10 @@ func (s Signal) ToRaw() []uint64 { type Context struct { Signal Signal - Context interface{} + Context any } -func Minimize(corpus []Context) []interface{} { +func Minimize(corpus []Context) []any { type ContextPrio struct { prio prioType idx int @@ -124,7 +124,7 @@ func Minimize(corpus []Context) []interface{} { for _, cp := range covered { indices[cp.idx] = struct{}{} } - result := make([]interface{}, 0, len(indices)) + result := make([]any, 0, len(indices)) for idx := range indices { result = append(result, corpus[idx].Context) } diff --git a/pkg/subsystem/linux/maintainers.go b/pkg/subsystem/linux/maintainers.go index d1d65400d..00aedda0e 100644 --- a/pkg/subsystem/linux/maintainers.go +++ b/pkg/subsystem/linux/maintainers.go @@ -83,7 +83,7 @@ type endOfFile struct{} var propertyRe = regexp.MustCompile(`^([[:alpha:]]):\s+(.*).*$`) -func (ml *maintainersLexer) next() interface{} { +func (ml *maintainersLexer) next() any { for ml.scanner.Scan() { ml.currentLine++ rawLine := ml.scanner.Text() diff --git a/pkg/tool/tool.go b/pkg/tool/tool.go index 0221cb876..d67949355 100644 --- a/pkg/tool/tool.go +++ b/pkg/tool/tool.go @@ -25,7 +25,7 @@ func Init() func() { return installProfiling(*flagCPUProfile, *flagMEMProfile) } -func Failf(msg string, args ...interface{}) { +func Failf(msg string, args ...any) { fmt.Fprintf(os.Stderr, msg+"\n", args...) os.Exit(1) } |
