Skip to contentSkip to conversation

kernel-shark: Do not hard-code app name

PATCH New Yordan Karadzhov (VMware) 1 participant 2 messages Apr 11, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 kernel-shark: Do not hard-code app name

Instead, use 'cmakedefine' the export the corresponding Cmake build variable.

---
 build/deff.h.cmake  | 3 +++
 src/kernelshark.cpp | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)
build/deff.h.cmake +3 -0
index 82379df..4302f00 100644
@@ -11,6 +11,9 @@
 /** KernelShark Version number. */
 #cmakedefine KS_VERSION_STRING "@KS_VERSION_STRING@"
 
+/** KernelShark Application name. */
+#cmakedefine KS_APP_NAME "@KS_APP_NAME@"
+
 /** KernelShark installation prefix path. */
 #cmakedefine _INSTALL_PREFIX "@_INSTALL_PREFIX@"
 
src/kernelshark.cpp +1 -1
index c373f54..1ad15f4 100644
@@ -56,7 +56,7 @@ int main(int argc, char **argv)
 	int c;
 
 	QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
-	QApplication::setDesktopFileName("kernelshark");
+	QApplication::setDesktopFileName(KS_APP_NAME);
 	QApplication a(argc, argv);
 
 	KsMainWindow ks;
Signature · 1 line
2.32.0
#1 lore raw

PATCH 2/2 kernel-shark: Fix memory corruption in KsCaptureDialog

The list of local plugins, returned by tracefs_tracers() must be freed using tracefs_list_free().

---
 src/KsCaptureDialog.cpp | 6 ++----
 src/libkshark-tepdata.c | 5 +++++
 src/libkshark-tepdata.h | 2 ++
 3 files changed, 9 insertions(+), 4 deletions(-)
src/KsCaptureDialog.cpp +2 -4
index ca4c2bc..651f811 100644
@@ -222,12 +222,10 @@ QStringList KsCaptureControl::_getPlugins()
 	if (!all_tracers)
 		return pluginList;
 
-	for (int i = 0; all_tracers[i]; ++i) {
+	for (int i = 0; all_tracers[i]; ++i)
 		pluginList << all_tracers[i];
-		free(all_tracers[i]);
-	}
 
-	free(all_tracers);
+	kshark_tracecmd_plugin_list_free(all_tracers);
 	std::sort(pluginList.begin(), pluginList.end());
 
 	return pluginList;
src/libkshark-tepdata.c +5 -0
index 08aca09..b435a29 100644
@@ -1724,6 +1724,11 @@ char **kshark_tracecmd_local_plugins()
 	return tracefs_tracers(tracefs_tracing_dir());
 }
 
+void kshark_tracecmd_plugin_list_free(char **list)
+{
+	tracefs_list_free(list);
+}
+
 /**
  * @brief Free an array, allocated by kshark_tracecmd_get_hostguest_mapping() API
  *
src/libkshark-tepdata.h +2 -0
index 1b955be..c67c06b 100644
@@ -51,6 +51,8 @@ void kshark_tep_filter_reset(struct kshark_data_stream *stream);
 
 char **kshark_tracecmd_local_plugins();
 
+void kshark_tracecmd_plugin_list_free(char **list);
+
 struct tep_handle;
 
 struct tep_handle *kshark_get_tep(struct kshark_data_stream *stream);
Signature · 1 line
2.32.0