[v5,20/20] batctl: Drop settings_data param lists

Message ID 20190209134222.15035-21-sven@narfation.org (mailing list archive)
State Accepted, archived
Delegated to: Simon Wunderlich
Headers
Series batctl: netlink restructuring, part 3 |

Commit Message

Sven Eckelmann Feb. 9, 2019, 1:42 p.m. UTC
  The parsing and validation of the settings command parameters is handled by
the parse function. The params struct member is therefore no longer used
and can just be dropped.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 sys.c | 32 --------------------------------
 sys.h |  3 ---
 2 files changed, 35 deletions(-)
  

Patch

diff --git a/sys.c b/sys.c
index 26c191d..9a7966f 100644
--- a/sys.c
+++ b/sys.c
@@ -39,14 +39,6 @@ 
 #include "functions.h"
 #include "debug.h"
 
-const char *sysfs_param_enable[] = {
-	"enable",
-	"disable",
-	"1",
-	"0",
-	NULL,
-};
-
 int parse_simple_boolean(struct state *state, int argc, char *argv[])
 {
 	struct settings_data *settings = state->cmd->arg;
@@ -216,7 +208,6 @@  int handle_sys_setting(struct state *state, int argc, char **argv)
 	struct settings_data *settings = state->cmd->arg;
 	int optchar, res = EXIT_FAILURE;
 	char *path_buff;
-	const char **ptr;
 
 	while ((optchar = getopt(argc, argv, "h")) != -1) {
 		switch (optchar) {
@@ -261,29 +252,6 @@  int handle_sys_setting(struct state *state, int argc, char **argv)
 		}
 	}
 
-	if (!settings->params)
-		goto write_file;
-
-	ptr = settings->params;
-	while (*ptr) {
-		if (strcmp(*ptr, argv[1]) == 0)
-			goto write_file;
-
-		ptr++;
-	}
-
-	fprintf(stderr, "Error - the supplied argument is invalid: %s\n", argv[1]);
-	fprintf(stderr, "The following values are allowed:\n");
-
-	ptr = settings->params;
-	while (*ptr) {
-		fprintf(stderr, " * %s\n", *ptr);
-		ptr++;
-	}
-
-	goto out;
-
-write_file:
 	res = sys_write_setting(state, path_buff, settings->sysfs_name, argc,
 				argv);
 
diff --git a/sys.h b/sys.h
index 5d0ff1e..50f82e0 100644
--- a/sys.h
+++ b/sys.h
@@ -43,15 +43,12 @@ 
 
 struct settings_data {
 	const char *sysfs_name;
-	const char **params;
 	void *data;
 	int (*parse)(struct state *state, int argc, char *argv[]);
 	int (*netlink_get)(struct state *state);
 	int (*netlink_set)(struct state *state);
 };
 
-extern const char *sysfs_param_enable[];
-
 struct simple_boolean_data {
 	bool val;
 };