[Asterisk-code-review] sched.c: Make not return a sched id of 0. (asterisk[13])

Joshua Colp asteriskteam at digium.com
Thu Dec 3 05:50:43 CST 2015


Joshua Colp has submitted this change and it was merged.

Change subject: sched.c: Make not return a sched id of 0.
......................................................................


sched.c: Make not return a sched id of 0.

According to the API doxygen a sched ID of 0 is valid.  Unfortunately, 0
was never returned historically and several users incorrectly coded usage
of the returned sched ID assuming that 0 was invalid.

ASTERISK-25476

Change-Id: Ib19c7ebb44ec9fd393ef6646dea806d4f34e3a20
---
M main/sched.c
1 file changed, 9 insertions(+), 2 deletions(-)

Approvals:
  Mark Michelson: Looks good to me, approved
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, but someone else must approve



diff --git a/main/sched.c b/main/sched.c
index e92e3ff..f851670 100644
--- a/main/sched.c
+++ b/main/sched.c
@@ -315,9 +315,16 @@
 		if (!new_id) {
 			break;
 		}
-		new_id->id = i;
+
+		/*
+		 * According to the API doxygen a sched ID of 0 is valid.
+		 * Unfortunately, 0 was never returned historically and
+		 * several users incorrectly coded usage of the returned
+		 * sched ID assuming that 0 was invalid.
+		 */
+		new_id->id = ++con->id_queue_size;
+
 		AST_LIST_INSERT_TAIL(&con->id_queue, new_id, list);
-		++con->id_queue_size;
 	}
 
 	return con->id_queue_size - original_size;

-- 
To view, visit https://gerrit.asterisk.org/1743
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib19c7ebb44ec9fd393ef6646dea806d4f34e3a20
Gerrit-PatchSet: 2
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-code-review mailing list