From patchwork Sat Feb 9 13:42:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 17801 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 288B081C3F; Sat, 9 Feb 2019 14:43:36 +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="P+wUSyWW"; dkim-atps=neutral Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=79.140.41.39; helo=v3-1039.vlinux.de; envelope-from=sven@narfation.org; receiver= Received: from v3-1039.vlinux.de (narfation.org [79.140.41.39]) by open-mesh.org (Postfix) with ESMTPS id 7244581C31 for ; Sat, 9 Feb 2019 14:42:46 +0100 (CET) Received: from sven-desktop.home.narfation.org (p200300C597362EFD0000000000004065.dip0.t-ipconnect.de [IPv6:2003:c5:9736:2efd::4065]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id 9DE3A11014A; Sat, 9 Feb 2019 14:42:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=narfation.org; s=20121; t=1549719764; bh=KFX8WcTKRygttEoZTQkzYiKjWmAn7nE1xk5k0xdG6C8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P+wUSyWWlSdz2GgSpaEPirqr/MKgZU3KQP7XVJH5VmmF1ekMp2niKfGp5HzpvNguz C/kwggzzVbHJZVX+zAPj795cdEtQXgiMQNrTP7FSj1vjdad87aLzremyrKbu39x30m MKvjMn5MSRbt4rur74Tq0F7Neu1xaSgHhw4qrLm0= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Sat, 9 Feb 2019 14:42:22 +0100 Message-Id: <20190209134222.15035-21-sven@narfation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190209134222.15035-1-sven@narfation.org> References: <20190209134222.15035-1-sven@narfation.org> MIME-Version: 1.0 Subject: [B.A.T.M.A.N.] [PATCH v5 20/20] batctl: Drop settings_data 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 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; };