]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
tools/cgdelete: fix coverity wrong argument size warning
authorKamalesh Babulal <kamalesh.babulal@oracle.com>
Wed, 18 May 2022 17:11:43 +0000 (11:11 -0600)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 18 May 2022 17:11:49 +0000 (11:11 -0600)
Fix a wrong argument size, reported by Coverity tool:

CID 1412122 (#1 of 1): Wrong sizeof argument (SIZEOF_MISMATCH)
suspicious_sizeof: Passing argument 8UL
/* sizeof (struct ext_cgroup_record *) */ to function calloc and then
casting the return value to struct ext_cgroup_record * is suspicious.

Also, fix the typo in the variable name, that's being allocated memory.

Signed-off-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
Signed-off-by: Tom Hromatka <tom.hromatka@oracle.com>
(cherry picked from commit 2045fcd6b3428f1b1ca226974259e00399049472)

src/tools/cgdelete.c

index 43cc47c22d22abeae6734c483187db02c43171fb..13a86c38ef54845b02b7a3169ce3483539810586 100644 (file)
@@ -155,8 +155,8 @@ int main(int argc, char *argv[])
                goto err;
        }
 
-       ecg_list = calloc(argc, sizeof(struct ext_cgroup_record *));
-       if (cgroup_list == NULL) {
+       ecg_list = calloc(argc, sizeof(struct ext_cgroup_record));
+       if (ecg_list == NULL) {
                fprintf(stderr, "%s: out of memory\n", argv[0]);
                ret = -1;
                goto err;