Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756508AbdLOUrG (ORCPT ); Fri, 15 Dec 2017 15:47:06 -0500 Received: from mx2.suse.de ([195.135.220.15]:57321 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756423AbdLOUrE (ORCPT ); Fri, 15 Dec 2017 15:47:04 -0500 Date: Fri, 15 Dec 2017 21:47:02 +0100 From: Michal =?UTF-8?B?U3VjaMOhbmVr?= To: Hari Bathini Cc: linuxppc-dev , Andrew Morton , lkml , Ankit Kumar , Mahesh J Salgaonkar Subject: Re: [PATCH v9 2/8] boot/param: add pointer to current and next argument to unknown parameter callback Message-ID: <20171215214702.7c7afba1@kitsune.suse.cz> In-Reply-To: <151075902585.14434.14102853902713018755.stgit@hbathini.in.ibm.com> References: <151075897205.14434.9005256552409420263.stgit@hbathini.in.ibm.com> <151075902585.14434.14102853902713018755.stgit@hbathini.in.ibm.com> Organization: SUSE Linux X-Mailer: Claws Mail 3.15.1-dirty (GTK+ 2.24.31; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1367 Lines: 42 Hello, On Wed, 15 Nov 2017 20:47:14 +0530 Hari Bathini wrote: > 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 > @@ -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 -- */ The [PATCH v8 5/6] you refreshed here moves the while(*next) to the end of the cycle for a reason. Checking *args at the start is mostly equivalent checking *next at the end. Checking *next at the start on the other hand skips the last argument. The "mostly" part is that there is a bug here because *args is not checked at the start of the cycle making it possible to crash if it is 0. To fix that the if(*args) above should be extended to wrap the cycle. Thanks Michal