Received: by 10.223.164.202 with SMTP id h10csp754236wrb; Wed, 15 Nov 2017 07:23:14 -0800 (PST) X-Google-Smtp-Source: AGs4zMZUuOfeSY1uFnVRM1VsdFDMwP6cdo1ob0GYWz5tjsN/ewbfK5maulzVZ4WXjU52ospFcJGE X-Received: by 10.84.172.1 with SMTP id m1mr7607955plb.345.1510759394014; Wed, 15 Nov 2017 07:23:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510759393; cv=none; d=google.com; s=arc-20160816; b=zykrW5uL23Wk12lB37NDsfQif6UtFplZW3vtLuNn6iwBt0gK4rLNt/Rc1TEQ3wmAE7 Dhhk4wcXqbuh2kuFbfcYJ9aaTQvxcWFsdT2K7hE0pzSZyyqI671545ryUKAWO4EK3tQW jl2pXjpvsnEio/fqGr03f/2cAA6aSEn6PY1ujNTeQQpSzvr4L3nPfZ0A/ljz5P0LYhTP eQ4b/UVj65KaKwEQGCtfC5QjIFrqAiZLK0AKqyCgPK0iV5IhN/Ov53NJjwWAEiH22PLy JeKPNkj56G4BRAQeslsSANBFTxXW1BSTK+/tRCfrkEtEJQN+1S2WjleZPm8USGWoFYna XBjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:user-agent:references:in-reply-to:date:cc:to:from :subject:arc-authentication-results; bh=IrApg6d/ntpuZdiR0UB2axi0tg+0KHR8glwlQS079Jk=; b=WJej5mqNpHuSqfz5958YS/gi123IJctuvfHWq5WK8TRGNrgjlAsjNRv0J6mKl9mu4n OAKp1rgeVKaVvN23jjTzRMAXKfXhJ/nof3WFcP2gKlb2bKVUKXV3EP6yWx683hsUukTq C/q7CJyXbbSg129EPoFvMvWw2DnM5eqlX3VZi4LG2cy3Rx01Ta9j4tnH00xljg+hNEmo rBNb6RWrBInIEtwNuGRBMwGhAruy4wn8CWdf38zlzz1HEbpoZA3M1HeueOReN+AgvlEu usdSqaRV9ErD9A8ATPq00lCnqxERxiln3G/jJgSUHxh2xbui1prNLY+72ZpMF2IioRW3 avAA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z2si4458575pll.661.2017.11.15.07.23.01; Wed, 15 Nov 2017 07:23:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758549AbdKOPRi (ORCPT + 89 others); Wed, 15 Nov 2017 10:17:38 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:50668 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1758465AbdKOPRZ (ORCPT ); Wed, 15 Nov 2017 10:17:25 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vAFFFrtD040488 for ; Wed, 15 Nov 2017 10:17:24 -0500 Received: from e06smtp10.uk.ibm.com (e06smtp10.uk.ibm.com [195.75.94.106]) by mx0a-001b2d01.pphosted.com with ESMTP id 2e8pu4cny6-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 15 Nov 2017 10:17:23 -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 Cc: Michael Ellerman , Ankit Kumar , Michal =?utf-8?b?U3VjaMOhbmVr?= , Mahesh J Salgaonkar 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1711150206 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); From 1584180761991488189@xxx Thu Nov 16 00:35:05 +0000 2017 X-GM-THRID: 1584180761991488189 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread