Skip to content

Commit 1fc5543

Browse files
author
Franck Rupin
committed
Fix invalid static checks
- Many source files are not compiant with staticcheck reports - This commit make the code compliant to the static check and linter - Some of the lines were commented only when they implement an ovs feature which is not used yet, otherwise it is removed. Fix formating
1 parent a900730 commit 1fc5543

File tree

6 files changed

+45
-53
lines changed

6 files changed

+45
-53
lines changed

ovs/flow.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ var (
3434
errInvalidActions = errors.New("invalid actions for Flow")
3535
errNoActions = errors.New("no actions defined for Flow")
3636
errNotEnoughElements = errors.New("not enough elements for valid Flow")
37-
errPriorityNotFirst = errors.New("priority field is not first in Flow")
3837
errInvalidLearnedActions = errors.New("invalid actions for LearnedFlow")
3938
)
4039

@@ -216,9 +215,9 @@ func (f *LearnedFlow) MarshalText() ([]byte, error) {
216215

217216
// A learned flow can have a limited set of actions, namely `load` and `output:field`.
218217
for _, a := range f.Actions {
219-
switch a.(type) {
218+
switch a := a.(type) {
220219
case *loadSetFieldAction:
221-
if a.(*loadSetFieldAction).typ != actionLoad {
220+
if a.typ != actionLoad {
222221
return nil, errInvalidLearnedActions
223222
}
224223
case *outputFieldAction:

ovs/match.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ import (
2626
const (
2727
source = "src"
2828
destination = "dst"
29-
30-
sourceHardwareAddr = "sha"
31-
targetHardwareAddr = "tha"
32-
sourceProtocolAddr = "spa"
33-
targetProtocolAddr = "tpa"
3429
)
3530

3631
// Constants of full Match names.

ovs/openflow.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ var (
309309

310310
// dumpAggregatePrefix is a sentinel value returned at the beginning of
311311
// the output from "ovs-ofctl dump-aggregate"
312-
dumpAggregatePrefix = []byte("NXST_AGGREGATE reply")
312+
//dumpAggregatePrefix = []byte("NXST_AGGREGATE reply")
313313
)
314314

315315
// dumpPorts calls 'ovs-ofctl dump-ports' with the specified arguments and

ovs/proto_trace.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ var (
4141
ctResumeFromRegexp = regexp.MustCompile(`Resuming from table`)
4242
ctResumeWithRegexp = regexp.MustCompile(`resume conntrack with`)
4343
tunNative = regexp.MustCompile(`native tunnel`)
44-
45-
pushVLANPattern = `push_vlan(vid=[0-9]+,pcp=[0-9]+)`
4644
)
4745

4846
const (

ovsnl/internal/ovsh/const.go

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ const (
119119
)
120120

121121
// ovsDatapathCmd as declared in ovsh/openvswitch.h:54
122-
type ovsDatapathCmd int32
122+
//type ovsDatapathCmd int32
123123

124124
// ovsDatapathCmd enumeration from ovsh/openvswitch.h:54
125125
const (
@@ -131,7 +131,7 @@ const (
131131
)
132132

133133
// ovsDatapathAttr as declared in ovsh/openvswitch.h:81
134-
type ovsDatapathAttr int32
134+
//type ovsDatapathAttr int32
135135

136136
// ovsDatapathAttr enumeration from ovsh/openvswitch.h:81
137137
const (
@@ -146,7 +146,7 @@ const (
146146
)
147147

148148
// ovsPacketCmd as declared in ovsh/openvswitch.h:134
149-
type ovsPacketCmd int32
149+
//type ovsPacketCmd int32
150150

151151
// ovsPacketCmd enumeration from ovsh/openvswitch.h:134
152152
const (
@@ -157,7 +157,7 @@ const (
157157
)
158158

159159
// ovsPacketAttr as declared in ovsh/openvswitch.h:177
160-
type ovsPacketAttr int32
160+
//type ovsPacketAttr int32
161161

162162
// ovsPacketAttr enumeration from ovsh/openvswitch.h:177
163163
const (
@@ -176,7 +176,7 @@ const (
176176
)
177177

178178
// ovsVportCmd as declared in ovsh/openvswitch.h:202
179-
type ovsVportCmd int32
179+
//type ovsVportCmd int32
180180

181181
// ovsVportCmd enumeration from ovsh/openvswitch.h:202
182182
const (
@@ -188,7 +188,7 @@ const (
188188
)
189189

190190
// ovsVportType as declared in ovsh/openvswitch.h:210
191-
type ovsVportType int32
191+
//type ovsVportType int32
192192

193193
// ovsVportType enumeration from ovsh/openvswitch.h:210
194194
const (
@@ -202,7 +202,7 @@ const (
202202
)
203203

204204
// ovsVportAttr as declared in ovsh/openvswitch.h:251
205-
type ovsVportAttr int32
205+
//type ovsVportAttr int32
206206

207207
// ovsVportAttr enumeration from ovsh/openvswitch.h:251
208208
const (
@@ -240,7 +240,7 @@ const (
240240
)
241241

242242
// ovsFlowCmd as declared in ovsh/openvswitch.h:294
243-
type ovsFlowCmd int32
243+
//type ovsFlowCmd int32
244244

245245
// ovsFlowCmd enumeration from ovsh/openvswitch.h:294
246246
const (
@@ -252,7 +252,7 @@ const (
252252
)
253253

254254
// ovsKeyAttr as declared in ovsh/openvswitch.h:307
255-
type ovsKeyAttr int32
255+
//type ovsKeyAttr int32
256256

257257
// ovsKeyAttr enumeration from ovsh/openvswitch.h:307
258258
const (
@@ -289,7 +289,7 @@ const (
289289
)
290290

291291
// ovsTunnelKeyAttr as declared in ovsh/openvswitch.h:349
292-
type ovsTunnelKeyAttr int32
292+
//type ovsTunnelKeyAttr int32
293293

294294
// ovsTunnelKeyAttr enumeration from ovsh/openvswitch.h:349
295295
const (
@@ -313,7 +313,7 @@ const (
313313
)
314314

315315
// ovsFragType as declared in ovsh/openvswitch.h:381
316-
type ovsFragType int32
316+
//type ovsFragType int32
317317

318318
// ovsFragType enumeration from ovsh/openvswitch.h:381
319319
const (
@@ -324,7 +324,7 @@ const (
324324
)
325325

326326
// ovsNshKeyAttr as declared in ovsh/openvswitch.h:499
327-
type ovsNshKeyAttr int32
327+
//type ovsNshKeyAttr int32
328328

329329
// ovsNshKeyAttr enumeration from ovsh/openvswitch.h:499
330330
const (
@@ -336,7 +336,7 @@ const (
336336
)
337337

338338
// ovsFlowAttr as declared in ovsh/openvswitch.h:565
339-
type ovsFlowAttr int32
339+
//type ovsFlowAttr int32
340340

341341
// ovsFlowAttr enumeration from ovsh/openvswitch.h:565
342342
const (
@@ -356,7 +356,7 @@ const (
356356
)
357357

358358
// ovsSampleAttr as declared in ovsh/openvswitch.h:606
359-
type ovsSampleAttr int32
359+
//type ovsSampleAttr int32
360360

361361
// ovsSampleAttr enumeration from ovsh/openvswitch.h:606
362362
const (
@@ -367,7 +367,7 @@ const (
367367
)
368368

369369
// ovsUserspaceAttr as declared in ovsh/openvswitch.h:640
370-
type ovsUserspaceAttr int32
370+
//type ovsUserspaceAttr int32
371371

372372
// ovsUserspaceAttr enumeration from ovsh/openvswitch.h:640
373373
const (
@@ -380,15 +380,15 @@ const (
380380
)
381381

382382
// ovsHashAlg as declared in ovsh/openvswitch.h:692
383-
type ovsHashAlg int32
383+
//type ovsHashAlg int32
384384

385385
// ovsHashAlg enumeration from ovsh/openvswitch.h:692
386386
const (
387387
HashAlgL4 = iota
388388
)
389389

390390
// ovsCtAttr as declared in ovsh/openvswitch.h:738
391-
type ovsCtAttr int32
391+
//type ovsCtAttr int32
392392

393393
// ovsCtAttr enumeration from ovsh/openvswitch.h:738
394394
const (
@@ -405,7 +405,7 @@ const (
405405
)
406406

407407
// ovsNatAttr as declared in ovsh/openvswitch.h:776
408-
type ovsNatAttr int32
408+
//type ovsNatAttr int32
409409

410410
// ovsNatAttr enumeration from ovsh/openvswitch.h:776
411411
const (
@@ -423,7 +423,7 @@ const (
423423
)
424424

425425
// ovsActionAttr as declared in ovsh/openvswitch.h:852
426-
type ovsActionAttr int32
426+
//type ovsActionAttr int32
427427

428428
// ovsActionAttr enumeration from ovsh/openvswitch.h:852
429429
const (
@@ -451,7 +451,7 @@ const (
451451
)
452452

453453
// ovsMeterCmd as declared in ovsh/openvswitch.h:894
454-
type ovsMeterCmd int32
454+
//type ovsMeterCmd int32
455455

456456
// ovsMeterCmd enumeration from ovsh/openvswitch.h:894
457457
const (
@@ -463,7 +463,7 @@ const (
463463
)
464464

465465
// ovsMeterAttr as declared in ovsh/openvswitch.h:902
466-
type ovsMeterAttr int32
466+
//type ovsMeterAttr int32
467467

468468
// ovsMeterAttr enumeration from ovsh/openvswitch.h:902
469469
const (
@@ -481,7 +481,7 @@ const (
481481
)
482482

483483
// ovsBandAttr as declared in ovsh/openvswitch.h:921
484-
type ovsBandAttr int32
484+
//type ovsBandAttr int32
485485

486486
// ovsBandAttr enumeration from ovsh/openvswitch.h:921
487487
const (
@@ -494,7 +494,7 @@ const (
494494
)
495495

496496
// ovsMeterBandType as declared in ovsh/openvswitch.h:932
497-
type ovsMeterBandType int32
497+
//type ovsMeterBandType int32
498498

499499
// ovsMeterBandType enumeration from ovsh/openvswitch.h:932
500500
const (

ovsnl/internal/ovsh/struct.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,32 +22,32 @@ type Header struct {
2222
}
2323

2424
type DPStats struct {
25-
Hit uint64
26-
Missed uint64
27-
Lost uint64
28-
Flows uint64
25+
Hit uint64
26+
Missed uint64
27+
Lost uint64
28+
Flows uint64
2929
}
3030

3131
type DPMegaflowStats struct {
32-
Mask_hit uint64
33-
Masks uint32
34-
Pad0 uint32
35-
Pad1 uint64
36-
Pad2 uint64
32+
Mask_hit uint64
33+
Masks uint32
34+
Pad0 uint32
35+
Pad1 uint64
36+
Pad2 uint64
3737
}
3838

3939
type VportStats struct {
40-
Rx_packets uint64
41-
Tx_packets uint64
42-
Rx_bytes uint64
43-
Tx_bytes uint64
44-
Rx_errors uint64
45-
Tx_errors uint64
46-
Rx_dropped uint64
47-
Tx_dropped uint64
40+
Rx_packets uint64
41+
Tx_packets uint64
42+
Rx_bytes uint64
43+
Tx_bytes uint64
44+
Rx_errors uint64
45+
Tx_errors uint64
46+
Rx_dropped uint64
47+
Tx_dropped uint64
4848
}
4949

5050
type FlowStats struct {
51-
Packets uint64
52-
Bytes uint64
51+
Packets uint64
52+
Bytes uint64
5353
}

0 commit comments

Comments
 (0)