Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2263447ybt; Tue, 16 Jun 2020 01:07:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpysB9QVaxgt5F1DlWuIS6aCi78ahA6LaB21jmZOhKaUJ5qGypfmgFUQD4qjYdEh1WQKPs X-Received: by 2002:a05:6402:1559:: with SMTP id p25mr1460450edx.244.1592294852069; Tue, 16 Jun 2020 01:07:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592294852; cv=none; d=google.com; s=arc-20160816; b=Rg31ZMRy0/YL8e66Y9bnIsdLCNB4q/r3WnsFKLRFD+eEPJstDsZEs3ThDMcxWvRIDU raQOs4VGac88oTPIc1v4er6Yr+6U9eV5u3nDIJYD7iPrM7PhOxUUWuN/wO4wNr6asMBq koR8vePuSbBdkWbj/e1BZPP3/osoOiveKODdTQACKQf1FcuG8/1+JWFhJhQ8/Cpphb/u uOs5Wm7HOFivDp2o4KhvqTuCCgwetYGM7OzjlN6PjnrfcY3NNQiH2njzq06i6ljP6S3P llZnbQB5t6M71vgkDrOKJmEOdAs2UwUkKg3ZqT2E4x0t4Vpd8bzq46zopcQ4Zk39L6xG H/lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=N5tNTqCiCUdiEHc+1FpFehcpPqvoxt/5zWZurJVx0cc=; b=pT/L9IwjuXdqXFZnuX9PonpFziUbvLcCjGCPh3jPingU3+ZgbJuAgyWhTSaFT6IPSC /f9LuVmIfYd25n3jD9+7Jca7Q7Qz7tR88podxtm8rIDR3sbvL4nXF3DtVocm9hM/rY1U BGAKPAAw7FUxI7HupoFPDJ03yeHA5t18wV7/UHqtb4p4vIozYUCCYZm9TyuWZF4Jf/js qduaG9Tgq6mkYhqBwwXdnJT6t7x7GPJ6tqySY+Qi6W97xYiNonRlwRWUtjhAFFyJ03xI TnNudB3ZxJ5zpvZ1djnwvQSVijNtRMfI1XD/WjAfrHp3iuDnSETzVsI3jXOhX/3FDqKo 7GJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yeo3WK8Z; 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 ci9si10333226ejb.218.2020.06.16.01.07.09; Tue, 16 Jun 2020 01:07:32 -0700 (PDT) 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=default header.b=yeo3WK8Z; 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 S1726879AbgFPIFU (ORCPT + 99 others); Tue, 16 Jun 2020 04:05:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:36326 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726112AbgFPIFT (ORCPT ); Tue, 16 Jun 2020 04:05:19 -0400 Received: from devnote2 (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 276DE2074D; Tue, 16 Jun 2020 08:05:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592294719; bh=xS1bz/I8TuJWQXl/b8r7l6ZWj5h9r7ECmLDtJ9PzSgk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=yeo3WK8ZeBdlZV9PyIT6cPW7zKJnQqiFsHfXXJpyg6SBIy5CQRba96zgytf1wqKtx /xNL0V4FTR+y5pUniIQJBR9d3mH+vK1NvVY0sYgJVyrV/5M+pA6zQSE6OCt5MJpP9T eR5PS3LXBKW9KQaENu4vnHy0n3wyLJYHJdt64VBE= Date: Tue, 16 Jun 2020 17:05:16 +0900 From: Masami Hiramatsu To: Steven Rostedt Cc: stable@vger.kernel.org, LKML Subject: Re: [PATCH 1/4] proc/bootconfig: Fix to use correct quotes for value Message-Id: <20200616170516.927d75bd98237466339fca33@kernel.org> In-Reply-To: <20200615151139.5cc223fc@oasis.local.home> References: <159197538852.80267.10091816844311950396.stgit@devnote2> <159197539793.80267.10836787284189465765.stgit@devnote2> <20200615151139.5cc223fc@oasis.local.home> 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 15 Jun 2020 15:11:39 -0400 Steven Rostedt wrote: > On Sat, 13 Jun 2020 00:23:18 +0900 > Masami Hiramatsu wrote: > > > Fix /proc/bootconfig to show the correctly choose the > > double or single quotes according to the value. > > > > If a bootconfig value includes a double quote character, > > we must use single-quotes to quote that value. > > > > Fixes: c1a3c36017d4 ("proc: bootconfig: Add /proc/bootconfig to show boot config list") > > Cc: stable@vger.kernel.org > > Signed-off-by: Masami Hiramatsu > > --- > > fs/proc/bootconfig.c | 13 +++++++++---- > > 1 file changed, 9 insertions(+), 4 deletions(-) > > > > diff --git a/fs/proc/bootconfig.c b/fs/proc/bootconfig.c > > index 9955d75c0585..930d1dae33eb 100644 > > --- a/fs/proc/bootconfig.c > > +++ b/fs/proc/bootconfig.c > > @@ -27,6 +27,7 @@ static int __init copy_xbc_key_value_list(char *dst, size_t size) > > { > > struct xbc_node *leaf, *vnode; > > const char *val; > > + char q; > > char *key, *end = dst + size; > > int ret = 0; > > Hmm, shouldn't the above have the upside-down xmas tree format? > > struct xbc_node *leaf, *vnode; > char *key, *end = dst + size; > const char *val; > char q; > int ret = 0; > > > Looks a little better that way. But anyway, more meat below. OK. > > > > > @@ -41,16 +42,20 @@ static int __init copy_xbc_key_value_list(char *dst, size_t size) > > break; > > dst += ret; > > vnode = xbc_node_get_child(leaf); > > - if (vnode && xbc_node_is_array(vnode)) { > > + if (vnode) { > > xbc_array_for_each_value(vnode, val) { > > - ret = snprintf(dst, rest(dst, end), "\"%s\"%s", > > - val, vnode->next ? ", " : "\n"); > > The above is a functional change that is not described in the change > log. > > You use to have: > > if (vnode && xbc_node_is_array(vnode)) { > xbc_array_for_each_value() { > [..] > } > } else { > [..] > } > > And now have: > > if (vnode) { > xbc_array_for_each_value() { > [..] > } > } else { > [..] > } > > Is "vnode" equivalent to "vnode && xbc_node_is_array(vnode)" ? No, it's not. But actually, the above change is equivalent, because xbc_array_for_each_value() can handle the vnode has no "next" member. (the array means just "a list of value node") Thus, if (vnode && xbc_node_is_array(vnode)) { xbc_array_for_each_value(vnode) /* vnode->next != NULL */ ... } else { snprintf(val); /* val is an empty string if !vnode */ } is equivalent to if (vnode) { xbc_array_for_each_value(vnode) /* vnode->next can be NULL */ ... } else { snprintf(""); } > > Why was this change made? It seems out of scope with the change log? Because I want to avoid checking double-quote in each value in 2 places. If we don't change the if() code, we need if (strchr(val, '"')) q = '\''; else q = '"'; this in 2 places. Anyway, I'll add it in the patch comment. Thank you, > > -- Steve > > > > + if (strchr(val, '"')) > > + q = '\''; > > + else > > + q = '"'; > > + ret = snprintf(dst, rest(dst, end), "%c%s%c%s", > > + q, val, q, vnode->next ? ", " : "\n"); > > if (ret < 0) > > goto out; > > dst += ret; > > } > > } else { > > - ret = snprintf(dst, rest(dst, end), "\"%s\"\n", val); > > + ret = snprintf(dst, rest(dst, end), "\"\"\n"); > > if (ret < 0) > > break; > > dst += ret; > -- Masami Hiramatsu