From patchwork Sun Sep 26 22:36:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fangrui Song X-Patchwork-Id: 45457 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B2B923858423 for ; Sun, 26 Sep 2021 22:36:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B2B923858423 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1632695805; bh=p9JGqACUDrDhpQKdiiGKTkoKhNDECPhAqdl5BFvr10c=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=tuGTC2fLFx/SPfq2IAGSXjVXHSQh28w1npbq3KZ5D7KWq7adQCVyG5KnW/k7tLdvJ rac9ZPtHrp9G+H9BraTQqy7EAY0upnsqcrkYfdS9cD+GoijLv0/NERrf8ddXYOPEbU UXJHfnDpcbJWH7C9a9iVUq7snxPCixrQvXH0lC7A= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by sourceware.org (Postfix) with ESMTPS id 158D93858C60 for ; Sun, 26 Sep 2021 22:36:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 158D93858C60 Received: by mail-qt1-x849.google.com with SMTP id l22-20020ac87b36000000b002a6c575f419so46681432qtu.23 for ; Sun, 26 Sep 2021 15:36:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=p9JGqACUDrDhpQKdiiGKTkoKhNDECPhAqdl5BFvr10c=; b=EmYhWhr00CklLknCE08HreloqgWwFLoRk1kQ7jGmE1EELIyJKJzLin9HmXUO9bRO3/ 4hds7m7lmnTQ1pSvSTh+0+f9QtXB1xvPpkjEGdLU/HX3cFRuzoIAWC/u3coS6ZdMexPB UO2gzSrswCU+gmVTZWDOSOLxBbtK8I/nfVyFmUxE+u1w+NDH9DItuQemVh1OKRqhUdoK wejZNolDAei9MHPraNnLwRVmXplfyXGTDoXHFwfgJJjgYx4c3TlhiT1ve82FdXr5cEaH 4CFgKNuVGjEFwEjoCm0AlOX6B9p7xnpY6hjnSnWk16blPYT9gaGRK/WGviah4sdKLEOn He0Q== X-Gm-Message-State: AOAM530ZI3zYGMfjXf6hBi+wdnR5OMvy02MYliua3kmCFL2MU/8cZXRz ZoSciI4Y0zRmbhcjQL77A2L1kYy0TWm/dspwe2WqHSXC3c/xpQ7qIY3IapbVBlg3oudsGL+VKPI lgUoyQwLd6xbuUWcbmlZpKrze8JoRHtJ/+xZTR7BteHs2Zo3k30kka1Ig1a/HJz/bdOlv X-Google-Smtp-Source: ABdhPJzh1aqHhqY4GwNrpHV5IEvpqP29YQR287y09aUIpIHrVEIFRC7tKnvN9m/h3VRpF86TVEMPfPsy4UFW X-Received: from maskray1.svl.corp.google.com ([2620:15c:2ce:200:58e8:dbcb:819b:fd8e]) (user=maskray job=sendgmr) by 2002:a05:6214:9c9:: with SMTP id dp9mr21490961qvb.2.1632695782650; Sun, 26 Sep 2021 15:36:22 -0700 (PDT) Date: Sun, 26 Sep 2021 15:36:19 -0700 Message-Id: <20210926223619.552849-1-maskray@google.com> Mime-Version: 1.0 Subject: [PATCH] linux: Fix a non-constant expression in _Static_assert To: libc-alpha@sourceware.org, Adhemerval Zanella X-Spam-Status: No, score=-19.3 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Fangrui Song via Libc-alpha From: Fangrui Song Reply-To: Fangrui Song Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" According to C11 6.6p6, `const int` as an operand does not make up a constant expression. Clang reports an error and GCC reports an error if fed into the preprocessed output: ../sysdeps/unix/sysv/linux/opendir.c:107:19: error: static_assert expression is not an integral constant expression _Static_assert (allocation_size >= sizeof (struct dirent64), GCC accepting the unpreprocessed source is a bug. Fixes: 4b962c9e859de23b461d61f860dbd3f21311e83a ("linux: Simplify opendir buffer allocation") --- sysdeps/unix/sysv/linux/opendir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdeps/unix/sysv/linux/opendir.c b/sysdeps/unix/sysv/linux/opendir.c index 48f254d169..88640f44ee 100644 --- a/sysdeps/unix/sysv/linux/opendir.c +++ b/sysdeps/unix/sysv/linux/opendir.c @@ -103,7 +103,7 @@ __alloc_dir (int fd, bool close_fd, int flags, file system provides a bogus value. */ enum { max_buffer_size = 1048576 }; - const size_t allocation_size = 32768; + enum { allocation_size = 32768 }; _Static_assert (allocation_size >= sizeof (struct dirent64), "allocation_size < sizeof (struct dirent64)");