File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -85,23 +85,26 @@ func parseRdmaKV(raw string, entry *v1.RdmaEntry) {
8585 var value uint64
8686 var err error
8787
88- parts := strings .Split (raw , "=" )
89- switch len (parts ) {
90- case 2 :
91- if parts [1 ] == "max" {
92- value = math .MaxUint32
93- } else {
94- value , err = parseUint (parts [1 ], 10 , 32 )
95- if err != nil {
96- return
97- }
98- }
99- if parts [0 ] == "hca_handle" {
100- entry .HcaHandles = uint32 (value )
101- } else if parts [0 ] == "hca_object" {
102- entry .HcaObjects = uint32 (value )
88+ k , v , found := strings .Cut (raw , "=" )
89+ if ! found {
90+ return
91+ }
92+
93+ if v == "max" {
94+ value = math .MaxUint32
95+ } else {
96+ value , err = parseUint (v , 10 , 32 )
97+ if err != nil {
98+ return
10399 }
104100 }
101+
102+ switch k {
103+ case "hca_handle" :
104+ entry .HcaHandles = uint32 (value )
105+ case "hca_object" :
106+ entry .HcaObjects = uint32 (value )
107+ }
105108}
106109
107110func toRdmaEntry (strEntries []string ) []* v1.RdmaEntry {
Original file line number Diff line number Diff line change @@ -387,23 +387,26 @@ func parseRdmaKV(raw string, entry *stats.RdmaEntry) {
387387 var value uint64
388388 var err error
389389
390- parts := strings .Split (raw , "=" )
391- switch len (parts ) {
392- case 2 :
393- if parts [1 ] == "max" {
394- value = math .MaxUint32
395- } else {
396- value , err = parseUint (parts [1 ], 10 , 32 )
397- if err != nil {
398- return
399- }
400- }
401- if parts [0 ] == "hca_handle" {
402- entry .HcaHandles = uint32 (value )
403- } else if parts [0 ] == "hca_object" {
404- entry .HcaObjects = uint32 (value )
390+ k , v , found := strings .Cut (raw , "=" )
391+ if ! found {
392+ return
393+ }
394+
395+ if v == "max" {
396+ value = math .MaxUint32
397+ } else {
398+ value , err = parseUint (v , 10 , 32 )
399+ if err != nil {
400+ return
405401 }
406402 }
403+
404+ switch k {
405+ case "hca_handle" :
406+ entry .HcaHandles = uint32 (value )
407+ case "hca_object" :
408+ entry .HcaObjects = uint32 (value )
409+ }
407410}
408411
409412func toRdmaEntry (strEntries []string ) []* stats.RdmaEntry {
You can’t perform that action at this time.
0 commit comments