Skip to content

Commit

Permalink
Fix clan static code analysis issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sidcha committed Dec 15, 2019
1 parent 811f40c commit e1f482f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 34 deletions.
2 changes: 1 addition & 1 deletion osdpctl/arg_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ int ap_parse(int argc, char *argv[], struct ap_option *ap_opts, void *data)
opt->val = 'q';
opt = opts + i + 2;
opt->val = 'f';
olen += snprintf(ostr + olen, 128 - olen, "hqf");
snprintf(ostr + olen, 128 - olen, "hqf");

while ((c = getopt_long(argc, argv, ostr, opts, &opt_idx)) >= 0) {

Expand Down
2 changes: 2 additions & 0 deletions osdpctl/channel_msgq.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ int channel_msgq_setup(void **data, struct config_pd_s *c)
if (ctx->send_msgid < 0) {
printf("Error: failed to create send message queue %s\n",
c->channel_device);
free(ctx);
return -1;
}

Expand All @@ -98,6 +99,7 @@ int channel_msgq_setup(void **data, struct config_pd_s *c)
if (ctx->recv_msgid < 0) {
printf("Error: failed to create recv message queue %s\n",
c->channel_device);
free(ctx);
return -1;
}
*data = (void *)ctx;
Expand Down
2 changes: 2 additions & 0 deletions osdpctl/channel_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ int channel_uart_setup(void **data, struct config_pd_s *c)
if (ctx->port_id < 0) {
printf("Error: invalid uart device %s\n",
c->channel_device);
free(ctx);
return -1;
}
if (RS232_OpenComport(ctx->port_id, c->channel_speed, "8N1", 0)) {
printf("Error: failed to open device %s\n",
c->channel_device);
free(ctx);
return -1;
}
*data = (void *)ctx;
Expand Down
2 changes: 1 addition & 1 deletion osdpctl/cmd_start.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ int cmd_handler_start(int argc, char *argv[], void *data)
info->baud_rate = pd->channel_speed;
if (channel_setup(pd)) {
printf("Failed to setup channel\n");
return -1;
exit (-1);
}
if (pd->channel.flush)
pd->channel.flush(pd->channel.data);
Expand Down
31 changes: 0 additions & 31 deletions osdpctl/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,34 +347,6 @@ const char *cap_names[CAP_SENTINEL] = {
[CAP_BIOMETRICS] = "biometrics"
};

int config_key_parse_cap(const char *key, const char *val, void *data)
{
char *token;
int i, j, len, ival[2];
struct config_pd_s *p = data;

for (i = 1; i < CAP_SENTINEL; i++) {
len = strlen(cap_names[i]);
if (strncmp(key, cap_names[i], len) == 0)
break;
}

if (i >= CAP_SENTINEL)
return INI_FAILURE;

j = 0;
token = strtok((char *)val, ",");
while (token != NULL) {
if (safe_atoi(token, &ival[j++]))
return INI_FAILURE;
token = strtok(NULL, ",");
}
p->cap[i].num_items = (uint8_t)ival[0];
p->cap[i].compliance_level = (uint8_t)ival[1];

return INI_SUCCESS;
}

int config_key_parse(const char *key, const char *val,
const struct config_key_s *p, void *data)
{
Expand Down Expand Up @@ -408,9 +380,6 @@ int config_ini_cb(void* data, const char *sec, const char *key, const char *val)
return INI_FAILURE;
pd = p->pd + id;

if (strncmp("cap.", key, 4) == 0)
return config_key_parse_cap(key + 4, val, (void *)pd);

return config_key_parse(key, val, g_config_key_pd, (void *)pd);
}

Expand Down
5 changes: 4 additions & 1 deletion src/osdp_pd.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ int pd_decode_command(struct osdp_pd *p, struct osdp_data *reply, uint8_t * buf,
union osdp_cmd cmd;

reply->id = 0;
reply->len = 0;
p->cmd_id = buf[pos++];
len--;

Expand Down Expand Up @@ -159,6 +160,7 @@ int pd_decode_command(struct osdp_pd *p, struct osdp_data *reply, uint8_t * buf,
*/
if (isset_flag(p, PD_FLAG_SC_ACTIVE) == 0) {
reply->id = REPLY_NAK;
reply->len = 1;
reply->data[0] = OSDP_PD_NAK_SC_COND;
LOG_E(TAG "Keyset with SC inactive");
break;
Expand All @@ -182,6 +184,7 @@ int pd_decode_command(struct osdp_pd *p, struct osdp_data *reply, uint8_t * buf,
case CMD_CHLNG:
if (p->cap[CAP_COMMUNICATION_SECURITY].compliance_level == 0) {
reply->id = REPLY_NAK;
reply->len = 1;
reply->data[0] = OSDP_PD_NAK_SC_UNSUP;
break;
}
Expand All @@ -208,6 +211,7 @@ int pd_decode_command(struct osdp_pd *p, struct osdp_data *reply, uint8_t * buf,

if (ret != 0 && reply->id == 0) {
reply->id = REPLY_NAK;
reply->len = 1;
reply->data[0] = OSDP_PD_NAK_RECORD;
}
p->reply_id = reply->id;
Expand Down Expand Up @@ -446,7 +450,6 @@ int pd_phy_state_update(struct osdp_pd *pd)
pd->phy_state = PD_PHY_STATE_ERR;
break;
}
ret = 1;
pd->phy_state = PD_PHY_STATE_SEND_REPLY;
/* FALLTHRU */
case PD_PHY_STATE_SEND_REPLY:
Expand Down

0 comments on commit e1f482f

Please sign in to comment.