[RFC,v4,20/20] batctl: Drop settings_date param lists

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

Commit Message

Sven Eckelmann Dec. 7, 2018, 8:32 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 ede8b09..a53b419 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 f32f134..e7d227d 100644
--- a/sys.h
+++ b/sys.h
@@ -49,15 +49,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;
 };