Skip to content

Commit bee9821

Browse files
committed
fix gocritic lint issues
Signed-off-by: Tariq Ibrahim <[email protected]>
1 parent 41955a0 commit bee9821

File tree

5 files changed

+13
-10
lines changed

5 files changed

+13
-10
lines changed

.golangci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ linters:
33
enable:
44
- asciicheck
55
- contextcheck
6+
- gocritic
67
- godot
78
- gofmt
89
- goimports
910
- misspell
1011
# TODO: re-enable once we have addressed the warnings
1112
disable:
1213
- unused
13-
- gocritic
1414
- stylecheck
1515
- forcetypeassert
1616

pkg/nvlib/device/device.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func (d *device) GetBrandAsString() (string, error) {
125125
case nvml.BRAND_NVIDIA_VWS:
126126
return "NvidiaVWS", nil
127127
// Deprecated in favor of nvml.BRAND_NVIDIA_CLOUD_GAMING
128-
//case nvml.BRAND_NVIDIA_VGAMING:
128+
// case nvml.BRAND_NVIDIA_VGAMING:
129129
// return "VGaming", nil
130130
case nvml.BRAND_NVIDIA_CLOUD_GAMING:
131131
return "NvidiaCloudGaming", nil

pkg/nvpci/nvpci.go

+3
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ func (p *nvpci) getGPUByPciBusID(address string, cache map[string]*NvidiaPCIDevi
281281
}
282282

283283
driver, err := filepath.EvalSymlinks(path.Join(devicePath, "driver"))
284+
// nolint:gocritic
284285
if err == nil {
285286
driver = filepath.Base(driver)
286287
} else if os.IsNotExist(err) {
@@ -291,6 +292,7 @@ func (p *nvpci) getGPUByPciBusID(address string, cache map[string]*NvidiaPCIDevi
291292

292293
var iommuGroup int64
293294
iommu, err := filepath.EvalSymlinks(path.Join(devicePath, "iommu_group"))
295+
// nolint:gocritic
294296
if err == nil {
295297
iommuGroupStr := strings.TrimSpace(filepath.Base(iommu))
296298
iommuGroup, err = strconv.ParseInt(iommuGroupStr, 0, 64)
@@ -359,6 +361,7 @@ func (p *nvpci) getGPUByPciBusID(address string, cache map[string]*NvidiaPCIDevi
359361
var sriovInfo SriovInfo
360362
// Device is a virtual function (VF) if "physfn" symlink exists.
361363
physFnAddress, err := filepath.EvalSymlinks(path.Join(devicePath, "physfn"))
364+
// nolint:gocritic
362365
if err == nil {
363366
physFn, err := p.getGPUByPciBusID(filepath.Base(physFnAddress), cache)
364367
if err != nil {

pkg/nvpci/resources.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func (mrs MemoryResources) GetTotalAddressableMemory(roundUp bool) (uint64, uint
112112
if key >= pciIOVNumBAR || numBAR == pciIOVNumBAR {
113113
break
114114
}
115-
numBAR = numBAR + 1
115+
numBAR++
116116

117117
region := mrs[key]
118118

@@ -123,10 +123,10 @@ func (mrs MemoryResources) GetTotalAddressableMemory(roundUp bool) (uint64, uint
123123
memSize := (region.End - region.Start) + 1
124124

125125
if memType32bit {
126-
memSize32bit = memSize32bit + uint64(memSize)
126+
memSize32bit += uint64(memSize)
127127
}
128128
if memType64bit {
129-
memSize64bit = memSize64bit + uint64(memSize)
129+
memSize64bit += uint64(memSize)
130130
}
131131

132132
}

pkg/pciids/pciids.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ func (p *parser) parse() Interface {
396396
hkClass = db.classes[uint32(id)]
397397

398398
hkFullID = uint32(id) << 16
399-
hkFullID = hkFullID & 0xFFFF0000
399+
hkFullID &= 0xFFFF0000
400400
hkFullName[0] = fmt.Sprintf("%s (%02x)", lit.name, id)
401401
}
402402

@@ -408,11 +408,11 @@ func (p *parser) parse() Interface {
408408
}
409409
hkSubClass = hkClass.subClasses[uint32(id)]
410410

411-
// Clear the last detected sub class.
412-
hkFullID = hkFullID & 0xFFFF0000
413-
hkFullID = hkFullID | uint32(id)<<8
411+
// Clear the last detected subclass.
412+
hkFullID &= 0xFFFF0000
413+
hkFullID |= uint32(id) << 8
414414
// Clear the last detected prog iface.
415-
hkFullID = hkFullID & 0xFFFFFF00
415+
hkFullID &= 0xFFFFFF00
416416
hkFullName[1] = fmt.Sprintf("%s (%02x)", lit.name, id)
417417

418418
db.classes[uint32(hkFullID)] = class{

0 commit comments

Comments
 (0)