Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2562521imu; Mon, 19 Nov 2018 02:33:37 -0800 (PST) X-Google-Smtp-Source: AJdET5f07AblPXR95mC4ImNjr4wergRFZXM0VydzR4EfXmKp2AUQZPL0LezNcQD5e2Qgoisk2ORO X-Received: by 2002:a17:902:b68d:: with SMTP id c13mr21811785pls.102.1542623617858; Mon, 19 Nov 2018 02:33:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542623617; cv=none; d=google.com; s=arc-20160816; b=y/0oq/wOXy4eRXrco4/riHhpHKgAR6CHmkEGMo8CUh0K+WqPNrbDXdad0o9lSrLRIG pJY3ou8TOecm1id8zLP+atTKTIBdCSpnG3DgZIfIMzEkq0qaJupYfG2uKS/+0bA5qvqZ N0U/bklCmZNmD2uWYytGhEdqPIYux5Ecz6pQPdJvir9+j8NDideSjI2UfKxsWwEB0eiW lb6ByYZowP2PzX9yXc1NxXElTj+c27zmtFwbYoeOUI/6IjrHUJW2datHg+Li694igxXh dCktdPPR2hmfAmVfpNsv47nVTDv+OLYdTiH0CHX9ZjeOGThjSaat5LXXijfETNc/r8Wk 4SGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=8Od9yITiN3CpQ9ID8oxmfcb1MGMov3ZoJ+/Zebs+qw4=; b=QKosRccViNRAXNciiNbK1COTIBdTwLF0+tM2/nBTUSX4NKar+8EjIYkSAu0T3xTIOn C35HEEFAq91aDVdoP81KUhtRT+yBa5y4jiPfpxGN7sds1QKkeqheiSNpWyOArB2zDCbU TojiTd0Qd/VpgOLz7SrxOTIcxN/LNwkYqZ3JI1LflTdRZQatnpf2rufLBNwpBNVgRJIJ iZ73heAun4de2tQAxki2OFvBvoCAW6DL3Un1Z0vckHXYQwPTLgljsU2lSXkP3nx1VgB0 iiUQu/AU+1YNQVHWdP7JN00HO7s+CtSI7BU4I4iRe/ULpCg0tKDlaz7lH+VhMbR/m3rD nHHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=es473xh3; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d2-v6si39689717plo.210.2018.11.19.02.33.22; Mon, 19 Nov 2018 02:33:37 -0800 (PST) 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=@nifty.com header.s=dec2015msa header.b=es473xh3; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727643AbeKSUzv (ORCPT + 99 others); Mon, 19 Nov 2018 15:55:51 -0500 Received: from conuserg-11.nifty.com ([210.131.2.78]:59354 "EHLO conuserg-11.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727489AbeKSUzv (ORCPT ); Mon, 19 Nov 2018 15:55:51 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-11.nifty.com with ESMTP id wAJAVrOB009918; Mon, 19 Nov 2018 19:31:54 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-11.nifty.com wAJAVrOB009918 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1542623514; bh=8Od9yITiN3CpQ9ID8oxmfcb1MGMov3ZoJ+/Zebs+qw4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=es473xh3BXGrESilENTJ82S6FUNHsottnp1X6xGXkAXtiFTf537ER62oQzK6A14UU K964ZaGfZhg1NiylVuxj9rzo8dwG1ULrBwTPRQN03iDH+GDytfoVtZGnpxzAMx5TP/ DjEH9b3s7YZP4M7SwxrkY0gk8TB+19Fae4tg52EyrKZvw6xSTG9C+tUcCHe4KMuHMU n7qPbT5pzvCIDSWfhbjvj6YYzof43pnhyffPA7EPxwB3sEvTThg21gGtNJGcaADaI6 xYKsRzPuMihOygCymhCceaf66UA/Ozx6BnkvLf/uDhdM/Lwk16Iv+gelvkJ6G7MNdW phzVg16pCvM7w== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Andrew Morton Cc: Luc Van Oostenryck , Nick Desaulniers , Kees Cook , Josh Triplett , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v3 2/3] build_bug.h: remove negative-array fallback for BUILD_BUG_ON() Date: Mon, 19 Nov 2018 19:31:42 +0900 Message-Id: <1542623503-3755-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1542623503-3755-1-git-send-email-yamada.masahiro@socionext.com> References: <1542623503-3755-1-git-send-email-yamada.masahiro@socionext.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The kernel can only be compiled with an optimization option (-O2, -Os, or the currently proposed -Og). Hence, __OPTIMIZE__ is always defined in the kernel source. The fallback for the -O0 case is just hypothetical and pointless. Moreover, commit 0bb95f80a38f ("Makefile: Globally enable VLA warning") enabled -Wvla warning. The use of variable length arrays is banned. Signed-off-by: Masahiro Yamada Acked-by: Kees Cook --- Changes in v3: None Changes in v2: None include/linux/build_bug.h | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/include/linux/build_bug.h b/include/linux/build_bug.h index 43d1fd5..d415c64 100644 --- a/include/linux/build_bug.h +++ b/include/linux/build_bug.h @@ -51,23 +51,9 @@ * If you have some code which relies on certain constants being equal, or * some other compile-time-evaluated condition, you should use BUILD_BUG_ON to * detect if someone changes it. - * - * The implementation uses gcc's reluctance to create a negative array, but gcc - * (as of 4.4) only emits that error for obvious cases (e.g. not arguments to - * inline functions). Luckily, in 4.3 they added the "error" function - * attribute just for this type of case. Thus, we use a negative sized array - * (should always create an error on gcc versions older than 4.4) and then call - * an undefined function with the error attribute (should always create an - * error on gcc 4.3 and later). If for some reason, neither creates a - * compile-time error, we'll still have a link-time error, which is harder to - * track down. */ -#ifndef __OPTIMIZE__ -#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) -#else #define BUILD_BUG_ON(condition) \ BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition) -#endif /** * BUILD_BUG - break compile if used. -- 2.7.4