[Asterisk-code-review] sched: Make sched settime() return void because it cannot fail (asterisk[13])

Friendly Automation asteriskteam at digium.com
Fri Jan 18 09:59:07 CST 2019


Friendly Automation has submitted this change and it was merged. ( https://gerrit.asterisk.org/10883 )

Change subject: sched: Make sched_settime() return void because it cannot fail
......................................................................

sched: Make sched_settime() return void because it cannot fail

Change-Id: I66b8b2b2778f186919d73ae9bf592104b8fb1cd5
---
M main/sched.c
1 file changed, 7 insertions(+), 13 deletions(-)

Approvals:
  Richard Mudgett: Looks good to me, but someone else must approve
  Corey Farrell: Looks good to me, but someone else must approve
  Matthew Fredrickson: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/main/sched.c b/main/sched.c
index 0e7521e..e5a6e52 100644
--- a/main/sched.c
+++ b/main/sched.c
@@ -485,7 +485,7 @@
  * given the last event *tv and the offset in milliseconds 'when',
  * computes the next value,
  */
-static int sched_settime(struct timeval *t, int when)
+static void sched_settime(struct timeval *t, int when)
 {
 	struct timeval now = ast_tvnow();
 
@@ -507,7 +507,6 @@
 	if (ast_tvcmp(*t, now) < 0) {
 		*t = now;
 	}
-	return 0;
 }
 
 int ast_sched_replace_variable(int old_id, struct ast_sched_context *con, int when, ast_sched_cb callback, const void *data, int variable)
@@ -538,12 +537,10 @@
 		tmp->variable = variable;
 		tmp->when = ast_tv(0, 0);
 		tmp->deleted = 0;
-		if (sched_settime(&tmp->when, when)) {
-			sched_release(con, tmp);
-		} else {
-			schedule(con, tmp);
-			res = tmp->sched_id->id;
-		}
+
+		sched_settime(&tmp->when, when);
+		schedule(con, tmp);
+		res = tmp->sched_id->id;
 	}
 #ifdef DUMP_SCHEDULER
 	/* Dump contents of the context while we have the lock so nothing gets screwed up by accident. */
@@ -789,11 +786,8 @@
 			 * If they return non-zero, we should schedule them to be
 			 * run again.
 			 */
-			if (sched_settime(&current->when, current->variable? res : current->resched)) {
-				sched_release(con, current);
-			} else {
-				schedule(con, current);
-			}
+			sched_settime(&current->when, current->variable ? res : current->resched);
+			schedule(con, current);
 		} else {
 			/* No longer needed, so release it */
 			sched_release(con, current);

-- 
To view, visit https://gerrit.asterisk.org/10883
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: I66b8b2b2778f186919d73ae9bf592104b8fb1cd5
Gerrit-Change-Number: 10883
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Friendly Automation (1000185)
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Matthew Fredrickson <creslin at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190118/6b357d12/attachment.html>


More information about the asterisk-code-review mailing list