From patchwork Fri Nov 16 06:19:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 151282 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp39565ljp; Thu, 15 Nov 2018 22:20:49 -0800 (PST) X-Google-Smtp-Source: AJdET5eLkRlyNyRz+6ixZ3ABlTrVLA8v0oofHG8IwVU9ANIzuDyQvRtk4HlwHzJ7gb9R8C1ON/rZ X-Received: by 2002:a17:902:6b87:: with SMTP id p7-v6mr9631212plk.282.1542349249388; Thu, 15 Nov 2018 22:20:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542349249; cv=none; d=google.com; s=arc-20160816; b=y9KFFahHFXtMdeJhE8wjB8ihh826hUiGPI6ZxQwe6zyhAfBAYcpX9y0R42kC2gPYmC 3YETSfZYcQybOBYjWkjKNkpc/fvFcQbtmBR7/X8r+psXsPqhKiKURLvCa36txxyDxQEH EbF/sXTe03eOOqwtSrz0OtAxLm1RaYxjncPk+FzfLztXr8zB36MUfQHHvHRQfQfq+JS5 Wx2XrWPwXEsDvkK82vmIInlgrLNV/tF5Slxn+SxtpDatKUldEbgygwhz/jyYmJafDjb5 CB+vu9AfEPPDl7KPjTkF+x61BK4H2UzJqDss0F725r237tgAbJWs6bbopWX1U2wwQev4 w/VA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=b7bIis8GuYOhefMZ1/UmXoVBCnD/P6pVfgD6PBk3yw8=; b=vARDVcUff/Y84qG9TIJ7FzrveAoFehaEYVVRXVBTMGQ3iCapJgR6fv3VmfIut6b16s rgn+asg8oUAfKXfMtNfX6jqfg2KuuPx9BzaWLxZKyaEo1LBp1KTzNGXjZ23LKtVLQodK L/J8nQdNVViSq9Y4N/vORxphm+etu0D2Gdv/33eNQyhaPOLMjMjwlZOonxY9dedSF89h wD9r8Jh/WmmP3kePE84KhBuv3Z8jmmyIHji9MgWzreqaE7taKErc6D8tWmG88SbIE+8j w1j655ZgOdvFBhjihRbXanCWaqUT7tnvb7MDUT1fmJnBAcxyiF0eWd0dBkKe0TL29pZ6 DStQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=WMmNUH9l; 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 h7si9539188pls.326.2018.11.15.22.20.49; Thu, 15 Nov 2018 22:20:49 -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=WMmNUH9l; 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 S2389249AbeKPQbs (ORCPT + 32 others); Fri, 16 Nov 2018 11:31:48 -0500 Received: from conuserg-10.nifty.com ([210.131.2.77]:50717 "EHLO conuserg-10.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727377AbeKPQbs (ORCPT ); Fri, 16 Nov 2018 11:31:48 -0500 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-10.nifty.com with ESMTP id wAG6Jp5F005743; Fri, 16 Nov 2018 15:19:51 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com wAG6Jp5F005743 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1542349191; bh=b7bIis8GuYOhefMZ1/UmXoVBCnD/P6pVfgD6PBk3yw8=; h=From:To:Cc:Subject:Date:From; b=WMmNUH9lCidfCyu0kwH4Mq1kZy4FuXg44vJ+39ktGCQz/SLOWVvj9qxru7lJN7+QY lBOJc8GBriuZdv27UPMFxiGObkQD+IrEVZAk/hOnOaQqcQVmVpqKMrWBpxHkb3Nsvv ds45N//wDh88Q9VgECNAqaTVq5759rasfsHXhvV06+w6HMHpyLsgk/VbC7Hn6VLH1v 1d9ah9W/znywOm0q6ZwPZK40lSPI1ePRBq3FOVMui47K8yzvilvmFjwrMcRMv0jYbB hBaPnn9ozQrZsLZgKXUW0HRxHHWKQ5KLCMLNbcXI5wkrVDjUaZZPd78BvdKMy/YRSt 9oemg5Lh7j5/w== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: Andrew Morton Cc: Linus Torvalds , Arnd Bergmann , Kees Cook , Nick Desaulniers , Miguel Ojeda , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] build_bug.h: remove negative-array fallback for BUILD_BUG_ON() Date: Fri, 16 Nov 2018 15:19:00 +0900 Message-Id: <1542349141-7229-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 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. A fallback for -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 --- include/linux/build_bug.h | 14 -------------- 1 file changed, 14 deletions(-) -- 2.7.4 Acked-by: Kees Cook Acked-by: Miguel Ojeda 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.