diff mbox series

[6/6] libtracefs sqlhist: Report errors executing the commands

Message ID 20220606192953.334315-7-rostedt@goodmis.org (mailing list archive)
State Accepted
Commit e8e2aeafdb1727c6b6b4b955114629da7ada62cd
Headers show
Series libtracefs: Fixes for sqlhist | expand

Commit Message

Steven Rostedt June 6, 2022, 7:29 p.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

If the -e option is set and the parsing succeeds but the executing does
not, sqlhist exits with success. It should instead check the return of the
creation of the histogram or synthetic event and return the error message
on failure and not succeed.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 Documentation/libtracefs-sql.txt | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/Documentation/libtracefs-sql.txt b/Documentation/libtracefs-sql.txt
index 5e48baa4da39..6d606dbcaf88 100644
--- a/Documentation/libtracefs-sql.txt
+++ b/Documentation/libtracefs-sql.txt
@@ -407,8 +407,13 @@  static int do_sql(const char *instance_name,
 			}
 		}
 		tracefs_synth_echo_cmd(&seq, synth);
-		if (execute)
-			tracefs_synth_create(synth);
+		if (execute) {
+			ret = tracefs_synth_create(synth);
+			if (ret < 0) {
+				fprintf(stderr, "%s\n", tracefs_error_last(NULL));
+				exit(-1);
+			}
+		}
 	} else {
 		struct tracefs_instance *instance = NULL;
 		struct tracefs_hist *hist;
@@ -430,8 +435,13 @@  static int do_sql(const char *instance_name,
 			}
 		}
 		tracefs_hist_echo_cmd(&seq, instance, hist, 0);
-		if (execute)
-			tracefs_hist_start(instance, hist);
+		if (execute) {
+			ret = tracefs_hist_start(instance, hist);
+			if (ret < 0) {
+				fprintf(stderr, "%s\n", tracefs_error_last(instance));
+				exit(-1);
+			}
+		}
 	}
 
 	tracefs_synth_free(synth);