From patchwork Tue Aug 16 05:20:20 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Lacombe X-Patchwork-Id: 1070312 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p7G5KZag013126 for ; Tue, 16 Aug 2011 05:20:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752414Ab1HPFUd (ORCPT ); Tue, 16 Aug 2011 01:20:33 -0400 Received: from mail-yx0-f174.google.com ([209.85.213.174]:59724 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752176Ab1HPFUc (ORCPT ); Tue, 16 Aug 2011 01:20:32 -0400 Received: by yxj19 with SMTP id 19so3556331yxj.19 for ; Mon, 15 Aug 2011 22:20:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=ZOE7srMV7u8tjwQj6704gSH7/qeYbNguJNYMKUnDTFg=; b=trGfdvBQ2kDYPV/cOOO96wDBXdcGVdm0p1hVhpWVobPU1N3z/7dZ7FP4ZzGjvlHSBK U0chnLULPMDvsulpFkN3EByT5Eubj9/+od+4GhGwW/tdy7KFKjSwqfTYUXkSLjVvs5fr eFkpsJNNgToIWNyyWAsioblqtBWAAByERUhkQ= Received: by 10.146.213.8 with SMTP id l8mr4630045yag.36.1313472032005; Mon, 15 Aug 2011 22:20:32 -0700 (PDT) Received: from localhost.localdomain (69-165-142-232.dsl.teksavvy.com [69.165.142.232]) by mx.google.com with ESMTPS id e21sm651319yhn.35.2011.08.15.22.20.30 (version=SSLv3 cipher=OTHER); Mon, 15 Aug 2011 22:20:31 -0700 (PDT) From: Arnaud Lacombe To: linux-kbuild@vger.kernel.org Cc: rabin@rab.in, Arnaud Lacombe Subject: [PATCH] kconfig: fix __enabled_ macros definition for invisible and un-selected symbols Date: Tue, 16 Aug 2011 01:20:20 -0400 Message-Id: <1313472020-14018-1-git-send-email-lacombar@gmail.com> X-Mailer: git-send-email 1.7.6.153.g78432 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Tue, 16 Aug 2011 05:20:35 +0000 (UTC) __enabled_ are only generated on visible or selected entries, do not reflect the purpose of its introduction. Fix this by always generating these entries for named symbol. Reported-by: Rabin Vincent Signed-off-by: Arnaud Lacombe --- scripts/kconfig/confdata.c | 49 ++++++++++++++++++++++++++++++++----------- 1 files changed, 36 insertions(+), 13 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 59b667c..5a58965 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -503,17 +503,6 @@ header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) fprintf(fp, "#define %s%s%s 1\n", CONFIG_, sym->name, suffix); } - /* - * Generate the __enabled_CONFIG_* and - * __enabled_CONFIG_*_MODULE macros for use by the - * IS_{ENABLED,BUILTIN,MODULE} macros. The _MODULE variant is - * generated even for booleans so that the IS_ENABLED() macro - * works. - */ - fprintf(fp, "#define __enabled_" CONFIG_ "%s %d\n", - sym->name, (*value == 'y')); - fprintf(fp, "#define __enabled_" CONFIG_ "%s_MODULE %d\n", - sym->name, (*value == 'm')); break; } case S_HEX: { @@ -565,6 +554,35 @@ static struct conf_printer header_printer_cb = }; /* + * Generate the __enabled_CONFIG_* and __enabled_CONFIG_*_MODULE macros for + * use by the IS_{ENABLED,BUILTIN,MODULE} macros. The _MODULE variant is + * generated even for booleans so that the IS_ENABLED() macro works. + */ +static void +header_print__enabled_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) +{ + + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: { + fprintf(fp, "#define __enabled_" CONFIG_ "%s %d\n", + sym->name, (*value == 'y')); + fprintf(fp, "#define __enabled_" CONFIG_ "%s_MODULE %d\n", + sym->name, (*value == 'm')); + break; + } + default: + break; + } +} + +static struct conf_printer header__enabled_printer_cb = +{ + .print_symbol = header_print__enabled_symbol, + .print_comment = header_print_comment, +}; + +/* * Tristate printer * * This printer is used when generating the `include/config/tristate.conf' file. @@ -945,11 +963,16 @@ int conf_write_autoconf(void) conf_write_heading(out_h, &header_printer_cb, NULL); for_all_symbols(i, sym) { + if (!sym->name) + continue; + sym_calc_value(sym); - if (!(sym->flags & SYMBOL_WRITE) || !sym->name) + + conf_write_symbol(out_h, sym, &header__enabled_printer_cb, NULL); + + if (!(sym->flags & SYMBOL_WRITE)) continue; - /* write symbol to auto.conf, tristate and header files */ conf_write_symbol(out, sym, &kconfig_printer_cb, (void *)1); conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1);