From: Richard Mudgett Date: Mon, 30 Nov 2015 22:42:47 +0000 (-0600) Subject: sched.c: Make not return a sched id of 0. X-Git-Tag: 11.21.0-rc1~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd4aee4b7bd10f793ae0bbd7db8fcdb9eff9c65c;p=thirdparty%2Fasterisk.git 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 --- diff --git a/main/sched.c b/main/sched.c index 366bb9a24f..882aa711db 100644 --- a/main/sched.c +++ b/main/sched.c @@ -327,9 +327,16 @@ static int add_ids(struct ast_sched_context *con) 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;