summaryrefslogtreecommitdiffstats
path: root/meta/recipes-kernel/systemtap/systemtap/0001-bpf-translate.cxx-fix-build-against-upcoming-gcc-14-.patch
blob: e3d94d93123491652088652ef8b440fc9d8d6eeb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
From d42139cf9cd26d0c0363fcfe007716baeb8de517 Mon Sep 17 00:00:00 2001
From: Sergei Trofimovich <slyich@gmail.com>
Date: Fri, 22 Dec 2023 19:42:38 +0000
Subject: [PATCH] bpf-translate.cxx: fix build against upcoming `gcc-14`
 (`-Werror=calloc-transposed-args`)

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

    bpf-translate.cxx: In function 'bpf::BPF_Section* bpf::output_probe(BPF_Output&, program&, const std::string&, unsigned int)':
    bpf-translate.cxx:5044:39: error: 'void* calloc(size_t, size_t)' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
     5044 |   bpf_insn *buf = (bpf_insn*) calloc (sizeof(bpf_insn), ninsns);
          |                                       ^~~~~~~~~~~~~~~~
    bpf-translate.cxx:5044:39: note: earlier argument should specify number of elements, later size of each element

Upstream-Status: Backport [https://sourceware.org/git/?p=systemtap.git;a=commit;h=d42139cf9cd26d0c0363fcfe007716baeb8de517]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
 bpf-translate.cxx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/bpf-translate.cxx b/bpf-translate.cxx
index 1a9302463..aa8ef65ce 100644
--- a/bpf-translate.cxx
+++ b/bpf-translate.cxx
@@ -5041,9 +5041,9 @@ output_probe(BPF_Output &eo, program &prog,
 	}
     }
 
-  bpf_insn *buf = (bpf_insn*) calloc (sizeof(bpf_insn), ninsns);
+  bpf_insn *buf = (bpf_insn*) calloc (ninsns, sizeof(bpf_insn));
   assert (buf);
-  Elf64_Rel *rel = (Elf64_Rel*) calloc (sizeof(Elf64_Rel), nreloc);
+  Elf64_Rel *rel = (Elf64_Rel*) calloc (nreloc, sizeof(Elf64_Rel));
   assert (rel);
 
   unsigned i = 0, r = 0;
-- 
2.43.0