Cleaned up CLI 'resource' implementation. (#9271)

Cleaned up CLI 'resource' implementation.
This commit is contained in:
Michael Keller 2019-12-10 01:47:45 +13:00 committed by GitHub
commit 692765ade9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 5 deletions

View File

@ -5850,9 +5850,8 @@ static void cliResource(char *cmdline)
return;
}
uint8_t resourceIndex = 0;
int index = 0;
for (resourceIndex = 0; ; resourceIndex++) {
unsigned resourceIndex = 0;
for (; ; resourceIndex++) {
if (resourceIndex >= ARRAYLEN(resourceTable)) {
cliPrintErrorLinef("INVALID RESOURCE NAME: '%s'", pch);
return;
@ -5865,7 +5864,7 @@ static void cliResource(char *cmdline)
}
pch = strtok_r(NULL, " ", &saveptr);
index = atoi(pch);
int index = atoi(pch);
if (resourceTable[resourceIndex].maxIndex > 0 || index > 0) {
if (index <= 0 || index > MAX_RESOURCE_INDEX(resourceTable[resourceIndex].maxIndex)) {