Commit fbedf62f authored by Matthew Halpern's avatar Matthew Halpern Committed by Viktor Trón

swarm/storage: fix loop bound for database cleanup (#19085)

The current loop continuation condition is always true as a uint8
is always being checked whether it is less than 255 (its maximum
value). Since the loop starts with the value 1, the loop termination
can be guarranteed to exit once the value overflows to 0.
parent 9d5e10f5
...@@ -527,8 +527,8 @@ func (s *LDBStore) Cleanup(f func(*chunk) bool) { ...@@ -527,8 +527,8 @@ func (s *LDBStore) Cleanup(f func(*chunk) bool) {
if err != nil { if err != nil {
found := false found := false
// highest possible proximity is 255 // The highest possible proximity is 255, so exit loop upon overflow.
for po = 1; po <= 255; po++ { for po = uint8(1); po != 0; po++ {
datakey = getDataKey(index.Idx, po) datakey = getDataKey(index.Idx, po)
data, err = s.db.Get(datakey) data, err = s.db.Get(datakey)
if err == nil { if err == nil {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment