[committed] libgfortran: Fix calloc call by swapping arg order [PR112364]

Message ID 3ff033dd-0187-48bb-ba7c-797232cb6000@codesourcery.com
State Accepted
Headers
Series [committed] libgfortran: Fix calloc call by swapping arg order [PR112364] |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Tobias Burnus Nov. 6, 2023, 10:53 a.m. UTC
  See PR for a discussion whether this change is required for alignment (or other) reasons
(looks as if not) - or"just" to match the indented order (arg names + description) and
to silence a -Walloc-size warning.

Committed as r14-5148-g17df6ddcf11aef

(BTW: I don't think that it is worthwhile to backport it - the -Walloc-size warning is new
since r14-5059-gd880e093d92084.)

Tobias
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
  

Patch

commit 17df6ddcf11aef6d200305d35641a7deb2f430e1
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Mon Nov 6 11:34:31 2023 +0100

    libgfortran: Fix calloc call by swapping arg order [PR112364]
    
    The prototype of calloc is
      void *calloc(size_t nmemb, size_t size);
    denoting "an array of nmemb objects, each of whose size is size." (C23)
    
    In order to follow the meaning of the argument names and to silence
    a -Walloc-size warning, this commit swaps the order of the two args
    to read now:  calloc (1, sizeof (transfer_queue));
    
    libgfortran/ChangeLog:
    
            PR libfortran/112364
            * io/async.c (enqueue_transfer, enqueue_done_id, enqueue_done,
            enqueue_close): Swap 1st and 2nd arg in calloc call.

diff --git a/libgfortran/io/async.c b/libgfortran/io/async.c
index 57097438e89..8fa1f0d4ce0 100644
--- a/libgfortran/io/async.c
+++ b/libgfortran/io/async.c
@@ -262,7 +262,7 @@  init_async_unit (gfc_unit *u)
 void
 enqueue_transfer (async_unit *au, transfer_args *arg, enum aio_do type)
 {
-  transfer_queue *tq = calloc (sizeof (transfer_queue), 1);
+  transfer_queue *tq = calloc (1, sizeof (transfer_queue));
   tq->arg = *arg;
   tq->type = type;
   tq->has_id = 0;
@@ -284,7 +284,7 @@  int
 enqueue_done_id (async_unit *au, enum aio_do type)
 {
   int ret;
-  transfer_queue *tq = calloc (sizeof (transfer_queue), 1);
+  transfer_queue *tq = calloc (1, sizeof (transfer_queue));
 
   tq->type = type;
   tq->has_id = 1;
@@ -308,7 +308,7 @@  enqueue_done_id (async_unit *au, enum aio_do type)
 void
 enqueue_done (async_unit *au, enum aio_do type)
 {
-  transfer_queue *tq = calloc (sizeof (transfer_queue), 1);
+  transfer_queue *tq = calloc (1, sizeof (transfer_queue));
   tq->type = type;
   tq->has_id = 0;
   LOCK (&au->lock);
@@ -328,7 +328,7 @@  enqueue_done (async_unit *au, enum aio_do type)
 void
 enqueue_close (async_unit *au)
 {
-  transfer_queue *tq = calloc (sizeof (transfer_queue), 1);
+  transfer_queue *tq = calloc (1, sizeof (transfer_queue));
 
   tq->type = AIO_CLOSE;
   LOCK (&au->lock);