From patchwork Fri Dec 7 20:32:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 17708 X-Patchwork-Delegate: sw@simonwunderlich.de Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id 2F76B812BD; Fri, 7 Dec 2018 21:33:31 +0100 (CET) Authentication-Results: open-mesh.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=narfation.org header.i=@narfation.org header.b="Ln2OQGGb"; dkim-atps=neutral Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=2001:4d88:2000:7::2; helo=v3-1039.vlinux.de; envelope-from=sven@narfation.org; receiver= Received: from v3-1039.vlinux.de (narfation.org [IPv6:2001:4d88:2000:7::2]) by open-mesh.org (Postfix) with ESMTPS id DF43F8141C for ; Fri, 7 Dec 2018 21:32:55 +0100 (CET) Received: from sven-desktop.home.narfation.org (p200300C5970891FD0000000000008096.dip0.t-ipconnect.de [IPv6:2003:c5:9708:91fd::8096]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id DEBAB110144; Fri, 7 Dec 2018 21:32:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=narfation.org; s=20121; t=1544214773; bh=Gn2Z4XXRr/H52TIRGRQ1nQs7Z+Vrs2+YnCwG4S02ehE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ln2OQGGb0eOTf89gsIyp4r27wn8o52pyL06Cf/mYvE2OuCU+6DiPi7Tfc/2qmSNYJ ejoLca8LRUS6rN4HFTDFN2fFPMr0MxjxRdHOpRIe85N5S0IY9HhhV+VmB9D2/swF6j lyh8T4ydR+2TXVZgQ5UyVKrLJuMTzYIUj17+6uyA= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Fri, 7 Dec 2018 21:32:09 +0100 Message-Id: <20181207203209.22633-21-sven@narfation.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181207203209.22633-1-sven@narfation.org> References: <20181207203209.22633-1-sven@narfation.org> MIME-Version: 1.0 Subject: [B.A.T.M.A.N.] [RFC v4 20/20] batctl: Drop settings_date param lists X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "B.A.T.M.A.N" 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 --- sys.c | 32 -------------------------------- sys.h | 3 --- 2 files changed, 35 deletions(-) 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; };