Skip to content

Commit 57666d0

Browse files
Fix Int cast flagged by copilot (#416)
1 parent 94bc54d commit 57666d0

6 files changed

Lines changed: 20 additions & 11 deletions

File tree

pkg/ipc/ipc.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/ipc/ipc_grpc.pb.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/service/debug.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ import (
2121
"strconv"
2222
"strings"
2323

24-
"github.com/livekit/ingress/pkg/errors"
2524
"github.com/livekit/protocol/logger"
2625
"github.com/livekit/protocol/pprof"
2726
"github.com/livekit/psrpc"
27+
28+
"github.com/livekit/ingress/pkg/errors"
2829
)
2930

3031
const (
@@ -80,14 +81,22 @@ func (s *Service) handlePProf(w http.ResponseWriter, r *http.Request) {
8081
var err error
8182
var b []byte
8283

83-
timeout, _ := strconv.Atoi(r.URL.Query().Get("timeout"))
84-
debug, _ := strconv.Atoi(r.URL.Query().Get("debug"))
84+
timeout, err := strconv.ParseInt(r.URL.Query().Get("timeout"), 10, 32)
85+
if err != nil {
86+
http.Error(w, "malformed timeout", http.StatusBadRequest)
87+
return
88+
}
89+
debug, err := strconv.ParseInt(r.URL.Query().Get("debug"), 10, 32)
90+
if err != nil {
91+
http.Error(w, "malformed debug", http.StatusBadRequest)
92+
return
93+
}
8594

8695
pathElements := strings.Split(r.URL.Path, "/")
8796
switch len(pathElements) {
8897
case 3:
8998
// profile main service
90-
b, err = pprof.GetProfileData(context.Background(), pathElements[2], timeout, debug)
99+
b, err = pprof.GetProfileData(context.Background(), pathElements[2], int(timeout), int(debug))
91100

92101
case 4:
93102
resourceID := pathElements[2]
@@ -97,7 +106,7 @@ func (s *Service) handlePProf(w http.ResponseWriter, r *http.Request) {
97106
return
98107
}
99108

100-
b, err = api.GetProfileData(context.Background(), pathElements[3], timeout, debug)
109+
b, err = api.GetProfileData(context.Background(), pathElements[3], int32(timeout), int32(debug))
101110
if err != nil {
102111
return
103112
}

pkg/service/process_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ func (p *process) WHIPRTCConnectionNotify(ctx context.Context, req *rpc.WHIPRTCC
297297
return &google_protobuf2.Empty{}, nil
298298
}
299299

300-
func (p *process) GetProfileData(ctx context.Context, profileName string, timeout int, debug int) (b []byte, err error) {
300+
func (p *process) GetProfileData(ctx context.Context, profileName string, timeout int32, debug int32) (b []byte, err error) {
301301
grpcClient := p.grpcClient.Load()
302302
if grpcClient == nil {
303303
return nil, errors.ErrIngressNotFound

pkg/service/service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -562,8 +562,8 @@ type localSessionAPI struct {
562562
sessionCloser
563563
}
564564

565-
func (a *localSessionAPI) GetProfileData(ctx context.Context, profileName string, timeout int, debug int) (b []byte, err error) {
566-
return pprof.GetProfileData(ctx, profileName, timeout, debug)
565+
func (a *localSessionAPI) GetProfileData(ctx context.Context, profileName string, timeout int32, debug int32) (b []byte, err error) {
566+
return pprof.GetProfileData(ctx, profileName, int(timeout), int(debug))
567567
}
568568

569569
func (a *localSessionAPI) GetPipelineDot(ctx context.Context) (string, error) {

pkg/types/session_api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type SessionAPI interface {
2222
MediaStatsUpdater
2323
MediaStatGatherer
2424

25-
GetProfileData(ctx context.Context, profileName string, timeout int, debug int) (b []byte, err error)
25+
GetProfileData(ctx context.Context, profileName string, timeout int32, debug int32) (b []byte, err error)
2626
GetPipelineDot(ctx context.Context) (string, error)
2727
CloseSession(ctx context.Context)
2828
}

0 commit comments

Comments
 (0)