[asterisk-commits] russell: trunk r104866 - /trunk/channels/chan_zap.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Feb 27 17:58:50 CST 2008
Author: russell
Date: Wed Feb 27 17:58:49 2008
New Revision: 104866
URL: http://svn.digium.com/view/asterisk?view=rev&rev=104866
Log:
reduce indentation in alloc_sub
(issue #12079)
Reported by: tzafrir
Patches:
alloc_sub uploaded by tzafrir (license 46)
Modified:
trunk/channels/chan_zap.c
Modified: trunk/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_zap.c?view=diff&rev=104866&r1=104865&r2=104866
==============================================================================
--- trunk/channels/chan_zap.c (original)
+++ trunk/channels/chan_zap.c Wed Feb 27 17:58:49 2008
@@ -1149,33 +1149,36 @@
ZT_BUFFERINFO bi;
int res;
if (p->subs[x].zfd < 0) {
- p->subs[x].zfd = zt_open("/dev/zap/pseudo");
- if (p->subs[x].zfd > -1) {
- res = ioctl(p->subs[x].zfd, ZT_GET_BUFINFO, &bi);
- if (!res) {
- bi.txbufpolicy = ZT_POLICY_IMMEDIATE;
- bi.rxbufpolicy = ZT_POLICY_IMMEDIATE;
- bi.numbufs = numbufs;
- res = ioctl(p->subs[x].zfd, ZT_SET_BUFINFO, &bi);
- if (res < 0) {
- ast_log(LOG_WARNING, "Unable to set buffer policy on channel %d\n", x);
- }
- } else
- ast_log(LOG_WARNING, "Unable to check buffer policy on channel %d\n", x);
- if (ioctl(p->subs[x].zfd, ZT_CHANNO, &p->subs[x].chan) == 1) {
- ast_log(LOG_WARNING, "Unable to get channel number for pseudo channel on FD %d\n", p->subs[x].zfd);
- zt_close(p->subs[x].zfd);
- p->subs[x].zfd = -1;
- return -1;
- }
- ast_debug(1, "Allocated %s subchannel on FD %d channel %d\n", subnames[x], p->subs[x].zfd, p->subs[x].chan);
- return 0;
- } else
- ast_log(LOG_WARNING, "Unable to open pseudo channel: %s\n", strerror(errno));
+ ast_log(LOG_WARNING, "%s subchannel of %d already in use\n", subnames[x], p->channel);
return -1;
}
- ast_log(LOG_WARNING, "%s subchannel of %d already in use\n", subnames[x], p->channel);
- return -1;
+
+ p->subs[x].zfd = zt_open("/dev/zap/pseudo");
+ if (p->subs[x].zfd <= -1) {
+ ast_log(LOG_WARNING, "Unable to open pseudo channel: %s\n", strerror(errno));
+ return -1;
+ }
+
+ res = ioctl(p->subs[x].zfd, ZT_GET_BUFINFO, &bi);
+ if (!res) {
+ bi.txbufpolicy = ZT_POLICY_IMMEDIATE;
+ bi.rxbufpolicy = ZT_POLICY_IMMEDIATE;
+ bi.numbufs = numbufs;
+ res = ioctl(p->subs[x].zfd, ZT_SET_BUFINFO, &bi);
+ if (res < 0) {
+ ast_log(LOG_WARNING, "Unable to set buffer policy on channel %d\n", x);
+ }
+ } else
+ ast_log(LOG_WARNING, "Unable to check buffer policy on channel %d\n", x);
+
+ if (ioctl(p->subs[x].zfd, ZT_CHANNO, &p->subs[x].chan) == 1) {
+ ast_log(LOG_WARNING, "Unable to get channel number for pseudo channel on FD %d\n", p->subs[x].zfd);
+ zt_close(p->subs[x].zfd);
+ p->subs[x].zfd = -1;
+ return -1;
+ }
+ ast_debug(1, "Allocated %s subchannel on FD %d channel %d\n", subnames[x], p->subs[x].zfd, p->subs[x].chan);
+ return 0;
}
static int unalloc_sub(struct zt_pvt *p, int x)
More information about the asterisk-commits
mailing list