diff mbox series

[2/4] libselinux: reorder calloc(3) arguments

Message ID 20240105183534.1110639-2-cgzones@googlemail.com (mailing list archive)
State Accepted
Commit b18fddef2e0a
Delegated to: Petr Lautrbach
Headers show
Series [1/4] libsepol: reorder calloc(3) arguments | expand

Commit Message

Christian Göttsche Jan. 5, 2024, 6:35 p.m. UTC
The canonical order of calloc(3) parameters is the number of elements
first and the size of each element second.

Reported by GCC 14:

    is_customizable_type.c:43:45: warning: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args]

Signed-off-by: Christian Göttsche <cgzones@googlemail.com>
---
 libselinux/src/is_customizable_type.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/libselinux/src/is_customizable_type.c b/libselinux/src/is_customizable_type.c
index da301c60..0ae92c8d 100644
--- a/libselinux/src/is_customizable_type.c
+++ b/libselinux/src/is_customizable_type.c
@@ -39,9 +39,7 @@  static void customizable_init(void)
 	}
 
 	if (ctr) {
-		list =
-		    (char **) calloc(sizeof(char *),
-						  ctr + 1);
+		list = calloc(ctr + 1, sizeof(char *));
 		if (list) {
 			i = 0;
 			while (fgets_unlocked(buf, selinux_page_size, fp)