git » libfiu » commit 590a7df

libfiu: Always return error messages on fiu_rc_string()

author Alberto Bertogli
2021-04-19 20:58:21 UTC
committer Alberto Bertogli
2021-04-19 20:58:21 UTC
parent 935ecf090cb3a7b8e5fb91490de240da877becf0

libfiu: Always return error messages on fiu_rc_string()

When executing remote commands, always fill in the error message, so
that the callers can get something more useful than an empty message.

This also makes the fiu-run errors a bit more friendly, as now at least
the user can know which command caused the error.

libfiu/fiu-rc.c +4 -0

diff --git a/libfiu/fiu-rc.c b/libfiu/fiu-rc.c
index 1d3b092..c3e7012 100644
--- a/libfiu/fiu-rc.c
+++ b/libfiu/fiu-rc.c
@@ -175,13 +175,17 @@ int fiu_rc_string(const char *cmd, char ** const error)
 
 	/* Excecute the command */
 	if (strcmp(command, "disable") == 0) {
+		*error = "Error in disable";
 		return fiu_disable(fp_name);
 	} else if (strcmp(command, "enable") == 0) {
+		*error = "Error in enable";
 		return fiu_enable(fp_name, failnum, failinfo, flags);
 	} else if (strcmp(command, "enable_random") == 0) {
+		*error = "Error in enable_random";
 		return fiu_enable_random(fp_name, failnum, failinfo,
 				flags, probability);
 	} else if (strcmp(command, "enable_stack_by_name") == 0) {
+		*error = "Error in enable_stack_by_name";
 		return fiu_enable_stack_by_name(fp_name, failnum, failinfo,
 				flags, func_name, func_pos_in_stack);
 	} else {