From: Brahmajit Das <brahmajit.xyz@gmail.com>
To: linux-trace-devel@vger.kernel.org
Subject: [PATCH 1/1] Fix incompatible function pointer types assigning to stream_find_id_func
Date: Tue, 10 Oct 2023 19:26:33 +0000 [thread overview]
Message-ID: <20231010192738.166989-1-brahmajit.xyz@gmail.com> (raw)
Newer compilers such as Clang 16 and GCC 14 enables certain errors by
default, -Werror=incompatible-function-pointer-types being one of them
(-Werror=incompatible-pointer-types is the equivalent in GCC). This
resutls in build errors such as
error: incompatible function pointer types assigning to 'stream_find_id_func' (aka 'int (*)(struct kshark_data_stream *, const char *)') from 'const int (struct kshark_data_stream *, const char *)' [-Wincompatible-function-pointer-types]
1204 | interface->find_event_id = tepdata_find_event_id;
| ^ ~~~~~~~~~~~~~~~~~~~~~
My patch is not the best fix/a proper fix but for now silences the error
and lets me build kernelshark with clang.
I've also added some other misc. fixes that helps building kernelshark
on musl libc.
Bug: https://bugs.gentoo.org/895838
Signed-off-by: Brahmajit Das <brahmajit.xyz@gmail.com>
---
src/kernelshark.cpp | 1 +
src/libkshark-tepdata.c | 6 +++---
src/libkshark.h | 1 +
src/plugins/sched_events.c | 1 +
4 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/src/kernelshark.cpp b/src/kernelshark.cpp
index 1ad15f4..d795492 100644
--- a/src/kernelshark.cpp
+++ b/src/kernelshark.cpp
@@ -7,6 +7,7 @@
// C
#include <sys/stat.h>
#include <getopt.h>
+#include <libgen.h>
// Qt
#include <QApplication>
diff --git a/src/libkshark-tepdata.c b/src/libkshark-tepdata.c
index b780957..236a858 100644
--- a/src/libkshark-tepdata.c
+++ b/src/libkshark-tepdata.c
@@ -1201,13 +1201,13 @@ static void kshark_tep_init_methods(struct kshark_generic_stream_interface *inte
interface->get_event_name = tepdata_get_event_name;
interface->aux_info= tepdata_get_latency;
interface->get_info = tepdata_get_info;
- interface->find_event_id = tepdata_find_event_id;
+ interface->find_event_id = (stream_find_id_func) tepdata_find_event_id;
interface->get_all_event_ids = tepdata_get_event_ids;
interface->dump_entry = tepdata_dump_entry;
interface->get_all_event_field_names = tepdata_get_field_names;
interface->get_event_field_type = tepdata_get_field_type;
- interface->read_record_field_int64 = tepdata_read_record_field;
- interface->read_event_field_int64 = tepdata_read_event_field;
+ interface->read_record_field_int64 = (stream_read_record_field)tepdata_read_record_field;
+ interface->read_event_field_int64 = (stream_read_event_field) tepdata_read_event_field;
interface->load_entries = tepdata_load_entries;
interface->load_matrix = tepdata_load_matrix;
}
diff --git a/src/libkshark.h b/src/libkshark.h
index 1514f33..c477c70 100644
--- a/src/libkshark.h
+++ b/src/libkshark.h
@@ -17,6 +17,7 @@
#include <string.h>
#include <pthread.h>
#include <errno.h>
+#include <sys/types.h>
// Json-C
#include <json-c/json.h>
diff --git a/src/plugins/sched_events.c b/src/plugins/sched_events.c
index c3a4f47..fc5dc54 100644
--- a/src/plugins/sched_events.c
+++ b/src/plugins/sched_events.c
@@ -14,6 +14,7 @@
#include <stdio.h>
// trace-cmd
+#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <trace-cmd.h>
// KernelShark
--
2.42.0
next reply other threads:[~2023-10-10 19:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-10 19:26 Brahmajit Das [this message]
2023-10-10 22:34 ` [PATCH 1/1] Fix incompatible function pointer types assigning to stream_find_id_func Steven Rostedt
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=20231010192738.166989-1-brahmajit.xyz@gmail.com \
--to=brahmajit.xyz@gmail.com \
--cc=linux-trace-devel@vger.kernel.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).