Incorrect array_size test.

ARRAY_SIZE(...) will return `3` for this array with members from 0 to 2,
therefore arr[3] is out of bounds. The array length test is off by one
and needs fixing.

Signed-off-by: Auke Kok <auke.kok@versity.com>
This commit is contained in:
Auke Kok
2025-03-05 14:22:37 -08:00
parent 33f6e9d0cd
commit 4a9760afe0

View File

@@ -1062,7 +1062,7 @@ static char *role_str(int role)
[LEADER] = "leader", [LEADER] = "leader",
}; };
if (role < 0 || role > ARRAY_SIZE(roles) || !roles[role]) if (role < 0 || role >= ARRAY_SIZE(roles) || !roles[role])
return "invalid"; return "invalid";
return roles[role]; return roles[role];