Merge "coverity: Fix warnings in res_smdi" into 13

This commit is contained in:
Jenkins2
2017-12-15 10:50:16 -06:00
committed by Gerrit Code Review

View File

@@ -588,9 +588,8 @@ static void *smdi_read(void *iface_p)
struct ast_smdi_interface *iface = iface_p; struct ast_smdi_interface *iface = iface_p;
struct ast_smdi_md_message *md_msg; struct ast_smdi_md_message *md_msg;
struct ast_smdi_mwi_message *mwi_msg; struct ast_smdi_mwi_message *mwi_msg;
char c = '\0';
char *cp = NULL; char *cp = NULL;
int i; int i, c;
int start = 0; int start = 0;
/* read an smdi message */ /* read an smdi message */
@@ -618,7 +617,14 @@ static void *smdi_read(void *iface_p)
/* read the message desk number */ /* read the message desk number */
for (i = 0; i < sizeof(md_msg->mesg_desk_num) - 1; i++) { for (i = 0; i < sizeof(md_msg->mesg_desk_num) - 1; i++) {
md_msg->mesg_desk_num[i] = fgetc(iface->file); c = fgetc(iface->file);
if (c == EOF) {
ast_log(LOG_ERROR, "Unexpected EOF while reading MD message\n");
ao2_ref(md_msg, -1);
ao2_ref(iface, -1);
return NULL;
}
md_msg->mesg_desk_num[i] = (char) c;
ast_debug(1, "Read a '%c'\n", md_msg->mesg_desk_num[i]); ast_debug(1, "Read a '%c'\n", md_msg->mesg_desk_num[i]);
} }
@@ -628,7 +634,14 @@ static void *smdi_read(void *iface_p)
/* read the message desk terminal number */ /* read the message desk terminal number */
for (i = 0; i < sizeof(md_msg->mesg_desk_term) - 1; i++) { for (i = 0; i < sizeof(md_msg->mesg_desk_term) - 1; i++) {
md_msg->mesg_desk_term[i] = fgetc(iface->file); c = fgetc(iface->file);
if (c == EOF) {
ast_log(LOG_ERROR, "Unexpected EOF while reading SMDI message\n");
ao2_ref(md_msg, -1);
ao2_ref(iface, -1);
return NULL;
}
md_msg->mesg_desk_term[i] = (char) c;
ast_debug(1, "Read a '%c'\n", md_msg->mesg_desk_term[i]); ast_debug(1, "Read a '%c'\n", md_msg->mesg_desk_term[i]);
} }
@@ -637,7 +650,14 @@ static void *smdi_read(void *iface_p)
ast_debug(1, "The message desk terminal is '%s'\n", md_msg->mesg_desk_term); ast_debug(1, "The message desk terminal is '%s'\n", md_msg->mesg_desk_term);
/* read the message type */ /* read the message type */
md_msg->type = fgetc(iface->file); c = fgetc(iface->file);
if (c == EOF) {
ast_log(LOG_ERROR, "Unexpected EOF while reading SMDI message\n");
ao2_ref(md_msg, -1);
ao2_ref(iface, -1);
return NULL;
}
md_msg->type = (char) c;
ast_debug(1, "Message type is '%c'\n", md_msg->type); ast_debug(1, "Message type is '%c'\n", md_msg->type);
@@ -742,8 +762,16 @@ static void *smdi_read(void *iface_p)
ast_copy_string(mwi_msg->name, mwi_msg->fwd_st, sizeof(mwi_msg->name)); ast_copy_string(mwi_msg->name, mwi_msg->fwd_st, sizeof(mwi_msg->name));
/* read the mwi failure cause */ /* read the mwi failure cause */
for (i = 0; i < sizeof(mwi_msg->cause) - 1; i++) for (i = 0; i < sizeof(mwi_msg->cause) - 1; i++) {
mwi_msg->cause[i] = fgetc(iface->file); c = fgetc(iface->file);
if (c == EOF) {
ast_log(LOG_ERROR, "Unexpected EOF while reading MWI message\n");
ao2_ref(mwi_msg, -1);
ao2_ref(iface, -1);
return NULL;
}
mwi_msg->cause[i] = (char) c;
}
mwi_msg->cause[sizeof(mwi_msg->cause) - 1] = '\0'; mwi_msg->cause[sizeof(mwi_msg->cause) - 1] = '\0';