public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: Sergei Trofimovich <slyich@gmail.com>
To: systemtap@sourceware.org
Cc: Sergei Trofimovich <slyich@gmail.com>
Subject: [PATCH] staprun: fix build against upcoming `gcc-14` (`-Werror=calloc-transposed-args`)
Date: Thu, 21 Dec 2023 10:00:06 +0000	[thread overview]
Message-ID: <20231221100006.3059923-1-slyich@gmail.com> (raw)

`gcc-14` added a new `-Wcalloc-transposed-args` warning recently. It
detected minor infelicity in `calloc()` API usage in `systemtap`:

    staprun.c: In function 'main':
    staprun.c:550:50: error: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
      550 |                 char ** new_argv = calloc(sizeof(char *),argc+2);
          |                                                  ^~~~
---
 staprun/staprun.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/staprun/staprun.c b/staprun/staprun.c
index 8437f3af6..d1b0b221b 100644
--- a/staprun/staprun.c
+++ b/staprun/staprun.c
@@ -547,7 +547,7 @@ int main(int argc, char **argv)
            us to extend argv[], with all the C fun that entails. */
 #ifdef HAVE_OPENAT
         if (relay_basedir_fd >= 0) {
-                char ** new_argv = calloc(sizeof(char *),argc+2);
+                char ** new_argv = calloc(argc+2, sizeof(char *));
                 const int new_Foption_size = 10; /* -FNNNNN */
                 char * new_Foption = malloc(new_Foption_size);
                 int i;
-- 
2.42.0


             reply	other threads:[~2023-12-21 10:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-21 10:00 Sergei Trofimovich [this message]
2023-12-21 14:58 ` Frank Ch. Eigler

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=20231221100006.3059923-1-slyich@gmail.com \
    --to=slyich@gmail.com \
    --cc=systemtap@sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).