]> git.ipfire.org Git - thirdparty/libcgroup.git/commit
api.c: fix unused variable in cgroup_parse_rules_file()
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Wed, 19 Jul 2023 04:35:44 +0000 (10:05 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 19 Jul 2023 18:15:41 +0000 (12:15 -0600)
commitde5127c3947159edfeca9a7f86780d829ea81ab2
treee6308d353637f1d2bf95fe587adef77858900a84
parentf3f21d21f7ac47a2f74eb0bbc109ae6019723ae7
api.c: fix unused variable in cgroup_parse_rules_file()

Fix an unused variable warning, reported by the Coverity tool:

CID 320877 (#1 of 1): Unused value (UNUSED_VALUE) assigned_pointer:
Assigning value NULL to pwd here, but that stored value is overwritten
before it can be used.

Move the grp, pwd variables assignment to beginning of the while loop in
the cgroup_parse_rules_file().

Tested with following cgrules
-----------------------------
$ cat /etc/cgrules.conf
student         devices         /usergroup/students
@admin          *               admingroup/
peter           cpu             test1/
%               memory          test2/
*               *               default/

$ sudo CGROUP_LOGLEVEL=DEBUG ./src/daemon/cgrulesengd -d -n
Parsing configuration file /etc/cgrules.conf.
Added rule student (UID: 1001, GID: -1) -> /usergroup/students for
controllers: devices
Added rule @admin (UID: -1, GID: 1004) -> admingroup/ for controllers: *
Added rule peter (UID: 1003, GID: -1) -> test1/ for controllers: cpu
Added rule % (UID: 1003, GID: -1) -> test2/ for controllers: memory
Added rule * (UID: -2, GID: -2) -> default/ for controllers: *
Parsing of configuration file complete.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/api.c