You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
4.3 KiB
123 lines
4.3 KiB
From b79e10fce4dfceddbc9adb706d7a3300df5fabe6 Mon Sep 17 00:00:00 2001
|
|
From: Markus Metzger <markus.t.metzger@intel.com>
|
|
Date: Mon, 16 Oct 2023 07:25:19 +0000
|
|
Subject: [PATCH 2/2] libipt, ptunit: avoid lto maybe-uninitialized warning
|
|
|
|
Building with GCC 13 and -flto produces
|
|
|
|
In function 'pt_qry_get_offset',
|
|
inlined from 'get_offset_null' at .../libipt/test/src/ptunit-block_decoder.c:164:12,
|
|
inlined from 'main' at .../libipt/test/src/ptunit-block_decoder.c:336:2:
|
|
.../libipt/src/pt_query_decoder.c:380:16: error: 'decoder' may be used uninitialized [-Werror=maybe-uninitialized]
|
|
380 | return pt_evt_get_offset(&decoder->evdec, offset);
|
|
| ^
|
|
.../libipt/src/pt_event_decoder.c: In function 'main':
|
|
.../libipt/src/pt_event_decoder.c:1541:5: note: by argument 1 of type 'const struct pt_event_decoder *' to 'pt_evt_get_offset' declared here
|
|
1541 | int pt_evt_get_offset(const struct pt_event_decoder *decoder, uint64_t *offset)
|
|
| ^
|
|
.../libipt/test/src/ptunit-block_decoder.c:157:33: note: 'decoder' declared here
|
|
157 | struct pt_block_decoder decoder;
|
|
| ^
|
|
|
|
Those are false positive since the decoder object isn't actually used. In
|
|
|
|
&decoder->evdec
|
|
|
|
we compute the address of the event decoder object within the block
|
|
decoder object. This adds an offset defined by the type. It does not
|
|
actually dereference the pointer to access an uninitialized decoder
|
|
object.
|
|
|
|
Initialize the test decoder to avoid those warnings. Fixes #101.
|
|
|
|
Signed-off-by: Markus Metzger <markus.t.metzger@intel.com>
|
|
---
|
|
libipt/test/src/ptunit-block_decoder.c | 4 ++++
|
|
libipt/test/src/ptunit-encoder.c | 2 ++
|
|
libipt/test/src/ptunit-insn_decoder.c | 4 ++++
|
|
libipt/test/src/ptunit-packet_decoder.c | 4 ++++
|
|
4 files changed, 14 insertions(+)
|
|
|
|
diff --git a/libipt/test/src/ptunit-block_decoder.c b/libipt/test/src/ptunit-block_decoder.c
|
|
index 44249d3..d1ff288 100644
|
|
--- a/libipt/test/src/ptunit-block_decoder.c
|
|
+++ b/libipt/test/src/ptunit-block_decoder.c
|
|
@@ -158,6 +158,8 @@ static struct ptunit_result get_offset_null(void)
|
|
uint64_t offset;
|
|
int errcode;
|
|
|
|
+ memset(&decoder, 0, sizeof(decoder));
|
|
+
|
|
errcode = pt_blk_get_offset(NULL, &offset);
|
|
ptu_int_eq(errcode, -pte_invalid);
|
|
|
|
@@ -184,6 +186,8 @@ static struct ptunit_result get_sync_offset_null(void)
|
|
uint64_t offset;
|
|
int errcode;
|
|
|
|
+ memset(&decoder, 0, sizeof(decoder));
|
|
+
|
|
errcode = pt_blk_get_sync_offset(NULL, &offset);
|
|
ptu_int_eq(errcode, -pte_invalid);
|
|
|
|
diff --git a/libipt/test/src/ptunit-encoder.c b/libipt/test/src/ptunit-encoder.c
|
|
index 15d5eb4..edabe9e 100644
|
|
--- a/libipt/test/src/ptunit-encoder.c
|
|
+++ b/libipt/test/src/ptunit-encoder.c
|
|
@@ -138,6 +138,8 @@ static struct ptunit_result get_offset_null(void)
|
|
uint64_t offset;
|
|
int errcode;
|
|
|
|
+ memset(&encoder, 0, sizeof(encoder));
|
|
+
|
|
errcode = pt_enc_get_offset(NULL, &offset);
|
|
ptu_int_eq(errcode, -pte_invalid);
|
|
|
|
diff --git a/libipt/test/src/ptunit-insn_decoder.c b/libipt/test/src/ptunit-insn_decoder.c
|
|
index c8447e7..c5a057c 100644
|
|
--- a/libipt/test/src/ptunit-insn_decoder.c
|
|
+++ b/libipt/test/src/ptunit-insn_decoder.c
|
|
@@ -158,6 +158,8 @@ static struct ptunit_result get_offset_null(void)
|
|
uint64_t offset;
|
|
int errcode;
|
|
|
|
+ memset(&decoder, 0, sizeof(decoder));
|
|
+
|
|
errcode = pt_insn_get_offset(NULL, &offset);
|
|
ptu_int_eq(errcode, -pte_invalid);
|
|
|
|
@@ -184,6 +186,8 @@ static struct ptunit_result get_sync_offset_null(void)
|
|
uint64_t offset;
|
|
int errcode;
|
|
|
|
+ memset(&decoder, 0, sizeof(decoder));
|
|
+
|
|
errcode = pt_insn_get_sync_offset(NULL, &offset);
|
|
ptu_int_eq(errcode, -pte_invalid);
|
|
|
|
diff --git a/libipt/test/src/ptunit-packet_decoder.c b/libipt/test/src/ptunit-packet_decoder.c
|
|
index 39f1ede..4cb60ad 100644
|
|
--- a/libipt/test/src/ptunit-packet_decoder.c
|
|
+++ b/libipt/test/src/ptunit-packet_decoder.c
|
|
@@ -158,6 +158,8 @@ static struct ptunit_result get_offset_null(void)
|
|
uint64_t offset;
|
|
int errcode;
|
|
|
|
+ memset(&decoder, 0, sizeof(decoder));
|
|
+
|
|
errcode = pt_pkt_get_offset(NULL, &offset);
|
|
ptu_int_eq(errcode, -pte_invalid);
|
|
|
|
@@ -199,6 +201,8 @@ static struct ptunit_result get_sync_offset_null(void)
|
|
uint64_t offset;
|
|
int errcode;
|
|
|
|
+ memset(&decoder, 0, sizeof(decoder));
|
|
+
|
|
errcode = pt_pkt_get_sync_offset(NULL, &offset);
|
|
ptu_int_eq(errcode, -pte_invalid);
|
|
|
|
--
|
|
2.41.0
|
|
|