mgmt/osdp: Fix coverity identified logical dead-code

A previous check and return for (maxlen <= 0) makes manlen at least 1 so
checks for (maxlen < 1) would never evaluate to true. Remove these
checks and merge those cases into one.

CID: 215392
Fixes: #33092
Signed-off-by: Siddharth Chandrasekaran <siddharth@embedjournal.com>
This commit is contained in:
Siddharth Chandrasekaran 2021-03-07 03:10:21 +01:00 committed by Anas Nashif
parent a871f00726
commit 28c823b16e

View file

@ -101,37 +101,14 @@ static int cp_build_command(struct osdp_pd *pd, uint8_t *buf, int max_len)
switch (pd->cmd_id) {
case CMD_POLL:
if (max_len < CMD_POLL_LEN) {
break;
}
buf[len++] = pd->cmd_id;
ret = 0;
break;
__fallthrough;
case CMD_LSTAT:
if (max_len < CMD_LSTAT_LEN) {
break;
}
buf[len++] = pd->cmd_id;
ret = 0;
break;
__fallthrough;
case CMD_ISTAT:
if (max_len < CMD_ISTAT_LEN) {
break;
}
buf[len++] = pd->cmd_id;
ret = 0;
break;
__fallthrough;
case CMD_OSTAT:
if (max_len < CMD_OSTAT_LEN) {
break;
}
buf[len++] = pd->cmd_id;
ret = 0;
break;
__fallthrough;
case CMD_RSTAT:
if (max_len < CMD_RSTAT_LEN) {
break;
}
buf[len++] = pd->cmd_id;
ret = 0;
break;