Received: by 10.223.164.221 with SMTP id h29csp3093160wrb; Tue, 3 Oct 2017 17:12:49 -0700 (PDT) X-Received: by 10.98.76.70 with SMTP id z67mr18833329pfa.78.1507075969133; Tue, 03 Oct 2017 17:12:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507075969; cv=none; d=google.com; s=arc-20160816; b=L20skpYgal9+T3KXKVijU5/OiEbN5Ultvr1/j7KKnDFNmVtmWiR9tZjwUJol7TMfOL DyTHpa/A9luOnnrUwsTmd+Lp0ywOzJO9myzMt8w6p5RKM+1ZBb+eMNfMdCkEWVs3mXTs aG3pJgkfcvGUJDV1/tZMVC0psL1A7QntO0GdTPOEh8iSWX/WYrJJHPAhX41001oXc/wa +h0YYQJ/1qjc+z0nNnHQsZnxrlz9RsKxuactYT2RP5hiAYYH+qKLJ8G3NNHEIIQwHksT qq1upK6Hc3uLGss0u9aSr80pevgymcAZ+6Hz5Yn++L6eu4C71b3sgFzxTbPtn1rlGaTy rNOQ== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=b8tLGdrM/uGrUTogRYf0Dqg1Wkez8NdlLFUuXymegaE=; b=nCA5npQe2Z7jpDUKdt4GgZwSIu7fU+v4+YdFC4+q0NEgEI9HX6M2+0IovIoWHO+6uW HyWlQarrPbzZFQVXTCce51MfdPUsLl7Ds6ZMmvz5l3BTqh6MvRFDoMqGxqCrq765VZ8M 97FWRkAsIpQIoaU4Xkmuxu1mgoqOM/twP+U7BWAr5DL51TJvgVQrjrJn+01ZajHvwpUV nfXPWgLQNvj4m3GGIRibKjOglchJx9aiOsgEaBYJPcPjW6wkssPZDhwxaIGy2gN8h9Qy raW6GuAuCHLAQ6QMxqqFwZxj/FzIU5b2Q+A9tpY0Wv768GFnuSk3Jy/T5/8QUFoWzjTu Us3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JrAgSeAr; 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=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 67si11190051pla.782.2017.10.03.17.12.34; Tue, 03 Oct 2017 17:12:49 -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=@gmail.com header.s=20161025 header.b=JrAgSeAr; 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=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751238AbdJDALC (ORCPT + 99 others); Tue, 3 Oct 2017 20:11:02 -0400 Received: from mail-ua0-f194.google.com ([209.85.217.194]:37604 "EHLO mail-ua0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750865AbdJDALA (ORCPT ); Tue, 3 Oct 2017 20:11:00 -0400 Received: by mail-ua0-f194.google.com with SMTP id q29so3422329uaf.4; Tue, 03 Oct 2017 17:11:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=b8tLGdrM/uGrUTogRYf0Dqg1Wkez8NdlLFUuXymegaE=; b=JrAgSeAruOPNMNo9JfUPt3TOEVfXhJ+l/3YkgZopa7ApDZ4v3DJEzYavoYrIOM+OBG J0mnhRmk3V3Urj1jN3EAbDbzFbocyrWqdh0sEwhiyU/L+sojYB2ud8d48ukqi9MsukUB 71TzvNyTJgiUiZKbVy3dapOxX7rwY4qhHP2T17/dbL1I9T/dHl1nhg0+VkKLpsjkBmLT JcuKsNjfpmfpot9vfl37gN3IitBEH0TrpIGtsmJVOduKIxdnY+kt2b6C4L2wrZCZLK1h wyJqtPkpQLkZareeG+IjdWIYWCVllENvBD+Evy4oLppcYF6h4z8CPoL3nK6zk+MWjARO 7L6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=b8tLGdrM/uGrUTogRYf0Dqg1Wkez8NdlLFUuXymegaE=; b=RrBFdzpfdc8xns0UJ+o2CcAqZNr+88v7EtxKAZ44tBE2Pu3sS0p0j2eNkGxlgGxTDs W5PefqgvyWe9fzlF/StilupT1Fv0TfR1YHb6hFmz+QVcEtK0ho/swW3tTFTN4TqUPXDn iufR9j6TOMzCQtRgdB1wgJuVJgWDhA4ghfKy/lbNhQ1Smt8tRhm1ZtBEwDJZUyn2G4Ws kVSjpXs5PzHuLoEhNjX5/S2V1iFyKLFiZQxFGu8DSGnBQ5+qbt9hcwebQqvfNH6GETq2 Y3A2tC0ezFBMNuDRpOQO3Lr/WqvRfLwACkwlqpb+d0HGf3G3YOjnMGA7bgf9TACA/Oda DTBg== X-Gm-Message-State: AMCzsaUZKv+DALbmLzcKRp9vsk9+2jzXa9UFf84SqNR5HYuLM/ADhb7b +AnYH6avlGM72fmylq9qmiJIwk4I7DtopkTVMkNd1wxfJYk= X-Google-Smtp-Source: AOwi7QBnsOuvMulkID/2/MxssOoc8mmVNIYsFu3u3hXLaARiXp/d5NYLvH5gwhcKeWbDedoKtJUZ224mNVHPSLty56E= X-Received: by 10.176.93.227 with SMTP id l35mr7542899uag.16.1507075860017; Tue, 03 Oct 2017 17:11:00 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.68.14 with HTTP; Tue, 3 Oct 2017 17:10:59 -0700 (PDT) In-Reply-To: <1507073146-19847-1-git-send-email-ulfalizer@gmail.com> References: <1507073146-19847-1-git-send-email-ulfalizer@gmail.com> From: Ulf Magnusson Date: Wed, 4 Oct 2017 02:10:59 +0200 Message-ID: Subject: Re: [PATCH] kconfig: Warn if choice default is not in choice To: yann.morin.1998@free.fr, linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Ulf Magnusson 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, Oct 4, 2017 at 1:25 AM, Ulf Magnusson wrote: > This will catch mistakes like in the following real-world example, where > a "CONFIG_" prefix snuck in, making an undefined symbol the default: > > choice > prompt "Compiler optimization level" > default CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE > > config CC_OPTIMIZE_FOR_PERFORMANCE > ... > > config CC_OPTIMIZE_FOR_SIZE > ... > > endchoice > > This now prints the following warning: > > init/Kconfig:1036:warning: choice default symbol 'CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE' is not contained in the choice > > Cases where the default symbol belongs to the wrong choice are also > detected. > > (The mistake is harmless here: Since the default symbol is not visible, > the choice falls back on using the first visible symbol as the default, > which is CC_OPTIMIZE_FOR_PERFORMANCE, as intended.) > > Discovered while playing around with Kconfiglib > (https://github.com/ulfalizer/Kconfiglib). > > Signed-off-by: Ulf Magnusson > --- > scripts/kconfig/menu.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c > index e935793..ce88de8 100644 > --- a/scripts/kconfig/menu.c > +++ b/scripts/kconfig/menu.c > @@ -252,6 +252,16 @@ static void sym_check_prop(struct symbol *sym) > "'%s': number is invalid", > sym->name); > } > + if (sym_is_choice(sym)) { > + struct property *choice_prop = > + sym_get_choice_prop(sym2); > + > + if (!choice_prop || > + prop_get_symbol(choice_prop) != sym) > + prop_warn(prop, > + "choice default symbol '%s' is not contained in the choice", > + sym2->name); > + } > break; > case P_SELECT: > case P_IMPLY: > -- > 2.7.4 > A patch to fix the compiler optimization level choice has been submitted as well: https://lkml.org/lkml/2017/10/3/991 Cheers, Ulf From 1580280844694147464@xxx Tue Oct 03 23:27:34 +0000 2017 X-GM-THRID: 1580280844694147464 X-Gmail-Labels: Inbox,Category Forums