diff mbox series

[3/5] KernelShark: Fix combo plot plugin crash in case of multiple streams

Message ID 20200727071823.169962-4-tz.stoyanov@gmail.com (mailing list archive)
State New
Headers show
Series Add support for opening trace.dat files with multuiple buffers | expand

Commit Message

Tzvetomir Stoyanov (VMware) July 27, 2020, 7:18 a.m. UTC
From: Tzvetomir (VMware)  Stoyanov <tz.stoyanov@gmail.com>

Added a check if there is a host-guest mapping in the loaded
multiple streams. If there is no such mapping, print an error and
exit the KsComboPlotDialog::update() function.

Signed-off-by: Tzvetomir (VMware)  Stoyanov <tz.stoyanov@gmail.com>
---
 src/plugins/KVMCombo.cpp | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Steven Rostedt July 28, 2020, 1:26 p.m. UTC | #1
On Mon, 27 Jul 2020 10:18:21 +0300
"Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com> wrote:

> From: Tzvetomir (VMware)  Stoyanov <tz.stoyanov@gmail.com>
> 
> Added a check if there is a host-guest mapping in the loaded
> multiple streams. If there is no such mapping, print an error and
> exit the KsComboPlotDialog::update() function.
> 
> Signed-off-by: Tzvetomir (VMware)  Stoyanov <tz.stoyanov@gmail.com>
> ---
>  src/plugins/KVMCombo.cpp | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/src/plugins/KVMCombo.cpp b/src/plugins/KVMCombo.cpp
> index ceb1f47..3ec36b6 100644
> --- a/src/plugins/KVMCombo.cpp
> +++ b/src/plugins/KVMCombo.cpp
> @@ -246,7 +246,12 @@ void KsComboPlotDialog::update()
>  	_guestMap = nullptr;
>  	_guestMapCount = 0;
>  	ret = kshark_tracecmd_get_hostguest_mapping(&_guestMap);
> -	if (ret > 0)
> +	if (ret <= 0) {
> +		QString err("Cannot find host / guest tracing into the loaded streams");
> +		QMessageBox msgBox;
> +		msgBox.critical(nullptr, "Error", err);
> +		return;
> +	} else
>  		_guestMapCount = ret;
>

Just a nit, but if we are following Linux coding styles, the above
should be:

	if (ret <= 0) {
		[..]
	} else {
		_guestMapCount = ret;
	}

As it is looked down upon to have part of an if block have brackets and
another part without. But I'll leave that up to Yordan to decide ;-)

Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>


-- Steve
 
>  	KsUtils::setElidedText(&_hostFileLabel,
diff mbox series

Patch

diff --git a/src/plugins/KVMCombo.cpp b/src/plugins/KVMCombo.cpp
index ceb1f47..3ec36b6 100644
--- a/src/plugins/KVMCombo.cpp
+++ b/src/plugins/KVMCombo.cpp
@@ -246,7 +246,12 @@  void KsComboPlotDialog::update()
 	_guestMap = nullptr;
 	_guestMapCount = 0;
 	ret = kshark_tracecmd_get_hostguest_mapping(&_guestMap);
-	if (ret > 0)
+	if (ret <= 0) {
+		QString err("Cannot find host / guest tracing into the loaded streams");
+		QMessageBox msgBox;
+		msgBox.critical(nullptr, "Error", err);
+		return;
+	} else
 		_guestMapCount = ret;
 
 	KsUtils::setElidedText(&_hostFileLabel,