Skip to content

Commit 964b489

Browse files
Fix for integer overflow of counter value if its too large (sonic-net#3596)
What I did Changed the data type casting to float if count coming is too large or in scientific notation . How I did it made it float then type cast to int for display purpose How to verify it Manually passed big value and see the count output if it breaks or works
1 parent 3354d08 commit 964b489

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

utilities_common/portstat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def get_counters(port):
229229
if counter_name not in fvs:
230230
fields[pos] = STATUS_NA
231231
elif fields[pos] != STATUS_NA:
232-
fields[pos] = str(int(fields[pos]) + int(fvs[counter_name]))
232+
fields[pos] = str(int(fields[pos]) + int(float(fvs[counter_name])))
233233

234234
cntr = NStats._make(fields)._asdict()
235235
return cntr

0 commit comments

Comments
 (0)