[PATCH xf86-video-intel 1/7] Fix transposed calloc() arguments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>

gcc-14 complains:
../src/legacy/i810/i810_dri.c:281:48: warning: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
...

Fix them all up via cocci:
@@
expression E1, E2;
type T;
@@
(
- calloc(sizeof(T), E2)
+ calloc(E2, sizeof(T))
|
- calloc(sizeof(E1), E2)
+ calloc(E2, sizeof(E1))
)

Signed-off-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>
---
 src/legacy/i810/i810_dri.c    | 2 +-
 src/legacy/i810/i810_driver.c | 2 +-
 src/sna/sna_display.c         | 4 ++--
 src/sna/sna_glyphs.c          | 4 ++--
 src/uxa/intel_display.c       | 8 ++++----
 src/uxa/intel_present.c       | 2 +-
 src/uxa/uxa-glyphs.c          | 2 +-
 src/uxa/uxa.c                 | 2 +-
 test/basic-copyarea.c         | 3 ++-
 test/basic-fillrect.c         | 3 ++-
 test/basic-putimage.c         | 3 ++-
 test/render-composite-solid.c | 3 ++-
 test/render-copy-alphaless.c  | 3 ++-
 test/render-copyarea.c        | 3 ++-
 test/render-fill-copy.c       | 3 ++-
 test/render-fill.c            | 3 ++-
 test/render-trapezoid-image.c | 3 ++-
 test/render-trapezoid.c       | 3 ++-
 18 files changed, 33 insertions(+), 23 deletions(-)

diff --git a/src/legacy/i810/i810_dri.c b/src/legacy/i810/i810_dri.c
index cca35d663b35..6c747f483ac6 100644
--- a/src/legacy/i810/i810_dri.c
+++ b/src/legacy/i810/i810_dri.c
@@ -278,7 +278,7 @@ I810DRIScreenInit(ScreenPtr pScreen)
    }
    pDRIInfo->SAREASize = SAREA_MAX;
 
