From a83befa0d111a0ba6fac52d763e93c76a2ef94d4 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 19 Dec 2025 12:52:30 +0100 Subject: all: use any instead of interface{} Any is the preferred over interface{} now in Go. --- syz-cluster/pkg/app/logging.go | 4 ++-- syz-cluster/pkg/controller/api.go | 10 +++++----- syz-cluster/pkg/db/base_finding_repo.go | 2 +- syz-cluster/pkg/db/build_repo.go | 2 +- syz-cluster/pkg/db/finding_repo.go | 6 +++--- syz-cluster/pkg/db/report_reply_repo.go | 6 +++--- syz-cluster/pkg/db/report_repo.go | 2 +- syz-cluster/pkg/db/series_repo.go | 14 +++++++------- syz-cluster/pkg/db/session_repo.go | 10 +++++----- syz-cluster/pkg/db/session_test_repo.go | 8 ++++---- syz-cluster/pkg/db/spanner.go | 4 ++-- syz-cluster/pkg/reporter/api.go | 6 +++--- 12 files changed, 37 insertions(+), 37 deletions(-) (limited to 'syz-cluster/pkg') diff --git a/syz-cluster/pkg/app/logging.go b/syz-cluster/pkg/app/logging.go index a4202dd84..01bd4bd3f 100644 --- a/syz-cluster/pkg/app/logging.go +++ b/syz-cluster/pkg/app/logging.go @@ -7,10 +7,10 @@ import "log" // TODO: catch these with monitoring. -func Errorf(fmt string, args ...interface{}) { +func Errorf(fmt string, args ...any) { log.Printf(fmt, args...) } -func Fatalf(fmt string, args ...interface{}) { +func Fatalf(fmt string, args ...any) { log.Fatalf(fmt, args...) } diff --git a/syz-cluster/pkg/controller/api.go b/syz-cluster/pkg/controller/api.go index 7520a05f9..6aad3ff42 100644 --- a/syz-cluster/pkg/controller/api.go +++ b/syz-cluster/pkg/controller/api.go @@ -78,7 +78,7 @@ func (c APIServer) triageResult(w http.ResponseWriter, r *http.Request) { http.Error(w, fmt.Sprint(err), http.StatusInternalServerError) return } - api.ReplyJSON[interface{}](w, nil) + api.ReplyJSON[any](w, nil) } func (c APIServer) getSeries(w http.ResponseWriter, r *http.Request) { @@ -118,7 +118,7 @@ func (c APIServer) uploadTest(w http.ResponseWriter, r *http.Request) { http.Error(w, fmt.Sprint(err), http.StatusInternalServerError) return } - api.ReplyJSON[interface{}](w, nil) + api.ReplyJSON[any](w, nil) } func (c APIServer) uploadTestArtifact(w http.ResponseWriter, r *http.Request) { @@ -148,7 +148,7 @@ func (c APIServer) uploadTestArtifact(w http.ResponseWriter, r *http.Request) { http.Error(w, fmt.Sprint(err), http.StatusInternalServerError) return } - api.ReplyJSON[interface{}](w, nil) + api.ReplyJSON[any](w, nil) } func (c APIServer) uploadFinding(w http.ResponseWriter, r *http.Request) { @@ -162,7 +162,7 @@ func (c APIServer) uploadFinding(w http.ResponseWriter, r *http.Request) { http.Error(w, fmt.Sprint(err), http.StatusInternalServerError) return } - api.ReplyJSON[interface{}](w, nil) + api.ReplyJSON[any](w, nil) } func (c APIServer) getLastBuild(w http.ResponseWriter, r *http.Request) { @@ -224,7 +224,7 @@ func (c APIServer) uploadBaseFinding(w http.ResponseWriter, r *http.Request) { http.Error(w, fmt.Sprint(err), http.StatusInternalServerError) return } - api.ReplyJSON[interface{}](w, nil) + api.ReplyJSON[any](w, nil) } func (c APIServer) baseFindingStatus(w http.ResponseWriter, r *http.Request) { diff --git a/syz-cluster/pkg/db/base_finding_repo.go b/syz-cluster/pkg/db/base_finding_repo.go index e963cb691..9ba5df92a 100644 --- a/syz-cluster/pkg/db/base_finding_repo.go +++ b/syz-cluster/pkg/db/base_finding_repo.go @@ -38,7 +38,7 @@ CommitHash = @commit AND Config = @config AND Arch = @arch AND Title = @title`, - Params: map[string]interface{}{ + Params: map[string]any{ "commit": info.CommitHash, "config": info.Config, "arch": info.Arch, diff --git a/syz-cluster/pkg/db/build_repo.go b/syz-cluster/pkg/db/build_repo.go index 6ce088a96..8e18388af 100644 --- a/syz-cluster/pkg/db/build_repo.go +++ b/syz-cluster/pkg/db/build_repo.go @@ -44,7 +44,7 @@ type LastBuildParams struct { func (repo *BuildRepository) LastBuiltTree(ctx context.Context, params *LastBuildParams) (*Build, error) { stmt := spanner.Statement{ SQL: "SELECT * FROM `Builds` WHERE 1=1", - Params: map[string]interface{}{}, + Params: map[string]any{}, } if params.Arch != "" { stmt.SQL += " AND `Arch` = @arch" diff --git a/syz-cluster/pkg/db/finding_repo.go b/syz-cluster/pkg/db/finding_repo.go index 0c9e1e0b9..afcc559b1 100644 --- a/syz-cluster/pkg/db/finding_repo.go +++ b/syz-cluster/pkg/db/finding_repo.go @@ -44,7 +44,7 @@ func (repo *FindingRepository) Store(ctx context.Context, id *FindingID, oldFinding, err := readEntity[Finding](ctx, txn, spanner.Statement{ SQL: "SELECT * from `Findings` WHERE `SessionID`=@sessionID " + "AND `TestName` = @testName AND `Title`=@title", - Params: map[string]interface{}{ + Params: map[string]any{ "sessionID": id.SessionID, "testName": id.TestName, "title": id.Title, @@ -56,7 +56,7 @@ func (repo *FindingRepository) Store(ctx context.Context, id *FindingID, // Query the Session object. session, err := readEntity[Session](ctx, txn, spanner.Statement{ SQL: "SELECT * FROM `Sessions` WHERE `ID`=@id", - Params: map[string]interface{}{"id": id.SessionID}, + Params: map[string]any{"id": id.SessionID}, }) if err != nil { return err @@ -105,7 +105,7 @@ func (repo *FindingRepository) mustStore(ctx context.Context, finding *Finding) func (repo *FindingRepository) ListForSession(ctx context.Context, sessionID string, limit int) ([]*Finding, error) { stmt := spanner.Statement{ SQL: "SELECT * FROM `Findings` WHERE `SessionID` = @session ORDER BY `TestName`, `Title`", - Params: map[string]interface{}{"session": sessionID}, + Params: map[string]any{"session": sessionID}, } addLimit(&stmt, limit) return repo.readEntities(ctx, stmt) diff --git a/syz-cluster/pkg/db/report_reply_repo.go b/syz-cluster/pkg/db/report_reply_repo.go index e20bd6e7a..5c76b5f17 100644 --- a/syz-cluster/pkg/db/report_reply_repo.go +++ b/syz-cluster/pkg/db/report_reply_repo.go @@ -29,7 +29,7 @@ func (repo *ReportReplyRepository) FindParentReportID(ctx context.Context, repor "JOIN `SessionReports` ON `SessionReports`.ID = `ReportReplies`.ReportID " + "WHERE `ReportReplies`.MessageID = @messageID " + "AND `SessionReports`.Reporter = @reporter LIMIT 1", - Params: map[string]interface{}{ + Params: map[string]any{ "reporter": reporter, "messageID": messageID, }, @@ -50,7 +50,7 @@ func (repo *ReportReplyRepository) Insert(ctx context.Context, reply *ReportRepl entity, err := readEntity[ReportReply](ctx, txn, spanner.Statement{ SQL: "SELECT * from `ReportReplies` " + "WHERE `ReportID`=@reportID AND `MessageID`=@messageID", - Params: map[string]interface{}{ + Params: map[string]any{ "reportID": reply.ReportID, "messageID": reply.MessageID, }, @@ -75,7 +75,7 @@ func (repo *ReportReplyRepository) LastForReporter(ctx context.Context, reporter "JOIN `SessionReports` ON `SessionReports`.ID=`ReportReplies`.ReportID " + "WHERE `SessionReports`.Reporter=@reporter " + "ORDER BY `Time` DESC LIMIT 1", - Params: map[string]interface{}{ + Params: map[string]any{ "reporter": reporter, }, }) diff --git a/syz-cluster/pkg/db/report_repo.go b/syz-cluster/pkg/db/report_repo.go index 6e9f469f8..28ca3a89a 100644 --- a/syz-cluster/pkg/db/report_repo.go +++ b/syz-cluster/pkg/db/report_repo.go @@ -55,7 +55,7 @@ func (repo *ReportRepository) ListNotReported(ctx context.Context, reporter stri limit int) ([]*SessionReport, error) { stmt := spanner.Statement{ SQL: "SELECT * FROM `SessionReports` WHERE `Reporter` = @reporter AND `ReportedAt` IS NULL", - Params: map[string]interface{}{ + Params: map[string]any{ "reporter": reporter, }, } diff --git a/syz-cluster/pkg/db/series_repo.go b/syz-cluster/pkg/db/series_repo.go index 0ac32415d..bb8bf7a8d 100644 --- a/syz-cluster/pkg/db/series_repo.go +++ b/syz-cluster/pkg/db/series_repo.go @@ -38,7 +38,7 @@ func NewSeriesRepository(client *spanner.Client) *SeriesRepository { func (repo *SeriesRepository) PatchByID(ctx context.Context, id string) (*Patch, error) { return readEntity[Patch](ctx, repo.client.Single(), spanner.Statement{ SQL: "SELECT * FROM Patches WHERE ID=@id", - Params: map[string]interface{}{"id": id}, + Params: map[string]any{"id": id}, }) } @@ -46,7 +46,7 @@ func (repo *SeriesRepository) PatchByID(ctx context.Context, id string) (*Patch, func (repo *SeriesRepository) GetByExtID(ctx context.Context, extID string) (*Series, error) { return readEntity[Series](ctx, repo.client.Single(), spanner.Statement{ SQL: "SELECT * FROM Series WHERE ExtID=@extID", - Params: map[string]interface{}{"extID": extID}, + Params: map[string]any{"extID": extID}, }) } @@ -74,7 +74,7 @@ func (repo *SeriesRepository) Insert(ctx context.Context, series *Series, // Check if the series already exists. stmt := spanner.Statement{ SQL: "SELECT 1 from `Series` WHERE `ExtID`=@extID", - Params: map[string]interface{}{"ExtID": series.ExtID}, + Params: map[string]any{"ExtID": series.ExtID}, } iter := txn.Query(ctx, stmt) defer iter.Stop() @@ -142,7 +142,7 @@ func (repo *SeriesRepository) ListLatest(ctx context.Context, filter SeriesFilte stmt := spanner.Statement{ SQL: "SELECT Series.* FROM Series WHERE 1=1", - Params: map[string]interface{}{}, + Params: map[string]any{}, } if !maxPublishedAt.IsZero() { stmt.SQL += " AND PublishedAt < @toTime" @@ -226,7 +226,7 @@ func (repo *SeriesRepository) querySessions(ctx context.Context, ro *spanner.Rea } sessions, err := readEntities[Session](ctx, ro, spanner.Statement{ SQL: "SELECT * FROM Sessions WHERE ID IN UNNEST(@ids)", - Params: map[string]interface{}{ + Params: map[string]any{ "ids": keys, }, }) @@ -265,7 +265,7 @@ func (repo *SeriesRepository) queryFindingCounts(ctx context.Context, ro *spanne SQL: "SELECT `SessionID`, COUNT(`ID`) as `Count` FROM `Findings` " + "WHERE `SessionID` IN UNNEST(@ids) AND `Findings`.`InvalidatedAt` IS NULL " + "GROUP BY `SessionID`", - Params: map[string]interface{}{ + Params: map[string]any{ "ids": keys, }, }) @@ -283,7 +283,7 @@ func (repo *SeriesRepository) queryFindingCounts(ctx context.Context, ro *spanne func (repo *SeriesRepository) ListPatches(ctx context.Context, series *Series) ([]*Patch, error) { return readEntities[Patch](ctx, repo.client.Single(), spanner.Statement{ SQL: "SELECT * FROM `Patches` WHERE `SeriesID` = @seriesID ORDER BY `Seq`", - Params: map[string]interface{}{ + Params: map[string]any{ "seriesID": series.ID, }, }) diff --git a/syz-cluster/pkg/db/session_repo.go b/syz-cluster/pkg/db/session_repo.go index 3db95092b..583a5f4af 100644 --- a/syz-cluster/pkg/db/session_repo.go +++ b/syz-cluster/pkg/db/session_repo.go @@ -35,7 +35,7 @@ func (repo *SessionRepository) Start(ctx context.Context, sessionID string) erro func(ctx context.Context, txn *spanner.ReadWriteTransaction) error { session, err := readEntity[Session](ctx, txn, spanner.Statement{ SQL: "SELECT * from `Sessions` WHERE `ID`=@id", - Params: map[string]interface{}{"id": sessionID}, + Params: map[string]any{"id": sessionID}, }) if err != nil { return err @@ -50,7 +50,7 @@ func (repo *SessionRepository) Start(ctx context.Context, sessionID string) erro } series, err := readEntity[Series](ctx, txn, spanner.Statement{ SQL: "SELECT * from `Series` WHERE `ID`=@id", - Params: map[string]interface{}{"id": session.SeriesID}, + Params: map[string]any{"id": session.SeriesID}, }) if err != nil { return err @@ -87,7 +87,7 @@ func (repo *SessionRepository) ListWaiting(ctx context.Context, from *NextSessio limit int) ([]*Session, *NextSession, error) { stmt := spanner.Statement{ SQL: "SELECT * FROM `Sessions` WHERE `StartedAt` IS NULL", - Params: map[string]interface{}{}, + Params: map[string]any{}, } if from != nil { stmt.SQL += " AND ((`CreatedAt` > @from) OR (`CreatedAt` = @from AND `ID` > @id))" @@ -114,7 +114,7 @@ func (repo *SessionRepository) ListWaiting(ctx context.Context, from *NextSessio func (repo *SessionRepository) ListForSeries(ctx context.Context, series *Series) ([]*Session, error) { return repo.readEntities(ctx, spanner.Statement{ SQL: "SELECT * FROM `Sessions` WHERE `SeriesID` = @series ORDER BY CreatedAt DESC", - Params: map[string]interface{}{"series": series.ID}, + Params: map[string]any{"series": series.ID}, }) } @@ -129,7 +129,7 @@ func (repo *SessionRepository) MissingReportList(ctx context.Context, from time. "SELECT 1 FROM SessionReports WHERE SessionReports.SessionID = Sessions.ID" + ") AND EXISTS (" + "SELECT 1 FROM Findings WHERE Findings.SessionID = Sessions.ID)", - Params: map[string]interface{}{}, + Params: map[string]any{}, } if !from.IsZero() { stmt.SQL += " AND `FinishedAt` > @from" diff --git a/syz-cluster/pkg/db/session_test_repo.go b/syz-cluster/pkg/db/session_test_repo.go index 03316c38c..3454f11bb 100644 --- a/syz-cluster/pkg/db/session_test_repo.go +++ b/syz-cluster/pkg/db/session_test_repo.go @@ -27,7 +27,7 @@ func (repo *SessionTestRepository) InsertOrUpdate(ctx context.Context, test *Ses // Check if the test already exists. dbTest, err := readEntity[SessionTest](ctx, txn, spanner.Statement{ SQL: "SELECT * from `SessionTests` WHERE `SessionID`=@sessionID AND `TestName` = @testName", - Params: map[string]interface{}{ + Params: map[string]any{ "sessionID": test.SessionID, "testName": test.TestName, }, @@ -62,7 +62,7 @@ func (repo *SessionTestRepository) InsertOrUpdate(ctx context.Context, test *Ses func (repo *SessionTestRepository) Get(ctx context.Context, sessionID, testName string) (*SessionTest, error) { return readEntity[SessionTest](ctx, repo.client.Single(), spanner.Statement{ SQL: "SELECT * FROM `SessionTests` WHERE `SessionID` = @session AND `TestName` = @name", - Params: map[string]interface{}{ + Params: map[string]any{ "session": sessionID, "name": testName, }, @@ -99,7 +99,7 @@ func (repo *SessionTestRepository) BySession(ctx context.Context, sessionID stri } builds, err := readEntities[Build](ctx, repo.client.Single(), spanner.Statement{ SQL: "SELECT * FROM `Builds` WHERE `ID` IN UNNEST(@ids)", - Params: map[string]interface{}{"ids": keys}, + Params: map[string]any{"ids": keys}, }) if err != nil { return nil, err @@ -117,6 +117,6 @@ func (repo *SessionTestRepository) BySessionRaw(ctx context.Context, sessionID s return readEntities[SessionTest](ctx, repo.client.Single(), spanner.Statement{ SQL: "SELECT * FROM `SessionTests` WHERE `SessionID` = @session" + " ORDER BY `UpdatedAt`", - Params: map[string]interface{}{"session": sessionID}, + Params: map[string]any{"session": sessionID}, }) } diff --git a/syz-cluster/pkg/db/spanner.go b/syz-cluster/pkg/db/spanner.go index 659ff6c76..11933961a 100644 --- a/syz-cluster/pkg/db/spanner.go +++ b/syz-cluster/pkg/db/spanner.go @@ -305,7 +305,7 @@ type genericEntityOps[EntityType, KeyType any] struct { func (g *genericEntityOps[EntityType, KeyType]) GetByID(ctx context.Context, key KeyType) (*EntityType, error) { stmt := spanner.Statement{ SQL: "SELECT * FROM " + g.table + " WHERE " + g.keyField + "=@key", - Params: map[string]interface{}{"key": key}, + Params: map[string]any{"key": key}, } return readEntity[EntityType](ctx, g.client.Single(), stmt) } @@ -318,7 +318,7 @@ func (g *genericEntityOps[EntityType, KeyType]) Update(ctx context.Context, key func(ctx context.Context, txn *spanner.ReadWriteTransaction) error { entity, err := readEntity[EntityType](ctx, txn, spanner.Statement{ SQL: "SELECT * from `" + g.table + "` WHERE `" + g.keyField + "`=@key", - Params: map[string]interface{}{"key": key}, + Params: map[string]any{"key": key}, }) if err != nil { return err diff --git a/syz-cluster/pkg/reporter/api.go b/syz-cluster/pkg/reporter/api.go index 310dd57d1..192ea693d 100644 --- a/syz-cluster/pkg/reporter/api.go +++ b/syz-cluster/pkg/reporter/api.go @@ -46,13 +46,13 @@ func (s *APIServer) upstreamReport(w http.ResponseWriter, r *http.Request) { } // TODO: journal the action. err := s.reportService.Upstream(r.Context(), r.PathValue("report_id"), req) - reply[interface{}](w, nil, err) + reply[any](w, nil, err) } func (s *APIServer) invalidateReport(w http.ResponseWriter, r *http.Request) { // TODO: journal the action. err := s.reportService.Invalidate(r.Context(), r.PathValue("report_id")) - reply[interface{}](w, nil, err) + reply[any](w, nil, err) } func (s *APIServer) nextReports(w http.ResponseWriter, r *http.Request) { @@ -62,7 +62,7 @@ func (s *APIServer) nextReports(w http.ResponseWriter, r *http.Request) { func (s *APIServer) confirmReport(w http.ResponseWriter, r *http.Request) { err := s.reportService.Confirm(r.Context(), r.PathValue("report_id")) - reply[interface{}](w, nil, err) + reply[any](w, nil, err) } func (s *APIServer) recordReply(w http.ResponseWriter, r *http.Request) { -- cgit mrf-deployment