]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
api: cg_move_task_files() - rearrange code to avoid extra check
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Sat, 8 Jul 2023 14:49:55 +0000 (20:19 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Mon, 17 Jul 2023 17:15:15 +0000 (11:15 -0600)
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 <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/api.c

index 0a4f0066bb91f9d4055ad52f873dccf86fe17ce2..90fb97877011d51796b71084f8852736d2c725a7 100644 (file)
--- 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);