-   if (!(pI810DRI = (I810DRIPtr) calloc(sizeof(I810DRIRec), 1))) {
+   if (!(pI810DRI = (I810DRIPtr) calloc(1, sizeof(I810DRIRec)))) {
       DRIDestroyInfoRec(pI810->pDRIInfo);
       pI810->pDRIInfo = NULL;
       return FALSE;
diff --git a/src/legacy/i810/i810_driver.c b/src/legacy/i810/i810_driver.c
index 778b1a415274..c0de514e6a7c 100644
--- a/src/legacy/i810/i810_driver.c
+++ b/src/legacy/i810/i810_driver.c
@@ -1544,7 +1544,7 @@ I810ScreenInit(SCREEN_INIT_ARGS_DECL)
    pI810 = I810PTR(scrn);
    hwp = VGAHWPTR(scrn);
 
-   pI810->LpRing = calloc(sizeof(I810RingBuffer),1);
+   pI810->LpRing = calloc(1, sizeof(I810RingBuffer));
    if (!pI810->LpRing) {
      xf86DrvMsg(scrn->scrnIndex, X_ERROR,
 		"Could not allocate lpring data structure.\n");
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index d4fa7b0bc759..e4a26ac53437 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -3793,7 +3793,7 @@ sna_crtc_add(ScrnInfoPtr scrn, unsigned id, int index)
 
 	DBG(("%s(%d): is-zaphod? %d\n", __FUNCTION__, id, is_zaphod(scrn)));
 
-	sna_crtc = calloc(sizeof(struct sna_crtc), 1);
+	sna_crtc = calloc(1, sizeof(struct sna_crtc));
 	if (sna_crtc == NULL)
 		return false;
 
@@ -5321,7 +5321,7 @@ sna_output_add(struct sna *sna, unsigned id, unsigned serial)
 		possible_crtcs >>= ffs(zaphod_crtcs) - 1;
 	}
 
-	sna_output = calloc(sizeof(struct sna_output), 1);
+	sna_output = calloc(1, sizeof(struct sna_output));
 	if (!sna_output)
 		return -1;
 
diff --git a/src/sna/sna_glyphs.c b/src/sna/sna_glyphs.c
index ebc061b5a8a8..285ded82128a 100644
--- a/src/sna/sna_glyphs.c
+++ b/src/sna/sna_glyphs.c
@@ -269,8 +269,8 @@ bool sna_glyphs_create(struct sna *sna)
 
 		cache->count = cache->evict = 0;
 		cache->picture = picture;
-		cache->glyphs = calloc(sizeof(struct sna_glyph *),
-				       GLYPH_CACHE_SIZE);
+		cache->glyphs = calloc(GLYPH_CACHE_SIZE,
+				       sizeof(struct sna_glyph *));
 		if (!cache->glyphs)
 			goto bail;
 
diff --git a/src/uxa/intel_display.c b/src/uxa/intel_display.c
index 409cbbcf7901..fc8e0811fd4a 100644
--- a/src/uxa/intel_display.c
+++ b/src/uxa/intel_display.c
@@ -313,7 +313,7 @@ intel_crtc_apply(xf86CrtcPtr crtc)
 	int fb_id, x, y;
 	int i, ret = FALSE;
 
-	output_ids = calloc(sizeof(uint32_t), xf86_config->num_output);
+	output_ids = calloc(xf86_config->num_output, sizeof(uint32_t));
 	if (!output_ids)
 		return FALSE;
 
@@ -734,7 +734,7 @@ intel_crtc_init(ScrnInfoPtr scrn, struct intel_mode *mode, drmModeResPtr mode_re
 	xf86CrtcPtr crtc;
 	struct intel_crtc *intel_crtc;
 
-	intel_crtc = calloc(sizeof(struct intel_crtc), 1);
+	intel_crtc = calloc(1, sizeof(struct intel_crtc));
 	if (intel_crtc == NULL)
 		return;
 
@@ -1542,7 +1542,7 @@ intel_output_init(ScrnInfoPtr scrn, struct intel_mode *mode, drmModeResPtr mode_
 			return;
 		}
 	}
-	kencoders = calloc(sizeof(drmModeEncoderPtr), koutput->count_encoders);
+	kencoders = calloc(koutput->count_encoders, sizeof(drmModeEncoderPtr));
 	if (!kencoders) {
 		goto out_free_encoders;
 	}
@@ -1558,7 +1558,7 @@ intel_output_init(ScrnInfoPtr scrn, struct intel_mode *mode, drmModeResPtr mode_
 		goto out_free_encoders;
 	}
 
-	intel_output = calloc(sizeof(struct intel_output), 1);
+	intel_output = calloc(1, sizeof(struct intel_output));
 	if (!intel_output) {
 		xf86OutputDestroy(output);
 		goto out_free_encoders;
diff --git a/src/uxa/intel_present.c b/src/uxa/intel_present.c
index b21e5c41072f..d92aebc68e12 100644
--- a/src/uxa/intel_present.c
+++ b/src/uxa/intel_present.c
@@ -168,7 +168,7 @@ intel_present_queue_vblank(RRCrtcPtr                    crtc,
 	int                                     ret;
 	uint32_t                                seq;
 
-	event = calloc(sizeof(struct intel_present_vblank_event), 1);
+	event = calloc(1, sizeof(struct intel_present_vblank_event));
 	if (!event)
 		return BadAlloc;
 	event->event_id = event_id;
diff --git a/src/uxa/uxa-glyphs.c b/src/uxa/uxa-glyphs.c
index d24ba5187870..98f02ffc442a 100644
--- a/src/uxa/uxa-glyphs.c
+++ b/src/uxa/uxa-glyphs.c
@@ -190,7 +190,7 @@ static Bool uxa_realize_glyph_caches(ScreenPtr pScreen)
 		ValidatePicture(picture);
 
 		cache->picture = picture;
-		cache->glyphs = calloc(sizeof(GlyphPtr), GLYPH_CACHE_SIZE);
+		cache->glyphs = calloc(GLYPH_CACHE_SIZE, sizeof(GlyphPtr));
 		if (!cache->glyphs)
 			goto bail;
 
diff --git a/src/uxa/uxa.c b/src/uxa/uxa.c
index b682dfd9f7f7..3a474ff6ef8b 100644
--- a/src/uxa/uxa.c
+++ b/src/uxa/uxa.c
@@ -470,7 +470,7 @@ Bool uxa_driver_init(ScreenPtr screen, uxa_driver_t * uxa_driver)
 	if (!dixRegisterPrivateKey(&uxa_screen_index, PRIVATE_SCREEN, 0))
 	    return FALSE;
 #endif
-	uxa_screen = calloc(sizeof(uxa_screen_t), 1);
+	uxa_screen = calloc(1, sizeof(uxa_screen_t));
 
 	if (!uxa_screen) {
 		LogMessage(X_WARNING,
diff --git a/test/basic-copyarea.c b/test/basic-copyarea.c
index a1ef34913176..c70b6a65536e 100644
--- a/test/basic-copyarea.c
+++ b/test/basic-copyarea.c
@@ -154,7 +154,8 @@ static void area_tests(struct test *t, int reps, int sets, enum target target)
 {
 	struct test_target tt;
 	XImage image;
-	uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height);
+	uint32_t *cells = calloc(t->out.width * t->out.height,
+				 sizeof(uint32_t));
 	int r, s, x, y;
 
 	printf("Testing area sets (%s): ", test_target_name(target));
diff --git a/test/basic-fillrect.c b/test/basic-fillrect.c
index 80c219c7b731..967caacb48bf 100644
--- a/test/basic-fillrect.c
+++ b/test/basic-fillrect.c
@@ -124,7 +124,8 @@ static void area_tests(struct test *t, int reps, int sets, enum target target)
 {
 	struct test_target tt;
 	XImage image;
-	uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height);
+	uint32_t *cells = calloc(t->out.width * t->out.height,
+				 sizeof(uint32_t));
 	int r, s, x, y;
 
 	printf("Testing area sets (%s): ", test_target_name(target));
diff --git a/test/basic-putimage.c b/test/basic-putimage.c
index e252fe3fe2b4..2a96e7cf1e31 100644
--- a/test/basic-putimage.c
+++ b/test/basic-putimage.c
@@ -144,7 +144,8 @@ static void area_tests(struct test *t, int reps, int sets, enum target target, i
 {
 	struct test_target tt;
 	XImage image;
-	uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height);
+	uint32_t *cells = calloc(t->out.width * t->out.height,
+				 sizeof(uint32_t));
 	int r, s, x, y;
 
 	printf("Testing area sets (%s %s shm): ",
diff --git a/test/render-composite-solid.c b/test/render-composite-solid.c
index 9d779be2e808..4751c0c60eb0 100644
--- a/test/render-composite-solid.c
+++ b/test/render-composite-solid.c
@@ -109,7 +109,8 @@ static void area_tests(struct test *t, int reps, int sets, enum target target)
 {
 	struct test_target tt;
 	XImage image;
-	uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height);
+	uint32_t *cells = calloc(t->out.width * t->out.height,
+				 sizeof(uint32_t));
 	int r, s, x, y;
 
 	printf("Testing area sets (%s): ", test_target_name(target));
diff --git a/test/render-copy-alphaless.c b/test/render-copy-alphaless.c
index 01c74a7ee912..5ba31291154e 100644
--- a/test/render-copy-alphaless.c
+++ b/test/render-copy-alphaless.c
@@ -139,7 +139,8 @@ static void area_tests(struct test *t, int reps, int sets, enum target target)
 {
 	struct test_target tt;
 	XImage image;
-	uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height);
+	uint32_t *cells = calloc(t->out.width * t->out.height,
+				 sizeof(uint32_t));
 	int r, s, x, y;
 
 	printf("Testing area sets (%s): ", test_target_name(target));
diff --git a/test/render-copyarea.c b/test/render-copyarea.c
index a202ddeb2711..ee7ff34e83b8 100644
--- a/test/render-copyarea.c
+++ b/test/render-copyarea.c
@@ -158,7 +158,8 @@ static void area_tests(struct test *t, int reps, int sets, enum target target)
 {
 	struct test_target tt;
 	XImage image;
-	uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height);
+	uint32_t *cells = calloc(t->out.width * t->out.height,
+				 sizeof(uint32_t));
 	int r, s, x, y;
 
 	printf("Testing area sets (%s): ", test_target_name(target));
diff --git a/test/render-fill-copy.c b/test/render-fill-copy.c
index b5b475a081d6..0cbbe8c93866 100644
--- a/test/render-fill-copy.c
+++ b/test/render-fill-copy.c
@@ -131,7 +131,8 @@ static void area_tests(struct test *t, int reps, int sets, enum target target)
 {
 	struct test_target tt;
 	XImage image;
-	uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height);
+	uint32_t *cells = calloc(t->out.width * t->out.height,
+				 sizeof(uint32_t));
 	int r, s, x, y;
 
 	printf("Testing area sets (%s): ", test_target_name(target));
diff --git a/test/render-fill.c b/test/render-fill.c
index 37c9d8583249..153104649d02 100644
--- a/test/render-fill.c
+++ b/test/render-fill.c
@@ -101,7 +101,8 @@ static void area_tests(struct test *t, int reps, int sets, enum target target)
 {
 	struct test_target tt;
 	XImage image;
-	uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height);
+	uint32_t *cells = calloc(t->out.width * t->out.height,
+				 sizeof(uint32_t));
 	int r, s, x, y;
 
 	printf("Testing area sets (%s): ", test_target_name(target));
diff --git a/test/render-trapezoid-image.c b/test/render-trapezoid-image.c
index 452b4ec99a95..0a84ef887eee 100644
--- a/test/render-trapezoid-image.c
+++ b/test/render-trapezoid-image.c
@@ -265,7 +265,8 @@ static void area_tests(struct test *t, int reps, int sets, enum target target, i
 {
 	struct test_target tt;
 	XImage image;
-	uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height);
+	uint32_t *cells = calloc(t->out.width * t->out.height,
+				 sizeof(uint32_t));
 	int r, s, x, y;
 
 	printf("Testing area sets (%s using %s source): ",
diff --git a/test/render-trapezoid.c b/test/render-trapezoid.c
index f15a78e3bdc0..38713a5fc8ff 100644
--- a/test/render-trapezoid.c
+++ b/test/render-trapezoid.c
@@ -151,7 +151,8 @@ static void area_tests(struct test *t, int reps, int sets, enum target target)
 {
 	struct test_target tt;
 	XImage image;
-	uint32_t *cells = calloc(sizeof(uint32_t), t->out.width*t->out.height);
+	uint32_t *cells = calloc(t->out.width * t->out.height,
+				 sizeof(uint32_t));
 	int r, s, x, y;
 
 	printf("Testing area sets (%s): ", test_target_name(target));
-- 
2.45.3




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux