]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
gunit/006: use ARRAY_SIZE() macro
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Tue, 8 Aug 2023 10:56:40 +0000 (16:26 +0530)
committerTom Hromatka <tom.hromatka@oracle.com>
Thu, 10 Aug 2023 15:56:48 +0000 (09:56 -0600)
Use ARRAY_SIZE() macro to calculate the length of the array, across the
file.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
tests/gunit/006-cgroup_get_cgroup.cpp

index e2f43f97c8b92ac1c9fa350b5ee3784c770c6595..833c2d4be1da730883ec3b64b92f813ef11d5c9b 100644 (file)
@@ -39,8 +39,7 @@ static const char * const CONTROLLERS[] = {
        "namespaces",
        "netns",
 };
-static const int CONTROLLERS_CNT =
-       sizeof(CONTROLLERS) / sizeof(CONTROLLERS[0]);
+static const int CONTROLLERS_CNT = ARRAY_SIZE(CONTROLLERS);
 
 static const char * const NAMES[][MAX_NAMES] = {
        {"tasks", "cpu.shares", "cpu.weight", "cpu.foo", NULL},
@@ -50,7 +49,7 @@ static const char * const NAMES[][MAX_NAMES] = {
        {"tasks", "namespaces.blah", NULL, NULL, NULL},
        {"tasks", "netns.foo", "netns.bar", "netns.baz", NULL},
 };
-static const int NAMES_CNT = sizeof(NAMES) / sizeof(NAMES[0]);
+static const int NAMES_CNT = ARRAY_SIZE(NAMES);
 
 static const char * const VALUES[][MAX_NAMES] = {
        {"1234", "512", "100", "abc123", NULL},
@@ -60,7 +59,7 @@ static const char * const VALUES[][MAX_NAMES] = {
        {"59832", "The Quick Brown Fox", NULL, NULL, NULL},
        {"987\n654", "root", "/sys/fs", "0xdeadbeef", NULL},
 };
-static const int VALUES_CNT = sizeof(VALUES) / sizeof(VALUES[0]);
+static const int VALUES_CNT = ARRAY_SIZE(VALUES);
 
 static const char * const CG_NAME = "tomcatcg";
 static const mode_t MODE = S_IRWXU | S_IRWXG | S_IRWXO;