Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp688635yba; Wed, 24 Apr 2019 08:04:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqz9+SoZwrxF0VMyOy21FhKRpNYJMHdmzbXuaJZqSJF9HGZ63LRrMQdtgAyO+3XFNdIBD4Oo X-Received: by 2002:a63:af0a:: with SMTP id w10mr31150433pge.67.1556118265641; Wed, 24 Apr 2019 08:04:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556118265; cv=none; d=google.com; s=arc-20160816; b=LyP8S9zvhbD7legYyHXtmzCfyqtRZoSPwOqwOnvwA2LbvosyE5MsG6uHosyBa9Yzce hQuHlpnkY0c81Wpr2/qIOQbRw0hQxBFdE196uPi1rFcrZDeE9i1/VS1nC7AHn/HcLRl7 6xc1yiA8b5C32LRdghmkbSvfhljc5rCzp9vPqScGIaCPIE2XsAT+wlgxjZ9TfAGJMe9L z5zSyXH/3XNGxrwVgiBTJE3rtA5IWyPvMb93Z/rUoaRx8kiT3PQyoanC1T4gD9FYdE/Q cC48nOBeGZKQUcZQmR8TPNKo10GIOqBpDxwO0WVMTi57QUmjYsftgTJGWMBuYXfNfhlQ BMUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=XKLrqEHsZgkXKIFnNrEflMfVKn1F3tCXT6JyQm68SoI=; b=OUcXbAKrRc60r9NB4vlhkoD3/+OaRvykCulhptDYKK9G0c53LNVGSrDLauNRFszvln EQRQvDEtRBGstkcdOGbqKfu2/93B/gCtYC9X3ngfcq0gDq7ucm+ECsi1qb2Gm1cxy11s vlxKfvC4cG2DJuO5chJ8Axpr4OH5SFjWycGcdFU479CydQaznRAIXcmoD4YdGUOPHDwy +87dDAaPsEhYKDM3VMcHjbYpQkdT09E5uPnxRQkEXyXWpYh6DJwJNqLHaIh8nDntAkCN JCDwlgXDg3gU6v/zvkhurcEqid1bGoCSQyOTHCId4H5okzw4yNCRirrYUBzsn4DawS/R KGrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=gjdWXS4s; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n12si19254845plp.223.2019.04.24.08.04.08; Wed, 24 Apr 2019 08:04:25 -0700 (PDT) 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; dkim=pass header.i=@chromium.org header.s=google header.b=gjdWXS4s; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730873AbfDXPDB (ORCPT + 99 others); Wed, 24 Apr 2019 11:03:01 -0400 Received: from mail-vs1-f67.google.com ([209.85.217.67]:44795 "EHLO mail-vs1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730727AbfDXPC7 (ORCPT ); Wed, 24 Apr 2019 11:02:59 -0400 Received: by mail-vs1-f67.google.com with SMTP id j184so10554918vsd.11 for ; Wed, 24 Apr 2019 08:02:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XKLrqEHsZgkXKIFnNrEflMfVKn1F3tCXT6JyQm68SoI=; b=gjdWXS4sz7Pz4Pb7GPMmkRX5Ad+ejIXPsRs+APt+HPnLgpYvEPZXoFQpv/N/f8rnnE ostLMHeZOpMFVt04Tf4VwDP7Hu+SaKLO9Q0VSQe131BuZ6o6Lxb0EH53o1PIKMcLLQEB X79E3KwNfQqvNNgvbmjrNG4ozxnQAbm0nYhUY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=XKLrqEHsZgkXKIFnNrEflMfVKn1F3tCXT6JyQm68SoI=; b=aKw6r2PsKg+gG1pdLr1U0zqljDrVaaF7ESqeyeiDYuQkPtOgtoeA2BRF2rqpJjQCkV pAzhQOX86ZOBlDL1CXla4gcREfmi4v7SGAPvgx7nGX1178uDLsejQrp/+BRPrFhvbiRA 56GV6mEq9UpDVVzHgLbvx1GLpGZHoFpvurKA4kGF+ZGIOimTf8jzpa/aHAeuWnG61UwL /vHdFUT7EIfFq0K+7yAIaU7HZ5T2Xd0kwWT+MV+KxA0Uiw56l6GQa+qk4s5nMkMwspDK z8mUED8pp/8GKF8aPXpRkFEa0y3TSdfpMRqY3vDpI+vHFzR/ZTIxwL8tZtsY87sUPYNC g7Nw== X-Gm-Message-State: APjAAAV89Oyz6b9ZEt9Zff1bi2YEzqfPvnbDClr/GwZoEMaFkDTUtKKC /tBMEAFo2p4f8kOTY7sMQP2H5yt1aQ0= X-Received: by 2002:a67:e407:: with SMTP id d7mr16801817vsf.212.1556118178309; Wed, 24 Apr 2019 08:02:58 -0700 (PDT) Received: from mail-vk1-f173.google.com (mail-vk1-f173.google.com. [209.85.221.173]) by smtp.gmail.com with ESMTPSA id i2sm3402748vsp.7.2019.04.24.08.02.57 for (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Wed, 24 Apr 2019 08:02:57 -0700 (PDT) Received: by mail-vk1-f173.google.com with SMTP id q189so4088642vkq.11 for ; Wed, 24 Apr 2019 08:02:57 -0700 (PDT) X-Received: by 2002:a1f:3458:: with SMTP id b85mr16977824vka.4.1556118176584; Wed, 24 Apr 2019 08:02:56 -0700 (PDT) MIME-Version: 1.0 References: <1556107369-7655-1-git-send-email-alex.popov@linux.com> In-Reply-To: <1556107369-7655-1-git-send-email-alex.popov@linux.com> From: Kees Cook Date: Wed, 24 Apr 2019 08:02:45 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [v2 1/1] kconfig: Terminate menu blocks with a comment in the generated config To: Alexander Popov Cc: Masahiro Yamada , Michal Marek , linux-kbuild , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 24, 2019 at 5:03 AM Alexander Popov wrote: > > Currently menu blocks start with a pretty header but end with nothing in > the generated config. So next config options stick together with the > options from the menu block. > > Let's terminate menu blocks in the generated config with a comment and > a newline if needed. Example: > > ... > CONFIG_BPF_STREAM_PARSER=y > CONFIG_NET_FLOW_LIMIT=y > > # > # Network testing > # > CONFIG_NET_PKTGEN=y > CONFIG_NET_DROP_MONITOR=y > # end of Network testing > # end of Networking options > > CONFIG_HAMRADIO=y > ... > > Signed-off-by: Alexander Popov Reviewed-by: Kees Cook -Kees > --- > scripts/kconfig/confdata.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c > index 08ba146..486b4c7 100644 > --- a/scripts/kconfig/confdata.c > +++ b/scripts/kconfig/confdata.c > @@ -819,6 +819,7 @@ int conf_write(const char *name) > struct menu *menu; > const char *basename; > const char *str; > + bool need_newline = false; > char dirname[PATH_MAX+1], tmpname[PATH_MAX+22], newname[PATH_MAX+8]; > char *env; > > @@ -871,12 +872,16 @@ int conf_write(const char *name) > "#\n" > "# %s\n" > "#\n", str); > + need_newline = false; > } else if (!(sym->flags & SYMBOL_CHOICE)) { > sym_calc_value(sym); > if (!(sym->flags & SYMBOL_WRITE)) > goto next; > + if (need_newline) { > + fprintf(out, "\n"); > + need_newline = false; > + } > sym->flags &= ~SYMBOL_WRITE; > - > conf_write_symbol(out, sym, &kconfig_printer_cb, NULL); > } > > @@ -888,6 +893,11 @@ int conf_write(const char *name) > if (menu->next) > menu = menu->next; > else while ((menu = menu->parent)) { > + if (!menu->sym && menu_is_visible(menu)) { > + str = menu_get_prompt(menu); > + fprintf(out, "# end of %s\n", str); > + need_newline = true; > + } > if (menu->next) { > menu = menu->next; > break; > -- > 2.7.4 > -- Kees Cook