From: Kamalesh Babulal Date: Sat, 8 Jul 2023 14:49:55 +0000 (+0530) Subject: api: cg_move_task_files() - rearrange code to avoid extra check X-Git-Tag: v3.1.0~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=487b23439e681a764e8ec6f45b89e7847f3832f4;p=thirdparty%2Flibcgroup.git api: cg_move_task_files() - rearrange code to avoid extra check Fix unused variables, reported by the Coverity tool: CID 320878 (#1 of 1): Unused value (UNUSED_VALUE)assigned_value: Assigning value 0 to ret here, but that stored value is overwritten before it can be used. Currently, in cg_move_task_files(), the ret is checked for ESRCH and set to zero, if true, and for other error values it executes the error path but immediately the ret is over-written without reading the set zero, re-arrange the code to such that only the error path is executed and ret is not set to zero. Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- diff --git a/src/api.c b/src/api.c index 0a4f0066..90fb9787 100644 --- a/src/api.c +++ b/src/api.c @@ -3166,12 +3166,8 @@ static int cg_move_task_files(FILE *input_tasks, FILE *output_tasks) break; ret = fprintf(output_tasks, "%d", tids); - if (ret < 0) { - if (errno == ESRCH) - ret = 0; - else - break; - } + if (ret < 0 && errno != ESRCH) + break; /* Flush the file, we need only one process per write() call. */ ret = fflush(output_tasks);