summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJose M. Guisado <jguisado@soleta.eu>2021-07-22 16:03:54 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2021-07-22 16:06:26 +0200
commit8190c6f6df72f9c1d27bd19ebcdab76a5436aaa9 (patch)
treed43f4cb9e46c8daf64544cd09942acf42f3c4e53
parent261d490c4e8ad9b6cee46e82a8ad029eeaf6cd6b (diff)
#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.
-rw-r--r--src/rest.c14
1 files changed, 7 insertions, 7 deletions
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);