Skip to content

Commit

Permalink
fix: 'nf_discovery.go' range-based loop & linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
KunLee76 committed Oct 1, 2024
1 parent b9bc331 commit b82be5b
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 22 deletions.
4 changes: 1 addition & 3 deletions internal/sbi/api_bootstrapping.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


package sbi

import (
Expand Down Expand Up @@ -29,4 +27,4 @@ func (s *Server) getBootstrappingRoutes() []Route {

func (s *Server) HTTPBootstrappingInfoRequest(c *gin.Context) {
c.JSON(http.StatusNotImplemented, gin.H{})
}
}
3 changes: 0 additions & 3 deletions internal/sbi/api_nfmanagement.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@ import (

"github.com/gin-gonic/gin"
"github.com/mitchellh/mapstructure"
// "go.mongodb.org/mongo-driver/bson"

// nrf_context "github.com/free5gc/nrf/internal/context"
"github.com/free5gc/nrf/internal/logger"
"github.com/free5gc/nrf/internal/util"
"github.com/free5gc/openapi"
"github.com/free5gc/openapi/models"
// timedecode "github.com/free5gc/util/mapstruct"
// "github.com/free5gc/util/mongoapi"
)

func (s *Server) getNfRegisterRoute() []Route {
Expand Down
2 changes: 1 addition & 1 deletion internal/sbi/consumer/nrf_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,6 @@ func (s *nnrfService) SendNFStatusNotify(
}
return problemDetails
}

return nil
}
28 changes: 14 additions & 14 deletions internal/sbi/processor/nf_discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,31 +143,31 @@ func (p *Processor) NFDiscoveryProcedure(c *gin.Context, queryParameters url.Val

// handle ipv4 & ipv6
if queryParameters["target-nf-type"][0] == "BSF" {
for i, nfProfile := range nfProfilesStruct {
for _, nfProfile := range nfProfilesStruct {

Check failure on line 146 in internal/sbi/processor/nf_discovery.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

rangeValCopy: each iteration copies 880 bytes (consider pointers or indexing) (gocritic)
if nfProfile.BsfInfo != nil && nfProfile.BsfInfo.Ipv4AddressRanges != nil {
for j := range nfProfile.BsfInfo.Ipv4AddressRanges {
ipv4IntStart, errAtoi := strconv.Atoi(nfProfilesStruct[i].BsfInfo.Ipv4AddressRanges[j].Start)
for addressRange := range nfProfile.BsfInfo.Ipv4AddressRanges {
ipv4IntStart, errAtoi := strconv.Atoi(nfProfile.BsfInfo.Ipv4AddressRanges[addressRange].Start)
if errAtoi != nil {
logger.DiscLog.Warnln("ipv4IntStart Atoi Error: ", errAtoi)
}
((nfProfilesStruct[i].BsfInfo.Ipv4AddressRanges)[j]).Start = nrf_context.Ipv4IntToIpv4String(int64(ipv4IntStart))
ipv4IntEnd, errAtoi := strconv.Atoi((((nfProfilesStruct[i].BsfInfo.Ipv4AddressRanges)[j]).End))
}
((nfProfile.BsfInfo.Ipv4AddressRanges)[addressRange]).Start = nrf_context.Ipv4IntToIpv4String(int64(ipv4IntStart))
ipv4IntEnd, errAtoi := strconv.Atoi((((nfProfile.BsfInfo.Ipv4AddressRanges)[addressRange]).End))
if errAtoi != nil {
logger.DiscLog.Warnln("ipv4IntEnd Atoi Error: ", errAtoi)
}
((nfProfilesStruct[i].BsfInfo.Ipv4AddressRanges)[j]).End = nrf_context.Ipv4IntToIpv4String(int64(ipv4IntEnd))
}
((nfProfile.BsfInfo.Ipv4AddressRanges)[addressRange]).End = nrf_context.Ipv4IntToIpv4String(int64(ipv4IntEnd))
}
}

if nfProfile.BsfInfo != nil && nfProfile.BsfInfo.Ipv6PrefixRanges != nil {
for j := range nfProfile.BsfInfo.Ipv6PrefixRanges {
for prefixRange := range nfProfile.BsfInfo.Ipv6PrefixRanges {
ipv6IntStart := new(big.Int)
ipv6IntStart.SetString(((nfProfilesStruct[i].BsfInfo.Ipv6PrefixRanges)[j]).Start, 10)
((nfProfilesStruct[i].BsfInfo.Ipv6PrefixRanges)[j]).Start = nrf_context.Ipv6IntToIpv6String(ipv6IntStart)
ipv6IntStart.SetString(((nfProfile.BsfInfo.Ipv6PrefixRanges)[prefixRange]).Start, 10)
((nfProfile.BsfInfo.Ipv6PrefixRanges)[prefixRange]).Start = nrf_context.Ipv6IntToIpv6String(ipv6IntStart)

ipv6IntEnd := new(big.Int)
ipv6IntEnd.SetString(((nfProfilesStruct[i].BsfInfo.Ipv6PrefixRanges)[j]).End, 10)
((nfProfilesStruct[i].BsfInfo.Ipv6PrefixRanges)[j]).End = nrf_context.Ipv6IntToIpv6String(ipv6IntEnd)
ipv6IntEnd.SetString(((nfProfile.BsfInfo.Ipv6PrefixRanges)[prefixRange]).End, 10)
((nfProfile.BsfInfo.Ipv6PrefixRanges)[prefixRange]).End = nrf_context.Ipv6IntToIpv6String(ipv6IntEnd)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/factory/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const (
NrfSbiDefaultScheme = "https"
NrfNfmResUriPrefix = "/nnrf-nfm/v1"
NrfDiscResUriPrefix = "/nnrf-disc/v1"
NrfBootstrappingPrefix = "/bootstrapping"
NrfBootstrappingPrefix = "/bootstrapping"
)

type Config struct {
Expand Down

0 comments on commit b82be5b

Please sign in to comment.