static int pri_find_empty_chan(struct zt_pri *pri)
{
int x;
- for (x=pri->numchans;x>0;x--) {
+ for (x=pri->numchans;x>=0;x--) {
if (pri->pvts[x] && !pri->pvts[x]->owner)
return x;
}
span = PRI_SPAN(channel);
channel = PRI_CHANNEL(channel);
- for (x=1;x<pri->numchans;x++) {
+ for (x=0;x<pri->numchans;x++) {
if (pri->pvts[x] && (pri->pvts[x]->prioffset == channel) && (pri->logicalspan == span)) {
principle = x;
break;
(pri->pvts[principle]) &&
(pri->pvts[principle]->call == c))
return principle;
- for (x=1;x<pri->numchans;x++) {
+ for (x=0;x<pri->numchans;x++) {
if (!pri->pvts[x]) continue;
if (pri->pvts[x]->call == c) {
/* Found our call */
(activeidles > pri->minidle)) {
/* Mark something for hangup if there is something
that can be hungup */
- for (x=pri->numchans;x>0;x--) {
+ for (x=pri->numchans;x>=0;x--) {
/* find a candidate channel */
if (pri->pvts[x] && pri->pvts[x]->owner && pri->pvts[x]->isidlecall) {
pri->pvts[x]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
} else {
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_2 "Restart on requested on entire span %d\n", pri->span);
- for (x=1;x < pri->numchans;x++)
+ for (x=0;x < pri->numchans;x++)
if (pri->pvts[x]) {
ast_mutex_lock(&pri->pvts[x]->lock);
if (pri->pvts[x]->call) {
/* Sometime switches (e.g. I421 / British Telecom) don't give us the
channel number, so we have to figure it out... This must be why
everybody resets exactly a channel at a time. */
- for (x=1;x<pri->numchans;x++) {
+ for (x=0;x<pri->numchans;x++) {
if (pri->pvts[x] && pri->pvts[x]->resetting) {
chanpos = x;
ast_mutex_lock(&pri->pvts[chanpos]->lock);