minor readability fixes in preparation for more work on this file:

- replace nested 'if' with '&&'
- fix indentation
- annotate the end brace of some huge block
- remove useless parentheses



git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@20597 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Luigi Rizzo 2006-04-16 18:37:01 +00:00
parent bdfa578990
commit 81ed862e67

View file

@ -294,10 +294,7 @@ int ast_park_call(struct ast_channel *chan, struct ast_channel *peer, int timeou
} }
pu->start = ast_tvnow(); pu->start = ast_tvnow();
pu->parkingnum = x; pu->parkingnum = x;
if (timeout > 0) pu->parkingtime = (timeout > 0) ? timeout : parkingtime;
pu->parkingtime = timeout;
else
pu->parkingtime = parkingtime;
if (extout) if (extout)
*extout = x; *extout = x;
if (peer) if (peer)
@ -425,13 +422,11 @@ static int builtin_automonitor(struct ast_channel *chan, struct ast_channel *pee
return -1; return -1;
} }
if (!monitor_app) { if (!monitor_app && !(monitor_app = pbx_findapp("Monitor"))) {
if (!(monitor_app = pbx_findapp("Monitor"))) {
monitor_ok=0; monitor_ok=0;
ast_log(LOG_ERROR,"Cannot record the call. The monitor application is disabled.\n"); ast_log(LOG_ERROR,"Cannot record the call. The monitor application is disabled.\n");
return -1; return -1;
} }
}
if (!ast_strlen_zero(courtesytone)) { if (!ast_strlen_zero(courtesytone)) {
if (ast_autoservice_start(callee_chan)) if (ast_autoservice_start(callee_chan))
return -1; return -1;
@ -848,7 +843,8 @@ void ast_register_feature(struct ast_call_feature *feature)
/*! \brief unregister feature from feature_list */ /*! \brief unregister feature from feature_list */
void ast_unregister_feature(struct ast_call_feature *feature) void ast_unregister_feature(struct ast_call_feature *feature)
{ {
if (!feature) return; if (!feature)
return;
AST_LIST_LOCK(&feature_list); AST_LIST_LOCK(&feature_list);
AST_LIST_REMOVE(&feature_list,feature,feature_entry); AST_LIST_REMOVE(&feature_list,feature,feature_entry);
@ -902,9 +898,7 @@ static int feature_exec_app(struct ast_channel *chan, struct ast_channel *peer,
app = pbx_findapp(feature->app); app = pbx_findapp(feature->app);
if (app) { if (app) {
struct ast_channel *work = chan; struct ast_channel *work = ast_test_flag(feature,AST_FEATURE_FLAG_CALLEE) ? peer : chan;
if (ast_test_flag(feature, AST_FEATURE_FLAG_CALLEE))
work = peer;
res = pbx_exec(work, app, feature->app_args); res = pbx_exec(work, app, feature->app_args);
if (res < 0) if (res < 0)
return res; return res;
@ -913,7 +907,7 @@ static int feature_exec_app(struct ast_channel *chan, struct ast_channel *peer,
return -2; return -2;
} }
return FEATURE_RETURN_SUCCESS; return FEATURE_RETURN_SUCCESS; /* XXX should probably return res */
} }
static void unmap_features(void) static void unmap_features(void)
@ -1018,14 +1012,12 @@ static void set_config_flags(struct ast_channel *chan, struct ast_channel *peer,
char *tok; char *tok;
struct ast_call_feature *feature; struct ast_call_feature *feature;
if (!tmp) { if (!tmp) /* no memory */
return; return;
}
/* while we have a feature */ /* while we have a feature */
while (NULL != (tok = strsep(&tmp, "#"))) { while (NULL != (tok = strsep(&tmp, "#"))) {
if ((feature = find_feature(tok))) { if ((feature = find_feature(tok)) && ast_test_flag(feature, AST_FEATURE_FLAG_NEEDSDTMF)) {
if (ast_test_flag(feature, AST_FEATURE_FLAG_NEEDSDTMF)) {
if (ast_test_flag(feature, AST_FEATURE_FLAG_CALLER)) if (ast_test_flag(feature, AST_FEATURE_FLAG_CALLER))
ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_0); ast_set_flag(config, AST_BRIDGE_DTMF_CHANNEL_0);
if (ast_test_flag(feature, AST_FEATURE_FLAG_CALLEE)) if (ast_test_flag(feature, AST_FEATURE_FLAG_CALLEE))
@ -1035,9 +1027,8 @@ static void set_config_flags(struct ast_channel *chan, struct ast_channel *peer,
} }
} }
} }
}
/* XXX this is very similar to the code in channel.c */
static struct ast_channel *ast_feature_request_and_dial(struct ast_channel *caller, const char *type, int format, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name) static struct ast_channel *ast_feature_request_and_dial(struct ast_channel *caller, const char *type, int format, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name)
{ {
int state = 0; int state = 0;
@ -1340,8 +1331,9 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast
return -1; return -1;
} }
if (!f || ((f->frametype == AST_FRAME_CONTROL) && ((f->subclass == AST_CONTROL_HANGUP) || (f->subclass == AST_CONTROL_BUSY) || if (!f || (f->frametype == AST_FRAME_CONTROL &&
(f->subclass == AST_CONTROL_CONGESTION)))) { (f->subclass == AST_CONTROL_HANGUP || f->subclass == AST_CONTROL_BUSY ||
f->subclass == AST_CONTROL_CONGESTION ) ) ) {
res = -1; res = -1;
break; break;
} }
@ -1362,7 +1354,7 @@ int ast_bridge_call(struct ast_channel *chan,struct ast_channel *peer,struct ast
} }
} }
/* check for '*', if we find it it's time to disconnect */ /* check for '*', if we find it it's time to disconnect */
if (f && (f->frametype == AST_FRAME_DTMF)) { if (f && f->frametype == AST_FRAME_DTMF) {
char *featurecode; char *featurecode;
int sense; int sense;
@ -1576,7 +1568,7 @@ static void *do_parking_thread(void *ignore)
goto std; /* XXX Ick: jumping into an else statement??? XXX */ goto std; /* XXX Ick: jumping into an else statement??? XXX */
} }
} }
} } /* end for */
if (x >= AST_MAX_FDS) { if (x >= AST_MAX_FDS) {
std: for (x=0; x<AST_MAX_FDS; x++) { std: for (x=0; x<AST_MAX_FDS; x++) {
/* Keep this one for next one */ /* Keep this one for next one */
@ -1594,7 +1586,7 @@ std: for (x=0; x<AST_MAX_FDS; x++) {
pu = pu->next; pu = pu->next;
} }
} }
} } /* end while */
ast_mutex_unlock(&parking_lock); ast_mutex_unlock(&parking_lock);
rfds = nrfds; rfds = nrfds;
efds = nefds; efds = nefds;