From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by mail19.linbit.com (LINBIT Mail Daemon) with ESMTP id DFA9E420302 for ; Thu, 4 Jun 2020 16:56:43 +0200 (CEST) Received: by mail-pg1-f193.google.com with SMTP id u5so3568653pgn.5 for ; Thu, 04 Jun 2020 07:56:43 -0700 (PDT) Date: Thu, 4 Jun 2020 07:56:40 -0700 From: Kees Cook To: Miguel Ojeda Message-ID: <202006040745.525ECD1@keescook> References: <20200603233203.1695403-2-keescook@chromium.org> <874krr8dps.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Cc: clang-built-linux , linux-ide@vger.kernel.org, Network Development , "maintainer:X86 ARCHITECTURE \(32-BIT AND 64-BIT\)" , linux-wireless , linux-kernel , linux-spi@vger.kernel.org, linux-block@vger.kernel.org, Andy Whitcroft , Linux-MM , Alexander Potapenko , b43-dev@lists.infradead.org, Joe Perches , Thomas Gleixner , Linus Torvalds , linux-clk@vger.kernel.org, drbd-dev@lists.linbit.com Subject: Re: [Drbd-dev] [PATCH 01/10] x86/mm/numa: Remove uninitialized_var() usage List-Id: "*Coordination* of development, patches, contributions -- *Questions* \(even to developers\) go to drbd-user, please." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Thu, Jun 04, 2020 at 01:41:07PM +0200, Miguel Ojeda wrote: > On Thu, Jun 4, 2020 at 9:58 AM Thomas Gleixner wrote: > > > > but if we ever lose the 1 then the above will silently compile the code > > within the IS_ENABLED() section out. > > Yeah, I believe `IS_ENABLED()` is only meant for Kconfig symbols, not > macro defs in general. A better option would be `__is_defined()` which > works for defined-to-nothing too. Er? That's not what it looked like to me: #define IS_BUILTIN(option) __is_defined(option) #define IS_ENABLED(option) __or(IS_BUILTIN(option), IS_MODULE(option)) But just to be sure, I just tested in with a real build: [ 3.242160] IS_ENABLED(TEST_UNDEF) false [ 3.242691] __is_defined(TEST_UNDEF) false [ 3.243240] IS_ENABLED(TEST_VALUE_EMPTY) false [ 3.243794] __is_defined(TEST_VALUE_EMPTY) false [ 3.244353] IS_ENABLED(TEST_VALUE_1) true [ 3.244848] __is_defined(TEST_VALUE_1) true and nope, it only works with a defined value present. diff --git a/init/main.c b/init/main.c index 03371976d387..378a9e54b6dc 100644 --- a/init/main.c +++ b/init/main.c @@ -1406,6 +1406,34 @@ static int __ref kernel_init(void *unused) */ pti_finalize(); +#undef TEST_UNDEF + if (IS_ENABLED(TEST_UNDEF)) + pr_info("IS_ENABLED(TEST_UNDEF) true\n"); + else + pr_info("IS_ENABLED(TEST_UNDEF) false\n"); + if (__is_defined(TEST_UNDEF)) + pr_info("__is_defined(TEST_UNDEF) true\n"); + else + pr_info("__is_defined(TEST_UNDEF) false\n"); +#define TEST_VALUE_EMPTY + if (IS_ENABLED(TEST_VALUE_EMPTY)) + pr_info("IS_ENABLED(TEST_VALUE_EMPTY) true\n"); + else + pr_info("IS_ENABLED(TEST_VALUE_EMPTY) false\n"); + if (__is_defined(TEST_VALUE_EMPTY)) + pr_info("__is_defined(TEST_VALUE_EMPTY) true\n"); + else + pr_info("__is_defined(TEST_VALUE_EMPTY) false\n"); +#define TEST_VALUE_1 1 + if (IS_ENABLED(TEST_VALUE_1)) + pr_info("IS_ENABLED(TEST_VALUE_1) true\n"); + else + pr_info("IS_ENABLED(TEST_VALUE_1) false\n"); + if (__is_defined(TEST_VALUE_1)) + pr_info("__is_defined(TEST_VALUE_1) true\n"); + else + pr_info("__is_defined(TEST_VALUE_1) false\n"); + system_state = SYSTEM_RUNNING; numa_default_policy(); which means a few other __is_defined() users are not correct too... -- Kees Cook