[VOL-3285] Resolving statis code analysis warnings
Change-Id: Iaddaae92c649fd27ce0a63f1786af594667c9e8e
diff --git a/internal/bbsim/responders/sadis/sadis.go b/internal/bbsim/responders/sadis/sadis.go
index ac084a5..75a6fd9 100644
--- a/internal/bbsim/responders/sadis/sadis.go
+++ b/internal/bbsim/responders/sadis/sadis.go
@@ -38,10 +38,10 @@
// bandwidthProfiles contains some dummy profiles
var bandwidthProfiles = []*SadisBWPEntry{
- &SadisBWPEntry{ID: "User_Bandwidth1", AIR: 100000, CBS: 10000, CIR: 30000, EBS: 1000, EIR: 100000},
- &SadisBWPEntry{ID: "User_Bandwidth2", AIR: 100000, CBS: 5000, CIR: 100000, EBS: 5000, EIR: 100000},
- &SadisBWPEntry{ID: "User_Bandwidth3", AIR: 100000, CBS: 5000, CIR: 1000000, EBS: 5000, EIR: 1000000},
- &SadisBWPEntry{ID: "Default", AIR: 100000, CBS: 30, CIR: 600, EBS: 30, EIR: 400},
+ {ID: "User_Bandwidth1", AIR: 100000, CBS: 10000, CIR: 30000, EBS: 1000, EIR: 100000},
+ {ID: "User_Bandwidth2", AIR: 100000, CBS: 5000, CIR: 100000, EBS: 5000, EIR: 100000},
+ {ID: "User_Bandwidth3", AIR: 100000, CBS: 5000, CIR: 1000000, EBS: 5000, EIR: 1000000},
+ {ID: "Default", AIR: 100000, CBS: 30, CIR: 600, EBS: 30, EIR: 400},
}
// SadisConfig is the top-level SADIS configuration struct
@@ -97,22 +97,22 @@
}
type SadisUniTagAtt struct {
- PonCTag int `json:"ponCTag, omitempty"`
- PonSTag int `json:"ponSTag, omitempty"`
- TechnologyProfileID int `json:"technologyProfileId, omitempty"`
- UpstreamBandwidthProfile string `json:"upstreamBandwidthProfile, omitempty"`
- DownstreamBandwidthProfile string `json:"downstreamBandwidthProfile, omitempty"`
- IsDhcpRequired bool `json:"isDhcpRequired, omitempty"`
- IsIgmpRequired bool `json:"isIgmpRequired, omitempty"`
+ PonCTag int `json:"ponCTag,omitempty"`
+ PonSTag int `json:"ponSTag,omitempty"`
+ TechnologyProfileID int `json:"technologyProfileId,omitempty"`
+ UpstreamBandwidthProfile string `json:"upstreamBandwidthProfile,omitempty"`
+ DownstreamBandwidthProfile string `json:"downstreamBandwidthProfile,omitempty"`
+ IsDhcpRequired bool `json:"isDhcpRequired,omitempty"`
+ IsIgmpRequired bool `json:"isIgmpRequired,omitempty"`
}
type SadisUniTagDt struct {
- UniTagMatch int `json:"uniTagMatch, omitempty"`
- PonCTag int `json:"ponCTag, omitempty"`
- PonSTag int `json:"ponSTag, omitempty"`
- TechnologyProfileID int `json:"technologyProfileId, omitempty"`
- UpstreamBandwidthProfile string `json:"upstreamBandwidthProfile, omitempty"`
- DownstreamBandwidthProfile string `json:"downstreamBandwidthProfile, omitempty"`
+ UniTagMatch int `json:"uniTagMatch,omitempty"`
+ PonCTag int `json:"ponCTag,omitempty"`
+ PonSTag int `json:"ponSTag,omitempty"`
+ TechnologyProfileID int `json:"technologyProfileId,omitempty"`
+ UpstreamBandwidthProfile string `json:"upstreamBandwidthProfile,omitempty"`
+ DownstreamBandwidthProfile string `json:"downstreamBandwidthProfile,omitempty"`
}
// SADIS BandwithProfile Entry
@@ -256,7 +256,7 @@
if vars["version"] != "v1" && vars["version"] != "v2" {
w.WriteHeader(http.StatusNotFound)
- w.Write([]byte("{}"))
+ _, _ = w.Write([]byte("{}"))
return
}
@@ -265,7 +265,7 @@
sadisJSON, _ := json.Marshal(sadisConf)
sadisLogger.Tracef("SADIS JSON: %s", sadisJSON)
- w.Write([]byte(sadisJSON))
+ _, _ = w.Write([]byte(sadisJSON))
}
@@ -296,7 +296,7 @@
sadisJSON, _ := json.Marshal(sadisConf)
sadisLogger.Tracef("SADIS JSON: %s", sadisJSON)
- w.Write([]byte(sadisJSON))
+ _, _ = w.Write([]byte(sadisJSON))
}
@@ -313,14 +313,14 @@
sadisConf, _ := GetOltEntry(s.olt)
w.WriteHeader(http.StatusOK)
- json.NewEncoder(w).Encode(sadisConf)
+ _ = json.NewEncoder(w).Encode(sadisConf)
return
}
i := strings.Split(vars["ID"], "-") // split ID to get serial number and uni port
if len(i) != 2 {
w.WriteHeader(http.StatusUnprocessableEntity)
- w.Write([]byte("{}"))
+ _, _ = w.Write([]byte("{}"))
sadisLogger.Warnf("Received invalid SADIS SubscriberId: %s", vars["ID"])
return
}
@@ -329,7 +329,7 @@
onu, err := s.olt.FindOnuBySn(sn)
if err != nil {
w.WriteHeader(http.StatusNotFound)
- w.Write([]byte("{}"))
+ _, _ = w.Write([]byte("{}"))
sadisLogger.WithFields(log.Fields{
"OnuSn": sn,
"OnuId": "NA",
@@ -346,10 +346,10 @@
w.WriteHeader(http.StatusOK)
if vars["version"] == "v1" {
sadisConf, _ := GetOnuEntryV1(s.olt, onu, uni)
- json.NewEncoder(w).Encode(sadisConf)
+ _ = json.NewEncoder(w).Encode(sadisConf)
} else if vars["version"] == "v2" {
sadisConf, _ := GetOnuEntryV2(s.olt, onu, uni)
- json.NewEncoder(w).Encode(sadisConf)
+ _ = json.NewEncoder(w).Encode(sadisConf)
}
}
@@ -361,7 +361,7 @@
if vars["version"] != "v1" && vars["version"] != "v2" {
w.WriteHeader(http.StatusNotFound)
- w.Write([]byte("{}"))
+ _, _ = w.Write([]byte("{}"))
return
}
@@ -370,13 +370,13 @@
for _, bwpEntry := range bandwidthProfiles {
if bwpEntry.ID == id {
w.WriteHeader(http.StatusOK)
- json.NewEncoder(w).Encode(bwpEntry)
+ _ = json.NewEncoder(w).Encode(bwpEntry)
return
}
}
w.WriteHeader(http.StatusNotFound)
- w.Write([]byte("{}"))
+ _, _ = w.Write([]byte("{}"))
}
// StartRestServer starts REST server which returns a SADIS configuration for the currently simulated OLT
diff --git a/internal/bbsim/responders/sadis/sadis_test.go b/internal/bbsim/responders/sadis/sadis_test.go
index 59c3874..04e0240 100644
--- a/internal/bbsim/responders/sadis/sadis_test.go
+++ b/internal/bbsim/responders/sadis/sadis_test.go
@@ -26,12 +26,12 @@
"gotest.tools/assert"
)
-func createMockDevices() (devices.OltDevice, devices.Onu) {
- olt := devices.OltDevice{
+func createMockDevices() (*devices.OltDevice, *devices.Onu) {
+ olt := &devices.OltDevice{
ID: 0,
}
- onu := devices.Onu{
+ onu := &devices.Onu{
ID: 1,
PonPortID: 1,
STag: 900,
@@ -50,7 +50,7 @@
uni := "1"
- res, err := GetOnuEntryV1(&olt, &onu, uni)
+ res, err := GetOnuEntryV1(olt, onu, uni)
if err != nil {
t.Fatal(err)
}
@@ -70,7 +70,7 @@
uni := "1"
- res, err := GetOnuEntryV2(&olt, &onu, uni)
+ res, err := GetOnuEntryV2(olt, onu, uni)
if err != nil {
t.Fatal(err)
}
@@ -99,7 +99,7 @@
uni := "1"
- res, err := GetOnuEntryV2(&olt, &onu, uni)
+ res, err := GetOnuEntryV2(olt, onu, uni)
if err != nil {
t.Fatal(err)
}