Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp6384498pxu; Thu, 24 Dec 2020 00:23:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJz0mwAN68+J3ZCxfJg6Fm4AhEKaryDefHmXhV+Cf3caCHFY8sxKKEIE12OZpgAZK3Grk+tq X-Received: by 2002:a50:ee1a:: with SMTP id g26mr27947677eds.68.1608798203857; Thu, 24 Dec 2020 00:23:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608798203; cv=none; d=google.com; s=arc-20160816; b=RBhJCUHSpUZBggfp8eHwak8ZFIWZAM7VKSO5DVCgaF4uLWOWcNlCjLTtmePl8ti02z 6z31/n3SA7vEv2U5OY4zqMqoSchnHUmPCwyHO6/l9uQzsHbIqSA+Nn9s/hhP1RgQWtxS pYmLdFLYFief9fv9/clAWJYQTRErNq1yvi0tuyfm1Rg2XGMWAyK4w7QpgqOSttH6aJN1 uTb4OQDma4zU/iq/wPM9+wVePaR40DAO8TASRaqS5B0XAexZpYOZjaPZYD2RK4tyW7R8 7UzlF3tUlR0la+Mmtt5KqEY5cPw6OaSOPZmrb06m7XDipKqjVmYy7Evb2sm2Nj1mB+3I P12Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=DnRdUwiOZJukYi8hU6ilE5IbsGiSnh4i06Ppu2HoMZg=; b=PkILkcTaDn1pE/xUlkBu4UwF8cjz54q9xfe4DF2hO64aZ8S5m3gcvtfjRT+21W53Df xwinnI+h2hBiA+tqEyJali122dn5HtBfhCOA1HvYZgW3MBr6h7DpVdUwJSQ5pkbe0fJv 2RzHbfkUiAF1DSXMk5+6EPtT+PHRIne6J0WIQrt3+duiwy8aYkueCedHGXnmRiF5icLS QN+xY3afwyCBtCdmEO9Ih8Lux8WIectp3qQRsMFZs4Fo/pfDHM73SjjWrrENhR2nkRku vJSON2rw2rqGfnuNyknCPbn2nZq6yGGxjiNKxHjT/RtQwTbNYlxpU+BwsSW+7ZGZzcRZ ViKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="a7Lzd/7q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e26si927699edv.153.2020.12.24.00.22.59; Thu, 24 Dec 2020 00:23:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="a7Lzd/7q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726342AbgLXIWd (ORCPT + 99 others); Thu, 24 Dec 2020 03:22:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:55342 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725902AbgLXIWc (ORCPT ); Thu, 24 Dec 2020 03:22:32 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7EF0E229CA; Thu, 24 Dec 2020 08:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1608798111; bh=4dRh5dQ6U2WKiejoumD6EOTE1qJAxxffrUTkrxN/FVU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=a7Lzd/7qVa08eOkQCyJ+B86j+/ysxpUd+ZWAoO31L6Dr6HqCjl6apNaC4KxTsoqXQ VDAN0o3b2N3HkCAEteY69NmCpkTk3SsTsNybW7C2zYH+QLllThhRrNM/urbdIExY9e AQBRc6kTBQBL0MSOK5sdNeIizDbmPkutyUyhyu0s21L38Mc28KR0yORMZNc+fXzegc x63rM3EGX3EOChovXH5VxPIvaVVzdmpiqROd9iVlFALwgDlSmGXUk54Kgy4wYQCZln A6NLKDCiws4kbpEjvSvmEo9PEJ8an+9+vNF0ba2Y89oSHgEXSpMT2WYFfH3QCLqmIV 0vtzNiiWqtzlA== Date: Thu, 24 Dec 2020 17:21:47 +0900 From: Masami Hiramatsu To: Tom Zanussi Cc: rostedt@goodmis.org, axelrasmussen@google.com, dan.carpenter@oracle.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 2/5] tracing: Rework synthetic event command parsing Message-Id: <20201224172147.2952b2d20c9a974922a33f6f@kernel.org> In-Reply-To: <48d21108d635e707ef135cac7fa0eaabc1cf5e9a.camel@kernel.org> References: <20201222214259.464311df07a343de821db568@kernel.org> <48d21108d635e707ef135cac7fa0eaabc1cf5e9a.camel@kernel.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 23 Dec 2020 17:17:27 -0600 Tom Zanussi wrote: > Hi Masami, > > On Tue, 2020-12-22 at 21:42 +0900, Masami Hiramatsu wrote: > > Hi Tom, > > > > On Mon, 21 Dec 2020 15:44:28 -0600 > > Tom Zanussi wrote: > > > > > > > @@ -656,7 +651,6 @@ static struct synth_field > > > *parse_synth_field(int argc, const char **argv, > > > > > > size = synth_field_size(field->type); > > > if (size < 0) { > > > - synth_err(SYNTH_ERR_INVALID_TYPE, errpos(field_type)); > > > > Why did you remove this error message? > > It wasn't actually removed - it was just moved into the next patch, so > is still there. I'll move it back here to avoid confusion. > > > > > [..] > > > @@ -1228,26 +1189,47 @@ static int __create_synth_event(int argc, > > > const char *name, const char **argv) > > > goto out; > > > } > > > > > > - for (i = 0; i < argc - 1; i++) { > > > - if (strcmp(argv[i], ";") == 0) > > > - continue; > > > + tmp_fields = saved_fields = kstrdup(raw_fields, GFP_KERNEL); > > > + if (!tmp_fields) { > > > + ret = -ENOMEM; > > > + goto out; > > > + } > > > + > > > + while ((field_str = strsep(&tmp_fields, ";")) != NULL) { > > > if (n_fields == SYNTH_FIELDS_MAX) { > > > synth_err(SYNTH_ERR_TOO_MANY_FIELDS, 0); > > > ret = -EINVAL; > > > goto err; > > > } > > > > > > - field = parse_synth_field(argc - i, &argv[i], > > > &consumed); > > > + argv = argv_split(GFP_KERNEL, field_str, &argc); > > > + if (!argv) { > > > + ret = -ENOMEM; > > > + goto err; > > > + } > > > + > > > + if (!argc) > > > + continue; > > > + > > > + field = parse_synth_field(argc, argv, &consumed); > > > if (IS_ERR(field)) { > > > + argv_free(argv); > > > ret = PTR_ERR(field); > > > goto err; > > > } > > > + > > > + argv_free(argv); > > > + > > > + if (consumed < argc) { > > > + ret = -EINVAL; > > > + goto err; > > > + } > > > > You can check the consumed < argc in parse_synth_field(), unless > > you keep the backward compatibility - I think you can add an > > inner loop for it, something like > > > > while ((field_str = strsep(&tmp_fields, ";")) != NULL) { > > argv = argv_split(...); > > consumed = 0; > > while (argc > consumed) { > > // increment consumed in parse_synth_field() > > field = parse_synth_field(argc - consumed, argv + consumed, > > &consumed); > > if (IS_ERR(field)) {...} > > > > fields[n_fields++] = field; > > if (n_fields == SYNTH_FIELDS_MAX) {...} > > } > > > > argv_free(argv); > > } > > > > what would you think? > > Hmm, not sure this helps - there's only supposed to be one field per > field_str and consumed returns either 2 or 3 depending on the field. I meant that this can be reused to support older syntax like "myevent int foo unsigned long bar" without inserting semicolons. > consumed is only used to detect whether there were unused words and if > so flag an error, rather than loop around to try to get another field. If you drop the backward compatibility from *this* patch, we can just check the "consumed < argc" in parse_synth_field() and remove "consumed" from this function. Thank you, -- Masami Hiramatsu