Code cleanup of res_smdi

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@74705 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Joshua Colp
2007-07-11 20:57:25 +00:00
parent 1040d3f64b
commit 21e30f9d7d

View File

@@ -94,8 +94,7 @@ int ast_smdi_mwi_set(struct ast_smdi_interface *iface, const char *mailbox)
FILE *file;
int i;
file = fopen(iface->name, "w");
if(!file) {
if (!(file = fopen(iface->name, "w"))) {
ast_log(LOG_ERROR, "Error opening SMDI interface %s (%s) for writing\n", iface->name, strerror(errno));
return 1;
}
@@ -104,7 +103,7 @@ int ast_smdi_mwi_set(struct ast_smdi_interface *iface, const char *mailbox)
fprintf(file, "OP:MWI ");
for(i = 0; i < iface->msdstrip; i++)
for (i = 0; i < iface->msdstrip; i++)
fprintf(file, "0");
fprintf(file, "%s!\x04", mailbox);
@@ -125,8 +124,7 @@ int ast_smdi_mwi_unset(struct ast_smdi_interface *iface, const char *mailbox)
FILE *file;
int i;
file = fopen(iface->name, "w");
if(!file) {
if (!(file = fopen(iface->name, "w"))) {
ast_log(LOG_ERROR, "Error opening SMDI interface %s (%s) for writing\n", iface->name, strerror(errno));
return 1;
}
@@ -135,7 +133,7 @@ int ast_smdi_mwi_unset(struct ast_smdi_interface *iface, const char *mailbox)
fprintf(file, "RMV:MWI ");
for(i = 0; i < iface->msdstrip; i++)
for (i = 0; i < iface->msdstrip; i++)
fprintf(file, "0");
fprintf(file, "%s!\x04", mailbox);
@@ -225,11 +223,10 @@ struct ast_smdi_md_message *ast_smdi_md_message_pop(struct ast_smdi_interface *i
*/
extern struct ast_smdi_md_message *ast_smdi_md_message_wait(struct ast_smdi_interface *iface, int timeout)
{
struct timeval start;
struct timeval start = ast_tvnow();
long diff = 0;
struct ast_smdi_md_message *msg;
start = ast_tvnow();
while (diff < timeout) {
if ((msg = ast_smdi_md_message_pop(iface)))
@@ -255,11 +252,10 @@ extern struct ast_smdi_md_message *ast_smdi_md_message_wait(struct ast_smdi_inte
extern struct ast_smdi_mwi_message *ast_smdi_mwi_message_pop(struct ast_smdi_interface *iface)
{
struct ast_smdi_mwi_message *mwi_msg = ASTOBJ_CONTAINER_UNLINK_START(&iface->mwi_q);
struct timeval now;
struct timeval now = ast_tvnow();
long elapsed = 0;
/* purge old messages */
now = ast_tvnow();
while (mwi_msg) {
elapsed = ast_tvdiff_ms(now, mwi_msg->timestamp);
@@ -293,11 +289,10 @@ extern struct ast_smdi_mwi_message *ast_smdi_mwi_message_pop(struct ast_smdi_int
*/
extern struct ast_smdi_mwi_message *ast_smdi_mwi_message_wait(struct ast_smdi_interface *iface, int timeout)
{
struct timeval start;
struct timeval start = ast_tvnow();
long diff = 0;
struct ast_smdi_mwi_message *msg;
start = ast_tvnow();
while (diff < timeout) {
if ((msg = ast_smdi_mwi_message_pop(iface)))
@@ -529,9 +524,7 @@ static int smdi_load(int reload)
int msdstrip = 0; /* strip zero digits */
long msg_expiry = SMDI_MSG_EXPIRY_TIME;
conf = ast_config_load(config_file);
if (!conf) {
if (!(conf = ast_config_load(config_file))) {
if (reload)
ast_log(LOG_NOTICE, "Unable to reload config %s: SMDI untouched\n", config_file);
else