Kamalesh Babulal [Tue, 22 Mar 2022 10:03:41 +0000 (15:33 +0530)]
tools-common.h: add logging helpers
fprintf(stderr, ...); is used across the tools to notify the user about
something that went wrong and needs to abort. Similarly, printf() is
used to print information, may continue with the code execution.
This patch adds helper macro err(), info(), that can replace messaging
printing to stderr/stdout, making code readable and compact.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 24 Mar 2022 13:55:40 +0000 (07:55 -0600)]
specfile: fix the samples/config path
Change the location of sample configuration files from sample/ to
samples/config/, this movement got introduced by Commit b546e328e00c
"samples: Move the config examples to samples/config/").
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Fri, 18 Mar 2022 15:41:20 +0000 (09:41 -0600)]
tests: Ignore cpuset exclusive errors in test 038
Setting the cpuset exclusive can be challenging because other
cgroups could be using the cpu that is slated to become exclusive
to this cgroup. Add try/except handling to test 038 for when we
can't get the exclusive bit set, so that the test doesn't fail due
to circumstances beyond libcgroup's control.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Wed, 23 Mar 2022 15:13:27 +0000 (09:13 -0600)]
ftests: Add support for make distcheck
make distcheck builds libcgroup in a different directory
from where it runs the tests. Add smarts to ftests.sh and
ftests-nocontainer.sh to support this case by copying the
requisite python files. After the tests complete, the
python files are then removed.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Fri, 18 Mar 2022 14:00:12 +0000 (08:00 -0600)]
cgroup.py: Fix potential undeclared variable
Due to the try/except and if/else paths in snapshot(),
the variable res may not be declared before reaching the
return statement. In the case where it's undeclared,
re-raise the exception.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Tue, 15 Mar 2022 11:09:27 +0000 (16:39 +0530)]
gunit: Adopt SPDX License tag
Adopt SPDX license tag for all the source files, those already have
LGPL 2.1 boilerplate in them and those missing license information.
All the files in the project fall under project license, hence
explicitly adding LGPL-2.1-only identifier to the files missing license
information. Adopting SPDX license helps the compliance tools to
determine the license and also helps in reducing the repetitive license
boilerplate across source files.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Tue, 15 Mar 2022 11:08:28 +0000 (16:38 +0530)]
ftests: Adopt SPDX License tag
Adopt SPDX license tag for all the source files, those already have
LGPL 2.1 boilerplate in them and those missing license information.
All the files in the project fall under project license, hence
explicitly adding LGPL-2.1-only identifier to the files missing license
information. Adopting SPDX license helps the compliance tools to
determine the license and also helps in reducing the repetitive license
boilerplate across source files.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 17 Mar 2022 12:47:27 +0000 (18:17 +0530)]
src/config.c: remove log level prefix
With commit 97a0e195ddd7 ("log: add log level string prefix to
logging functions"), log level prefixes gets added to message
printed by cgroup_{err,warn,info} functions, remove them from
message passed to these functions.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Sat, 19 Mar 2022 14:14:40 +0000 (19:44 +0530)]
src/api.c: remove log level prefix
With commit 97a0e195ddd7 ("log: add log level string prefix to
logging functions"), log level prefixes gets added to message
printed by cgroup_{err,warn,info} functions, remove them from
message passed to these functions.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Sat, 19 Mar 2022 14:14:29 +0000 (19:44 +0530)]
src/abstraction-common.c: remove log level prefix
With commit 97a0e195ddd7 ("log: add log level string prefix to
logging functions"), log level prefixes gets added to message
printed by cgroup_{err,warn,info} functions, remove them from
message passed to these functions.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Sat, 19 Mar 2022 06:55:25 +0000 (12:25 +0530)]
Makefile: fix samples/c build dependency
If the user chooses to build the samples/c programs, it will fail to
build, with the error:
config.status: creating samples/c/Makefile
CC setuid.o
make: *** No rule to make target '../../src/.libs/libcgroup.la', needed by 'setuid'. Stop.
it is due to the dependency on libcgroup.la, which is currently built
after samples. Fix it by moving the samples directory to be built after
src directory.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
1. Remove obsolete constructions from scripts/init/cgconfig.in
2. Add fallback logging functions for non-lsb systems.
Signed-off-by: Vladimir Nikishkin <libcgroup@lockywolf.net> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
TJH: Merged the original patch and review comments patch into one commit
Kamalesh Babulal [Wed, 16 Mar 2022 16:18:08 +0000 (21:48 +0530)]
libcgroup.doxyfile: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO types. It also introduces
reverse xmas tree local variable declarations and header file
reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 1 warnings, 1519 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 16:17:38 +0000 (21:47 +0530)]
include/tools.h: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG. It also introduces reverse xmas tree local
variable declarations and header file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 1 errors, 3 warnings, 73 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 16:17:11 +0000 (21:47 +0530)]
include/tasks.h: introduce coding style changes
This patch introduces coding style changes such as reverse xmas tree
local variable declarations, header file reordering, and many other
minor tweaks such as line spacing, removing trailing white spaces.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 16:16:41 +0000 (21:46 +0530)]
include/log.h: introduce coding style changes
This patch introduces coding style changes such as reverse xmas tree
local variable declarations, header file reordering, and many other
minor tweaks such as line spacing, removing trailing white spaces.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 16:16:22 +0000 (21:46 +0530)]
include/iterators.h: fix checkpatch.pl warnings
This patch introduces coding style changes such as reverse xmas tree
local variable declarations, header file reordering, and many other
minor tweaks such as line spacing, removing trailing white spaces.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 25 warnings, 432 lines checked
Kamalesh Babulal [Wed, 16 Mar 2022 16:16:04 +0000 (21:46 +0530)]
include/init.h: fix checkpatch.pl warnings
This patch introduces coding style changes such as reverse xmas tree
local variable declarations, header file reordering, and many other
minor tweaks such as line spacing, removing trailing white spaces.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 1 warnings, 86 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 16:15:44 +0000 (21:45 +0530)]
include/groups.h: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG. It also introduces reverse xmas tree local
variable declarations and header file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 27 warnings, 630 lines checked
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG. It also introduces reverse xmas tree local
variable declarations and header file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 2 errors, 19 warnings, 927 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG. It also introduces reverse xmas tree local
variable declarations and header file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 1 errors, 0 warnings, 44 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 16:13:15 +0000 (21:43 +0530)]
samples/walk_test.c: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG. It also introduces reverse xmas tree local
variable declarations and header file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 0 warnings, 121 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 16:12:57 +0000 (21:42 +0530)]
samples/walk_task.c: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG. It also introduces reverse xmas tree local
variable declarations and header file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 1 warnings, 49 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG. It also introduces reverse xmas tree local
variable declarations and header file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 1 errors, 0 warnings, 47 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 16:07:47 +0000 (21:37 +0530)]
samples/setuid.c: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG. It also introduces reverse xmas tree local
variable declarations and header file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
0 errors, 1 warnings, 82 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 16:07:14 +0000 (21:37 +0530)]
samples/read_stats.c: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG. It also introduces reverse xmas tree local
variable declarations and header file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 0 warnings, 84 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 16:05:16 +0000 (21:35 +0530)]
samples/proctest.c: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG. It also introduces reverse xmas tree local
variable declarations and header file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
0 errors, 1 warnings, 55 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 16:04:27 +0000 (21:34 +0530)]
samples/logger.c: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG. It also introduces reverse xmas tree local
variable declarations and header file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 0 warnings, 53 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG. It also introduces reverse xmas tree local
variable declarations and header file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 2 warnings, 59 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 16:00:10 +0000 (21:30 +0530)]
samples/get_procs.c: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG. It also introduces reverse xmas tree local
variable declarations and header file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 1 errors, 0 warnings, 36 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG. It also introduces reverse xmas tree local
variable declarations and header file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 1 errors, 1 warnings, 49 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG. It also introduces reverse xmas tree local
variable declarations and header file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 1 errors, 0 warnings, 34 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG. It also introduces reverse xmas tree local
variable declarations and header file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 1 errors, 0 warnings, 34 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 15:54:04 +0000 (21:24 +0530)]
cgrulesengd.c: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types. It
also introduces reverse xmas tree local variable declarations and header
file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 10 errors, 36 warnings, 1306 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 15:53:45 +0000 (21:23 +0530)]
cgrulesengd.h: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types. It
also introduces reverse xmas tree local variable declarations and header
file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 18 warnings, 129 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 15:51:53 +0000 (21:21 +0530)]
pam/pam_cgroup.c: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO types. It also introduces
reverse xmas tree local variable declarations and header file
reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 10 warnings, 163 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 15:51:36 +0000 (21:21 +0530)]
tools-common.h: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types. It
also introduces reverse xmas tree local variable declarations and header
file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 7 warnings, 145 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 15:50:38 +0000 (21:20 +0530)]
tools-common.c: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types. It
also introduces reverse xmas tree local variable declarations and header
file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 1 errors, 2 warnings, 312 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 16:24:34 +0000 (21:54 +0530)]
lssubsys.c: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types. It
also introduces reverse xmas tree local variable declarations and header
file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 16 warnings, 295 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 15:45:33 +0000 (21:15 +0530)]
lscgroup.c: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types. It
also introduces reverse xmas tree local variable declarations and header
file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 9 warnings, 328 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 15:45:01 +0000 (21:15 +0530)]
cgxset.c: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types. It
also introduces reverse xmas tree local variable declarations and header
file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 1 errors, 20 warnings, 385 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 15:42:43 +0000 (21:12 +0530)]
cgxget.c: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types. It
also introduces reverse xmas tree local variable declarations and header
file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 2 errors, 17 warnings, 921 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 15:37:43 +0000 (21:07 +0530)]
cgsnapshot.c: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types. It
also introduces reverse xmas tree local variable declarations and header
file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 1 errors, 39 warnings, 847 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 15:36:34 +0000 (21:06 +0530)]
cgset.c: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types. It
also introduces reverse xmas tree local variable declarations and header
file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 1 errors, 16 warnings, 284 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 15:32:16 +0000 (21:02 +0530)]
cgget.c: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types. It
also introduces reverse xmas tree local variable declarations and header
file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 2 errors, 13 warnings, 772 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 15:25:09 +0000 (20:55 +0530)]
cgexec.c: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types. It
also introduces reverse xmas tree local variable declarations and header
file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 2 errors, 8 warnings, 178 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 15:24:30 +0000 (20:54 +0530)]
cgdelete.c: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types. It
also introduces reverse xmas tree local variable declarations and header
file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 1 errors, 6 warnings, 303 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 15:23:50 +0000 (20:53 +0530)]
cgcreate.c: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types. It
also introduces reverse xmas tree local variable declarations and header
file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 10 warnings, 247 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 15:22:59 +0000 (20:52 +0530)]
cgconfig.c: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types. It
also introduces reverse xmas tree local variable declarations and header
file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 11 warnings, 213 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 16 Mar 2022 15:22:23 +0000 (20:52 +0530)]
cgclassify.c: fix checkpatch.pl warnings
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO and NEW_TYPEDEFS types. It
also introduces reverse xmas tree local variable declarations and header
file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 2 errors, 10 warnings, 203 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Mon, 14 Mar 2022 10:35:06 +0000 (16:05 +0530)]
.checkpatch.conf: add NEW_TYPEDEFS to ignore-list
There are tools/files, that introduce new typdefs and checkpatch.pl is
unhappy about it. It takes some re-work on removing and for now let's
teach checkpatch to ignore it.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Mon, 14 Mar 2022 04:38:44 +0000 (10:08 +0530)]
Adopt SPDX License tag for files missing license information
Adopt SPDX license tag for all the source files, those missing License
information. All the files in the project fall under project license,
hence explicitly adding LGPL-2.1-only identifier to them. The SPDX
license identifier is added for the files, reported by checkpatch.pl.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Mon, 14 Mar 2022 04:35:01 +0000 (10:05 +0530)]
Adopt SPDX License tag
Adopt SPDX license tag for all the source files, those already have
LGPL 2.1 bolierplate in them. Adopting SPDX license helps the
compliance tools to determine the license and also helps in reducing the
repetitive license boilerplate across source files.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Fri, 11 Mar 2022 14:54:43 +0000 (07:54 -0700)]
samples/c: drop the test suites
samples/c contains test cases, those do serve as good examples on how to
use some APIs, but there are also very elaborate test cases, which are
test suites in themselves. Let's drop these examples and allow users to
look at gunit/ftests for how to contribute to test cases. This patch
also modifies the Makefile to help users to build the examples, in case
they want to give it a quick try.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Fri, 11 Mar 2022 14:51:09 +0000 (07:51 -0700)]
log: add log level string prefix to logging functions
Usage of cgroup_{err, warn, info} functions, expects the log level to be
prefixed to the message like: cgroup_warn("Warning: ..."). This patch
removes this need to prefix and automatically adds the desired prefix to
the logger function, so the usage becomes cgroup_warn("..."). This
helps in readability and avoiding typos in setting the right log level
string to the message.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/abstraction-map.c: re-arrange the header files
Re-arrange the headers files, in the following order:
1. Header files that declare the functions, are defined in this file.
2. Other header files from the libcgroup.
3. Standard header file.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/abstraction-cpuset.c: re-arrange the header files
Re-arrange the headers files, in the following order:
1. Header files that declare the functions, are defined in this file.
2. Other header files from the libcgroup.
3. Standard header file.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
src/abstraction-cpu.c: re-arrange the header files
Re-arrange the headers files, in the following order:
1. Header files that declare the functions, are defined in this file.
2. Other header files from the libcgroup.
3. Standard header file.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO types. It also introduces
reverse xmas tree local variable declarations and header file
reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 26 errors, 204 warnings, 5855 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO types. It also introduces
reverse xmas tree local variable declarations and header file
reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 55 warnings, 743 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO types. It also introduces
reverse xmas tree local variable declarations and header file
reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 3 warnings, 96 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Fix most of the warnings/errors reported by Linux Kernel's
checkpatch.pl, except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO types.
It also introduces reverse xmas tree local variable declarations
and header file reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 4 errors, 36 warnings, 1899 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO types. It also introduces
reverse xmas tree local variable declarations and header file
reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 5 errors, 2 warnings, 438 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO types. It also introduces
reverse xmas tree local variable declarations and header file
reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 4 warnings, 150 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Fix all of the warnings/errors reported by Linux Kernel's checkpatch.pl,
except SPDX_LICENSE_TAG, USE_NEGATIVE_ERRNO types. It also introduces
reverse xmas tree local variable declarations and header file
reordering.
In summary, this patch fixes the following checkpatch.pl
recommendations:
total: 0 errors, 7 warnings, 320 lines checked
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 10 Mar 2022 05:09:21 +0000 (10:39 +0530)]
test-013: add support for newer cpu.pressure output
Kernel commit 0e94682b73bf ("psi: introduce psi monitor"), adds more
information to the cgroup V2 cpu.pressure file. This patch recognizes
the additional information displayed while reading cpu.pressure file.
Older format:
-------------
cpu.pressure: some avg10=0.00 avg60=0.00 avg300=0.00 total=0
New format:
-----------
some avg10=0.00 avg60=0.00 avg300=0.00 total=0
full avg10=0.00 avg60=0.00 avg300=0.00 total=0
Fixes: https://github.com/libcgroup/libcgroup/issues/105 Reported-by: Tom Hromatka <tom.hromatka@oracle.com> Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 10 Mar 2022 05:08:03 +0000 (10:38 +0530)]
test-010: add support for newer cpu.pressure output
Kernel commit 0e94682b73bf ("psi: introduce psi monitor"), adds more
information to the cgroup V2 cpu.pressure file. This patch recognizes
the additional information displayed while reading cpu.pressure file.
Older format:
-------------
cpu.pressure: some avg10=0.00 avg60=0.00 avg300=0.00 total=0
New format:
-----------
some avg10=0.00 avg60=0.00 avg300=0.00 total=0
full avg10=0.00 avg60=0.00 avg300=0.00 total=0
Fixes: https://github.com/libcgroup/libcgroup/issues/105 Reported-by: Tom Hromatka <tom.hromatka@oracle.com> Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 10 Mar 2022 05:11:17 +0000 (10:41 +0530)]
test-009: add support for newer cpu.pressure output
Kernel commit 0e94682b73bf ("psi: introduce psi monitor"), adds more
information to the cgroup V2 cpu.pressure file. This patch recognizes
the additional information displayed while reading cpu.pressure file.
Older format:
-------------
cpu.pressure: some avg10=0.00 avg60=0.00 avg300=0.00 total=0
New format:
-----------
some avg10=0.00 avg60=0.00 avg300=0.00 total=0
full avg10=0.00 avg60=0.00 avg300=0.00 total=0
Fixes: https://github.com/libcgroup/libcgroup/issues/105 Reported-by: Tom Hromatka <tom.hromatka@oracle.com> Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Make the Python linting more exhaustive, using
https://github.com/reviewdog/action-flake8. The current linting
is limited to syntax errors, and it can also be extended. The
reason to use new action is that there is active development
in comparison to the current action used.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Mon, 28 Feb 2022 14:11:43 +0000 (19:41 +0530)]
tools/lssubsys: fix strncpy() warning
GCC complains about string truncations in
print_all_controllers_in_hierarchy:
In function 'print_all_controllers_in_hierarchy',
inlined from 'cgroup_list_all_controllers' at lssubsys.c:226:9,
inlined from 'main' at lssubsys.c:294:8:
lssubsys.c:127:25: warning: 'strncpy' output may be truncated copying 4095 bytes from a string of length 4095 [-Wstringop-truncation]
127 | strncpy(cont_name, info.name, FILENAME_MAX-1);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lssubsys.c:131:25: warning: 'strncpy' output may be truncated copying 4095 bytes from a string of length 4095 [-Wstringop-truncation]
131 | strncpy(cont_names, info.name, FILENAME_MAX-1);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
this warning seems to be a little odd when the current code is already
explicitly truncating the string. Digging deeper, it looks like the
memset(), followed by strncpy() with -O >= 2 triggers this warning on
GCC 11. A simple and safe fix would be removing the memset(). As per
the standard's strncpy() will fill the destination string with '\0', if
the source string length is lesser than that of the destination. This
fix, take this approach.
Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Thu, 24 Feb 2022 15:37:23 +0000 (21:07 +0530)]
cgroup.py: replace UnicodeDecodeError with RunError
init_cgrules(), tries creating a directory '/etc/cgconfig.d' and relies
on stderr from RunError to check if the directory already exists and
fails on other exceptions. The exception logic can be simplified by,
passing `-p` to mkdir and fail on any RunError exceptions.
This patch replaces except UnicodeDecodeError RunError to catch
any exceptions raised when running the command
`mkdir -p /etc/cgconfig.d`.
Suggested-by: Tom Hromatka <tom.hromatka@oracle.com> Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 23 Feb 2022 13:43:33 +0000 (19:13 +0530)]
run.py: fix codec type used to decode stdout, stderr
Codec 'ascii' only decodes English and can't understand other characters
and raise an UnicodeDecodeError. For example, consider running 'mkdir' on
an already existing directory, it would trigger:
err.strip().decode('ascii')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 31: ordinal not in range(128)
fix it by using 'UTF-8' as Codec for decoding, with the patch stderr
will be:
Kamalesh Babulal [Wed, 23 Feb 2022 09:47:30 +0000 (15:17 +0530)]
ftests.py: fix double import of log
Fix double import, 'import log' and 'from log import Log'. The reason to
do so is to access the global variable from the log package. This patch
uses only 'import log' that will work for both accessing the global
variables and Class Log functions.
Reported-by: LGTM Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 23 Feb 2022 09:38:48 +0000 (15:08 +0530)]
log.py: fix selfimport
It's not advised to selfimport, i.e import log. To remove this
selfimport, the global variable access needs to be fixed by using
'global' keyword inside the Class methods.
Reported-by: LGTM Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Kamalesh Babulal [Wed, 23 Feb 2022 06:16:03 +0000 (11:46 +0530)]
cgroup.py: fix nested loop variable in get_cgroup_mounts()
In get_cgroup_mounts(), both files '/proc/mounts' and
'<mountpoint>/cgroup.controller' uses 'line' as loop variable
to read lines from the file. The issue here is that, they are
nested. This patch renames second loop variable
'line' -> 'ctrlf_line'.
Reported-by: LGTM Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com> Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
Tom Hromatka [Thu, 24 Feb 2022 14:55:57 +0000 (07:55 -0700)]
github: Run the libcgroup Github Actions
Add jobs to run the libcgroup automated tests against the main
branch of libcgroup. Since the Github Action is being
triggered from the tests repo, the setup steps differ slightly
from libcgroup's steps. In this case we need to move the unit
and functional tests from the root to tests/, and we need to
move the library code from libcg/ to the root.
Finally, code coverage is not enabled in these runs.
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com> Reviewed-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>