Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mauro.chehab@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [PATCH i-g-t v2 4/4] lib: fix calloc calls with inverted arguments
Date: Wed, 10 Apr 2024 16:42:38 +0200	[thread overview]
Message-ID: <20240410144321.44766-5-mauro.chehab@linux.intel.com> (raw)
In-Reply-To: <20240410144321.44766-1-mauro.chehab@linux.intel.com>

From: Mauro Carvalho Chehab <mchehab@kernel.org>

The new gcc version 14 now complains when calloc is called
with inverted arguments. use the script from:
a0ee73a8f359 ("benchmarks: fix calloc calls with inverted arguments")

To fix it.

Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
---
 lib/igt_chamelium.c | 4 ++--
 lib/igt_kms.c       | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index 881e1892cf87..016d5356630c 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -153,7 +153,7 @@ struct chamelium_port **chamelium_get_ports(struct chamelium *chamelium,
 {
 	int i;
 	struct chamelium_port **ret =
-		calloc(sizeof(void*), chamelium->port_count);
+		calloc(chamelium->port_count, sizeof(void*));
 
 	*count = chamelium->port_count;
 	for (i = 0; i < chamelium->port_count; i++)
@@ -1516,7 +1516,7 @@ igt_crc_t *chamelium_read_captured_crcs(struct chamelium *chamelium,
 	res = chamelium_rpc(chamelium, NULL, "GetCapturedChecksums", "(in)", 0);
 
 	*frame_count = xmlrpc_array_size(&chamelium->env, res);
-	ret = calloc(sizeof(igt_crc_t), *frame_count);
+	ret = calloc(*frame_count, sizeof(igt_crc_t));
 
 	for (i = 0; i < *frame_count; i++) {
 		xmlrpc_array_read_item(&chamelium->env, res, i, &elem);
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 2a518eb8d936..60339565a192 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -2778,7 +2778,7 @@ void igt_display_require(igt_display_t *display, int drm_fd)
 		     resources->count_crtcs, IGT_MAX_PIPES);
 
 	display->n_pipes = IGT_MAX_PIPES;
-	display->pipes = calloc(sizeof(igt_pipe_t), display->n_pipes);
+	display->pipes = calloc(display->n_pipes, sizeof(igt_pipe_t));
 	igt_assert_f(display->pipes, "Failed to allocate memory for %d pipes\n", display->n_pipes);
 
 	for (i = 0; i < resources->count_crtcs; i++) {
@@ -2806,7 +2806,7 @@ void igt_display_require(igt_display_t *display, int drm_fd)
 	igt_assert(plane_resources);
 
 	display->n_planes = plane_resources->count_planes;
-	display->planes = calloc(sizeof(igt_plane_t), display->n_planes);
+	display->planes = calloc(display->n_planes, sizeof(igt_plane_t));
 	igt_assert_f(display->planes, "Failed to allocate memory for %d planes\n", display->n_planes);
 
 	for (i = 0; i < plane_resources->count_planes; ++i) {
@@ -2855,7 +2855,7 @@ void igt_display_require(igt_display_t *display, int drm_fd)
 		}
 
 		igt_assert_lt(0, n_planes);
-		pipe->planes = calloc(sizeof(igt_plane_t), n_planes);
+		pipe->planes = calloc(n_planes, sizeof(igt_plane_t));
 		igt_assert_f(pipe->planes, "Failed to allocate memory for %d planes\n", n_planes);
 		last_plane = n_planes - 1;
 
-- 
2.44.0


  parent reply	other threads:[~2024-04-10 14:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-10 14:42 [PATCH i-g-t v2 0/4] Fix warnings with gcc 14 Mauro Carvalho Chehab
2024-04-10 14:42 ` [PATCH i-g-t v2 1/4] benchmarks: fix calloc calls with inverted arguments Mauro Carvalho Chehab
2024-04-10 15:06   ` Kamil Konieczny
2024-04-10 14:42 ` [PATCH i-g-t v2 2/4] assembler: " Mauro Carvalho Chehab
2024-04-10 15:13   ` Kamil Konieczny
2024-04-10 14:42 ` [PATCH i-g-t v2 3/4] tests: " Mauro Carvalho Chehab
2024-04-10 15:15   ` Kamil Konieczny
2024-04-10 14:42 ` Mauro Carvalho Chehab [this message]
2024-04-10 15:17   ` [PATCH i-g-t v2 4/4] lib: " Kamil Konieczny
2024-04-10 23:30 ` ✗ Fi.CI.BAT: failure for Fix warnings with gcc 14 Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240410144321.44766-5-mauro.chehab@linux.intel.com \
    --to=mauro.chehab@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox