Skip to content

Commit a7a2dc5

Browse files
wenyingdhongliangl
authored andcommitted
Bump up golangci-bin version
1. Bump up golangci-bin version to v1.50.0 2. Remove invalid configurations in golangci.yml 3. Formated several files 4. Removed unused code which is for padding messages Signed-off-by: wenyingd <[email protected]>
1 parent 2ade3b2 commit a7a2dc5

File tree

21 files changed

+269
-322
lines changed

21 files changed

+269
-322
lines changed

.golangci.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@ linters-settings:
1212
linters:
1313
disable-all: true
1414
enable: # see https://golangci-lint.run/usage/linters/
15-
- deadcode
15+
- unused
1616
- staticcheck
1717
- govet
1818
- gofmt
1919
- goimports
2020
- gosec
2121
- misspell
22-
23-
run:
24-
deadline: 5m

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ test:
99
# code linting
1010
.golangci-bin:
1111
@echo "===> Installing Golangci-lint <==="
12-
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $@ v1.41.1
12+
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $@ v1.50.0
1313

1414
.PHONY: golangci
1515
golangci: .golangci-bin

openflow13/action.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ func (a *ActionGroup) UnmarshalBinary(data []byte) error {
276276
type ActionMplsTtl struct {
277277
ActionHeader
278278
MplsTtl uint8
279-
pad []byte // 3bytes
279+
// 3 bytes for padding
280280
}
281281

282282
type ActionDecNwTtl struct {
@@ -315,13 +315,12 @@ func (a *ActionDecNwTtl) UnmarshalBinary(data []byte) error {
315315
type ActionNwTtl struct {
316316
ActionHeader
317317
NwTtl uint8
318-
pad []byte // 3bytes
318+
// 3 bytes for padding
319319
}
320320

321321
type ActionPush struct {
322322
ActionHeader
323323
EtherType uint16
324-
pad []byte // 2bytes
325324
}
326325

327326
func NewActionPushVlan(etherType uint16) *ActionPush {
@@ -362,7 +361,6 @@ func (a *ActionPush) UnmarshalBinary(data []byte) error {
362361

363362
type ActionPopVlan struct {
364363
ActionHeader
365-
pad []byte // 4bytes
366364
}
367365

368366
func NewActionPopVlan() *ActionPopVlan {
@@ -395,7 +393,6 @@ func (a *ActionPopVlan) UnmarshalBinary(data []byte) error {
395393
type ActionPopMpls struct {
396394
ActionHeader
397395
EtherType uint16
398-
pad []byte // 2bytes
399396
}
400397

401398
func NewActionPopMpls(etherType uint16) *ActionPopMpls {

openflow13/bundles.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,15 @@ func NewBundlePropertyExperimenter() *BundlePropertyExperimenter {
165165
// it, if the added messages are not wanted to realize on the switch.
166166
type BundleAdd struct {
167167
BundleID uint32
168-
pad [2]byte
169168
Flags uint16
170169
Message util.Message
171170
Properties []BundlePropertyExperimenter
172171
}
173172

174173
func (b *BundleAdd) Len() (n uint16) {
175174
length := uint16(unsafe.Sizeof(b.BundleID) + unsafe.Sizeof(b.Flags))
176-
length += uint16(len(b.pad))
175+
// 2 bytes for padding
176+
length += 2
177177
length += b.Message.Len()
178178
if b.Properties != nil {
179179
for _, p := range b.Properties {

openflow13/flowmod.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ type FlowMod struct {
2727
OutGroup uint32
2828
Flags uint16
2929

30-
pad []byte // 2bytes
31-
3230
Match Match // Fields to match
3331
Instructions []Instruction // Instruction set - 0 or more.
3432
}

openflow13/match.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func (m *MatchField) MarshalBinary() (data []byte, err error) {
127127
if m.HasMask {
128128
fld = (m.Field << 1) | 0x1
129129
} else {
130-
fld = (m.Field << 1) | 0x0
130+
fld = m.Field << 1
131131
}
132132
data[n] = fld
133133
n += 1
@@ -477,7 +477,7 @@ func DecodeMatchField(class uint16, field uint8, length uint8, hasMask bool, dat
477477
return nil, nil
478478
}
479479

480-
// ofp_match_type 1.3
480+
// ofp_match_type 1.3
481481
const (
482482
MatchType_Standard = iota /* Deprecated. */
483483
MatchType_OXM

openflow13/meter.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ func (m *MeterBandHeader) UnmarshalBinary(data []byte) error {
8181

8282
type MeterBandDrop struct {
8383
MeterBandHeader /* Type: OFPMBT13_DROP. */
84-
pad [4]uint8
8584
}
8685

8786
func (m *MeterBandDrop) Len() (n uint16) {
@@ -111,7 +110,6 @@ func (m *MeterBandDrop) UnmarshalBinary(data []byte) error {
111110
type MeterBandDSCP struct {
112111
MeterBandHeader /* Type: OFPMBT13_DSCP_REMARK. */
113112
PrecLevel uint8 /* Number of drop precedence level to add. */
114-
pad [3]uint8
115113
}
116114

117115
func (m *MeterBandDSCP) Len() (n uint16) {

openflow13/multipart.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ type MultipartRequest struct {
1515
common.Header
1616
Type uint16
1717
Flags uint16
18-
pad []byte // 4 bytes
1918
Body []util.Message
2019
}
2120

@@ -103,7 +102,6 @@ type MultipartReply struct {
103102
common.Header
104103
Type uint16
105104
Flags uint16
106-
pad []byte // 4 bytes
107105
Body []util.Message
108106
}
109107

@@ -1324,7 +1322,6 @@ type OFPTableFeatures struct {
13241322
Length uint16
13251323
TableID uint8
13261324
Command uint8
1327-
pad [4]uint8
13281325
Name [32]byte
13291326
MetadataMatch uint64
13301327
MetadataWrite uint64
@@ -1350,6 +1347,7 @@ func (f *OFPTableFeatures) MarshalBinary() (data []byte, err error) {
13501347
n += 1
13511348
data[n] = f.Command
13521349
n += 1
1350+
// 4 bytes for padding
13531351
n += 4
13541352
copy(data[n:], f.Name[:32])
13551353
n += 32

openflow13/nx_action.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,11 +1218,9 @@ type NXActionLearn struct {
12181218
Cookie uint64
12191219
Flags uint16
12201220
TableID uint8
1221-
pad uint8
12221221
FinIdleTimeout uint16
12231222
FinHardTimeout uint16
12241223
LearnSpecs []*NXLearnSpec
1225-
pad2 []byte
12261224
}
12271225

12281226
func (a *NXActionLearn) Len() uint16 {
@@ -1252,7 +1250,9 @@ func (a *NXActionLearn) MarshalBinary() (data []byte, err error) {
12521250
binary.BigEndian.PutUint16(data[n:], a.Flags)
12531251
n += 2
12541252
data[n] = a.TableID
1255-
n += 2
1253+
n += 1
1254+
// 1 byte for padding
1255+
n += 1
12561256
binary.BigEndian.PutUint16(data[n:], a.FinIdleTimeout)
12571257
n += 2
12581258
binary.BigEndian.PutUint16(data[n:], a.FinHardTimeout)
@@ -1364,7 +1364,6 @@ func NewNXActionNote() *NXActionNote {
13641364
type NXActionRegLoad2 struct {
13651365
*NXActionHeader
13661366
DstField *MatchField
1367-
pad []byte
13681367
}
13691368

13701369
func NewNXActionRegLoad2(dstField *MatchField) *NXActionRegLoad2 {
@@ -1417,7 +1416,6 @@ type NXActionController struct {
14171416
MaxLen uint16
14181417
ControllerID uint16
14191418
Reason uint8
1420-
pad uint8
14211419
}
14221420

14231421
func (a *NXActionController) Len() uint16 {
@@ -1487,7 +1485,6 @@ const (
14871485
type NXActionController2PropMaxLen struct {
14881486
*PropHeader /* Type: NXAC2PT_MAX_LEN */
14891487
MaxLen uint16
1490-
pad [2]uint8
14911488
}
14921489

14931490
func (a *NXActionController2PropMaxLen) Len() uint16 {
@@ -1539,7 +1536,6 @@ func NewMaxLen(maxLen uint16) *NXActionController2PropMaxLen {
15391536
type NXActionController2PropControllerID struct {
15401537
*PropHeader /* Type: NXAC2PT_CONTROLLER_ID */
15411538
ControllerID uint16
1542-
pad [2]uint8
15431539
}
15441540

15451541
func (a *NXActionController2PropControllerID) Len() uint16 {
@@ -1591,7 +1587,6 @@ func NewControllerID(controllerID uint16) *NXActionController2PropControllerID {
15911587
type NXActionController2PropReason struct {
15921588
*PropHeader /* Type: NXAC2PT_REASON */
15931589
Reason uint8
1594-
pad [3]uint8
15951590
}
15961591

15971592
func (a *NXActionController2PropReason) Len() uint16 {
@@ -1643,7 +1638,6 @@ func NewReason(reason uint8) *NXActionController2PropReason {
16431638
type NXActionController2PropUserdata struct {
16441639
*PropHeader /* Type: NXAC2PT_USERDATA */
16451640
Userdata []byte
1646-
pad []uint8
16471641
}
16481642

16491643
func (a *NXActionController2PropUserdata) Len() uint16 {
@@ -1695,7 +1689,6 @@ func NewUserdata(userdata []byte) *NXActionController2PropUserdata {
16951689

16961690
type NXActionController2PropPause struct {
16971691
*PropHeader /* Type: NXAC2PT_PAUSE */
1698-
pad [4]uint8
16991692
}
17001693

17011694
func (a *NXActionController2PropPause) Len() uint16 {
@@ -1818,7 +1811,6 @@ func DecodeController2Prop(data []byte) (Property, error) {
18181811
// NXActionController2 is NX action to output packet to the Controller set with a specified ID.
18191812
type NXActionController2 struct {
18201813
*NXActionHeader
1821-
pad [6]uint8
18221814

18231815
props []Property
18241816
}
@@ -1843,6 +1835,7 @@ func (a *NXActionController2) MarshalBinary() (data []byte, err error) {
18431835
}
18441836
copy(data[n:], b)
18451837
n += int(a.NXActionHeader.Len())
1838+
// 6 bytes for padding
18461839
n += 6
18471840

18481841
for _, prop := range a.props {

openflow13/nxt_message.go

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,11 @@ func NewSetPacketInFormet(format uint32) *VendorHeader {
8080
}
8181

8282
type ControllerID struct {
83-
pad [6]byte
84-
ID uint16
83+
ID uint16
8584
}
8685

8786
func (c *ControllerID) Len() uint16 {
88-
return uint16(len(c.pad) + 2)
87+
return 8
8988
}
9089

9190
func (c *ControllerID) MarshalBinary() (data []byte, err error) {
@@ -117,11 +116,10 @@ type TLVTableMap struct {
117116
OptType uint8
118117
OptLength uint8
119118
Index uint16
120-
pad [2]byte
121119
}
122120

123121
func (t *TLVTableMap) Len() uint16 {
124-
return uint16(len(t.pad) + 6)
122+
return 8
125123
}
126124

127125
func (t *TLVTableMap) MarshalBinary() (data []byte, err error) {
@@ -154,7 +152,6 @@ func (t *TLVTableMap) UnmarshalBinary(data []byte) error {
154152

155153
type TLVTableMod struct {
156154
Command uint16
157-
pad [6]byte
158155
TlvMaps []*TLVTableMap
159156
}
160157

@@ -292,7 +289,6 @@ const (
292289
type ContinuationPropBridge struct {
293290
*PropHeader /* Type: NXCPT_BRIDGE */
294291
Bridge [4]uint32
295-
pad [4]uint8
296292
}
297293

298294
func (p *ContinuationPropBridge) Len() (n uint16) {
@@ -341,7 +337,6 @@ func (p *ContinuationPropBridge) UnmarshalBinary(data []byte) error {
341337
type ContinuationPropStack struct {
342338
*PropHeader /* Type: NXCPT_STACK */
343339
Stack []uint8
344-
pad []uint8
345340
}
346341

347342
func (p *ContinuationPropStack) Len() (n uint16) {
@@ -430,7 +425,6 @@ func (p *ContinuationPropMirrors) UnmarshalBinary(data []byte) error {
430425

431426
type ContinuationPropConntracked struct {
432427
*PropHeader /* Type: NXCPT_CONNTRACKED */
433-
pad [4]uint8
434428
}
435429

436430
func (p *ContinuationPropConntracked) Len() (n uint16) {
@@ -469,7 +463,6 @@ func (p *ContinuationPropConntracked) UnmarshalBinary(data []byte) error {
469463
type ContinuationPropTableID struct {
470464
*PropHeader /* Type: NXCPT_TABLE_ID */
471465
TableID uint8
472-
pad [3]uint8
473466
}
474467

475468
func (p *ContinuationPropTableID) Len() (n uint16) {
@@ -511,7 +504,6 @@ func (p *ContinuationPropTableID) UnmarshalBinary(data []byte) error {
511504

512505
type ContinuationPropCookie struct {
513506
*PropHeader /* Type: NXCPT_COOKIE */
514-
pad [4]uint8
515507
Cookie uint64
516508
}
517509

@@ -554,7 +546,6 @@ func (p *ContinuationPropCookie) UnmarshalBinary(data []byte) error {
554546

555547
type ContinuationPropActions struct {
556548
*PropHeader /* Type: NXCPT_ACTIONS */
557-
pad [4]uint8
558549
Actions []Action
559550
}
560551

@@ -617,7 +608,6 @@ func (p *ContinuationPropActions) UnmarshalBinary(data []byte) error {
617608

618609
type ContinuationPropActionSet struct {
619610
*PropHeader /* Type: NXCPT_ACTION_SET */
620-
pad [4]uint8
621611
ActionSet []Action
622612
}
623613

@@ -772,7 +762,6 @@ const (
772762
type PacketIn2PropPacket struct {
773763
*PropHeader
774764
Packet protocol.Ethernet
775-
pad []uint8
776765
}
777766

778767
func (p *PacketIn2PropPacket) Len() (n uint16) {
@@ -908,7 +897,6 @@ func (p *PacketIn2PropBufferID) UnmarshalBinary(data []byte) error {
908897
type PacketIn2PropTableID struct {
909898
*PropHeader /* Type: NXPINT_TABLE_ID */
910899
TableID uint8
911-
pad [3]uint8
912900
}
913901

914902
func (p *PacketIn2PropTableID) Len() (n uint16) {
@@ -950,7 +938,6 @@ func (p *PacketIn2PropTableID) UnmarshalBinary(data []byte) error {
950938

951939
type PacketIn2PropCookie struct {
952940
*PropHeader /* Type: NXPINT_COOKIE */
953-
pad [4]uint8
954941
Cookie uint64
955942
}
956943

@@ -996,7 +983,6 @@ func (p *PacketIn2PropCookie) UnmarshalBinary(data []byte) error {
996983
type PacketIn2PropReason struct {
997984
*PropHeader /* Type: NXPINT_COOKIE */
998985
Reason uint8
999-
pad [3]uint8
1000986
}
1001987

1002988
func (p *PacketIn2PropReason) Len() (n uint16) {
@@ -1039,7 +1025,6 @@ func (p *PacketIn2PropReason) UnmarshalBinary(data []byte) error {
10391025
type PacketIn2PropMetadata struct {
10401026
*PropHeader /* Type: NXPINT_METADATA */
10411027
Fields []MatchField
1042-
pad []uint8
10431028
}
10441029

10451030
func (p *PacketIn2PropMetadata) Len() (n uint16) {
@@ -1104,7 +1089,6 @@ func (p *PacketIn2PropMetadata) UnmarshalBinary(data []byte) error {
11041089
type PacketIn2PropUserdata struct {
11051090
*PropHeader /* Type: NXPINT_USERDATA */
11061091
Userdata []uint8
1107-
pad []uint8
11081092
}
11091093

11101094
func (p *PacketIn2PropUserdata) Len() (n uint16) {
@@ -1149,7 +1133,6 @@ func (p *PacketIn2PropUserdata) UnmarshalBinary(data []byte) error {
11491133
type PacketIn2PropContinuation struct {
11501134
*PropHeader /* Type: NXPINT_CONTINUATION */
11511135
Continuation []byte
1152-
pad []uint8
11531136
}
11541137

11551138
func (p *PacketIn2PropContinuation) Len() (n uint16) {

0 commit comments

Comments
 (0)