From patchwork Wed Nov 15 15:17:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hari Bathini X-Patchwork-Id: 838211 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ycSll6QPhz9s7C for ; Thu, 16 Nov 2017 02:21:55 +1100 (AEDT) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3ycSll5ZqKzDqpX for ; Thu, 16 Nov 2017 02:21:55 +1100 (AEDT) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3ycSfd1MgbzDql8 for ; Thu, 16 Nov 2017 02:17:29 +1100 (AEDT) Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) by bilbo.ozlabs.org (Postfix) with ESMTP id 3ycSfc6fJ2z8t1V for ; Thu, 16 Nov 2017 02:17:28 +1100 (AEDT) Received: by ozlabs.org (Postfix) id 3ycSfc5X8Fz9sBW; Thu, 16 Nov 2017 02:17:28 +1100 (AEDT) Delivered-To: linuxppc-dev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=hbathini@linux.vnet.ibm.com; receiver=) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ycSfc11Shz9s7C for ; Thu, 16 Nov 2017 02:17:27 +1100 (AEDT) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vAFFFnJM084415 for ; Wed, 15 Nov 2017 10:17:26 -0500 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 2e8qxbrr8k-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 15 Nov 2017 10:17:24 -0500 Received: from localhost by e06smtp10.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 15 Nov 2017 15:17:21 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp10.uk.ibm.com (192.168.101.140) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 15 Nov 2017 15:17:18 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id vAFFHIBf39321730; Wed, 15 Nov 2017 15:17:18 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4B84B5203F; Wed, 15 Nov 2017 14:10:59 +0000 (GMT) Received: from hbathini.in.ibm.com (unknown [9.79.199.182]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 26BCE5204B; Wed, 15 Nov 2017 14:10:56 +0000 (GMT) Subject: [PATCH v9 2/8] boot/param: add pointer to current and next argument to unknown parameter callback From: Hari Bathini To: linuxppc-dev , Andrew Morton , lkml Date: Wed, 15 Nov 2017 20:47:14 +0530 In-Reply-To: <151075897205.14434.9005256552409420263.stgit@hbathini.in.ibm.com> References: <151075897205.14434.9005256552409420263.stgit@hbathini.in.ibm.com> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17111515-0040-0000-0000-000003EEA90E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17111515-0041-0000-0000-000025F15E9E Message-Id: <151075902585.14434.14102853902713018755.stgit@hbathini.in.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-11-15_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1711150206 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michal =?utf-8?b?U3VjaMOhbmVr?= , Ankit Kumar , Mahesh J Salgaonkar Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Michal Suchanek Add pointer to current and next argument to make parameter processing more robust. This can make parameter processing easier and less error prone in cases where the parameters need to be enforced/ignored based on firmware/system state. Signed-off-by: Michal Suchanek Signed-off-by: Hari Bathini --- Changes in v9: * Fixed messages like below observed while loading modules with no parameters. - iptable_filter: unknown parameter '' ignored - ip_tables: unknown parameter '' ignored include/linux/moduleparam.h | 1 + init/main.c | 8 ++++++-- kernel/module.c | 5 +++-- kernel/params.c | 18 ++++++++++++------ lib/dynamic_debug.c | 1 + 5 files changed, 23 insertions(+), 10 deletions(-) diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index 1d7140f..50a19e6 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h @@ -328,6 +328,7 @@ extern char *parse_args(const char *name, s16 level_max, void *arg, int (*unknown)(char *param, char *val, + char *currant, char *next, const char *doing, void *arg)); /* Called by module remove. */ diff --git a/init/main.c b/init/main.c index 3bdd8da..3ba3eed 100644 --- a/init/main.c +++ b/init/main.c @@ -241,6 +241,7 @@ early_param("loglevel", loglevel); /* Change NUL term back to "=", to make "param" the whole string. */ static int __init repair_env_string(char *param, char *val, + char *unused3, char *unused2, const char *unused, void *arg) { if (val) { @@ -259,6 +260,7 @@ static int __init repair_env_string(char *param, char *val, /* Anything after -- gets handed straight to init. */ static int __init set_init_arg(char *param, char *val, + char *unused3, char *unused2, const char *unused, void *arg) { unsigned int i; @@ -266,7 +268,7 @@ static int __init set_init_arg(char *param, char *val, if (panic_later) return 0; - repair_env_string(param, val, unused, NULL); + repair_env_string(param, val, unused3, unused2, unused, NULL); for (i = 0; argv_init[i]; i++) { if (i == MAX_INIT_ARGS) { @@ -284,9 +286,10 @@ static int __init set_init_arg(char *param, char *val, * unused parameters (modprobe will find them in /proc/cmdline). */ static int __init unknown_bootoption(char *param, char *val, + char *unused3, char *unused2, const char *unused, void *arg) { - repair_env_string(param, val, unused, NULL); + repair_env_string(param, val, unused3, unused2, unused, NULL); /* Handle obsolete-style parameters */ if (obsolete_checksetup(param)) @@ -438,6 +441,7 @@ static noinline void __ref rest_init(void) /* Check for early params. */ static int __init do_early_param(char *param, char *val, + char *unused3, char *unused2, const char *unused, void *arg) { const struct obs_kernel_param *p; diff --git a/kernel/module.c b/kernel/module.c index 32c2cda..ffe7520 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -3619,8 +3619,9 @@ static int prepare_coming_module(struct module *mod) return 0; } -static int unknown_module_param_cb(char *param, char *val, const char *modname, - void *arg) +static int unknown_module_param_cb(char *param, char *val, + char *unused, char *unused2, + const char *modname, void *arg) { struct module *mod = arg; int ret; diff --git a/kernel/params.c b/kernel/params.c index cc9108c..69ff58e 100644 --- a/kernel/params.c +++ b/kernel/params.c @@ -119,6 +119,8 @@ static void param_check_unsafe(const struct kernel_param *kp) static int parse_one(char *param, char *val, + char *currant, + char *next, const char *doing, const struct kernel_param *params, unsigned num_params, @@ -126,7 +128,8 @@ static int parse_one(char *param, s16 max_level, void *arg, int (*handle_unknown)(char *param, char *val, - const char *doing, void *arg)) + char *currant, char *next, + const char *doing, void *arg)) { unsigned int i; int err; @@ -153,7 +156,7 @@ static int parse_one(char *param, if (handle_unknown) { pr_debug("doing %s: %s='%s'\n", doing, param, val); - return handle_unknown(param, val, doing, arg); + return handle_unknown(param, val, currant, next, doing, arg); } pr_debug("Unknown argument '%s'\n", param); @@ -169,9 +172,10 @@ char *parse_args(const char *doing, s16 max_level, void *arg, int (*unknown)(char *param, char *val, + char *currant, char *next, const char *doing, void *arg)) { - char *param, *val, *err = NULL; + char *param, *val, *next, *err = NULL; /* Chew leading spaces */ args = skip_spaces(args); @@ -179,16 +183,18 @@ char *parse_args(const char *doing, if (*args) pr_debug("doing %s, parsing ARGS: '%s'\n", doing, args); - while (*args) { + next = next_arg(args, ¶m, &val); + while (*next) { int ret; int irq_was_disabled; - args = next_arg(args, ¶m, &val); + args = next; + next = next_arg(args, ¶m, &val); /* Stop at -- */ if (!val && strcmp(param, "--") == 0) return err ?: args; irq_was_disabled = irqs_disabled(); - ret = parse_one(param, val, doing, params, num, + ret = parse_one(param, val, args, next, doing, params, num, min_level, max_level, arg, unknown); if (irq_was_disabled && !irqs_disabled()) pr_warn("%s: option '%s' enabled irq's!\n", diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index da796e2..dec7f40 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -889,6 +889,7 @@ static int ddebug_dyndbg_param_cb(char *param, char *val, /* handle both dyndbg and $module.dyndbg params at boot */ static int ddebug_dyndbg_boot_param_cb(char *param, char *val, + char *unused3, char *unused2, const char *unused, void *arg) { vpr_info("%s=\"%s\"\n", param, val);