From 8190c6f6df72f9c1d27bd19ebcdab76a5436aaa9 Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Thu, 22 Jul 2021 16:03:54 +0200 Subject: #1051 Initialize task_id once in og_cmd_post_schedule_command Fixes task_id re-initialization in commit 33d8cecfe. Task id is to be initialized with the "session" value and can be done out of the for loop it was before. Avoiding unnecesary snprintf's with the same value. --- src/rest.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/rest.c') diff --git a/src/rest.c b/src/rest.c index fa35eab..41738ea 100644 --- a/src/rest.c +++ b/src/rest.c @@ -4848,15 +4848,15 @@ static int og_cmd_post_schedule_command(json_t *element, goto err_dbi_result; } dbi_result_free(result); + } - len = snprintf(task_id, sizeof(sequence), "%d", sequence); - if (len >= (int)sizeof(task_id)) { - syslog(LOG_ERR, "truncated snprintf (%s:%d)\n", - __func__, __LINE__); - goto err_dbi; - } - params->task_id = task_id; + len = snprintf(task_id, sizeof(session), "%d", session); + if (len >= (int)sizeof(task_id)) { + syslog(LOG_ERR, "truncated snprintf (%s:%d)\n", + __func__, __LINE__); + goto err_dbi_result; } + params->task_id = task_id; og_task_schedule_create(params); -- cgit v1.2.3-18-g5258