From patchwork Fri Aug 2 13:22:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1968364 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=LzbtX67W; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wb6334RMnz1yZl for ; Fri, 2 Aug 2024 23:23:11 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D67A1385B50B for ; Fri, 2 Aug 2024 13:23:09 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id E3190385C6D1 for ; Fri, 2 Aug 2024 13:22:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E3190385C6D1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E3190385C6D1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722604968; cv=none; b=Y4/kHuNBH1QROOI/zR0Ola8XLCMQNWWf48HsAS7oIvt7pdtRVvCqDkJ9NQm0NvaeE8p5GEJCumrOPHNNuCZlD4wH6/F9UZXCrPPhMN4p0A7RicZoRrM0zoK2ya1PXQBFdDXf5H4mMRvxBPUxpdfNYkhzbC6l02k0564jn+XeRX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722604968; c=relaxed/simple; bh=Ymb4QYVTNpIg4EwfcHnz3r17ZcKXJrCecCnyKQJX4Uc=; h=DKIM-Signature:From:To:MIME-Version:Subject:Message-ID:Date; b=VmQ4fZOOthknE6INshkp3HRcK4D4WEqwYtpVLnLoImIcUIy1HCziUbk/Rba2aUvBIWz4b86+WVCyq9sErPQtPqj8laqDO7frx/fMc3VyIyyVkuDehwhpAz/pyMjLoKwfkmBP99y28YQubsHNknPjt0tVY2LXwtQVpCzVv9FFWks= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1722604966; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=YNhctE4x5zxNLuDO9g56SZpxsf1qNDeTn5qx9Oa0rW4=; b=LzbtX67WGuOVj9GTyWd3TBJZqnBos9GXmffvPBKRFice43H+dLZEQU7JTAlWZ4cfeKm/Fo 1bxY+Fl1ua+rsAQJLqHEHib67AbBubohwKctraV4EMmehAa7uKUotbG6XkiQRyzzSTVc04 2fx1O/577dXl/jUKf7wjm4jbjQFfNRk= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-456-zHrTfYEvN4CgPpG0Y1bCmw-1; Fri, 02 Aug 2024 09:22:45 -0400 X-MC-Unique: zHrTfYEvN4CgPpG0Y1bCmw-1 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 60E871955D55 for ; Fri, 2 Aug 2024 13:22:44 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.45.224.139]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3C21D1955D4A for ; Fri, 2 Aug 2024 13:22:42 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org MIME-Version: 1.0 Subject: [PATCH 4/4] Turn on -Wimplicit-fallthrough by default if available In-Reply-To: Message-ID: <2a5b17ba992abd2311da130c18a531f89c21ee79.1722604821.git.fweimer@redhat.com> References: X-From-Line: 2a5b17ba992abd2311da130c18a531f89c21ee79 Mon Sep 17 00:00:00 2001 Date: Fri, 02 Aug 2024 15:22:40 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org --- Makeconfig | 3 +++ config.make.in | 1 + configure | 12 ++++++++++++ configure.ac | 10 ++++++++++ 4 files changed, 26 insertions(+) diff --git a/Makeconfig b/Makeconfig index 2d4343b604..e90f612b96 100644 --- a/Makeconfig +++ b/Makeconfig @@ -889,6 +889,9 @@ endif # Extra flags to pass to GCC. +gccwarn := -Wall -Wwrite-strings -Wundef +ifeq ($(enable-wimplicit-fallthrough),yes) ++gccwarn += -Wimplicit-fallthrough +endif ifeq ($(enable-werror),yes) +gccwarn += -Werror endif diff --git a/config.make.in b/config.make.in index 36096881b7..4286a63269 100644 --- a/config.make.in +++ b/config.make.in @@ -51,6 +51,7 @@ c++-cstdlib-header = @CXX_CSTDLIB_HEADER@ c++-cmath-header = @CXX_CMATH_HEADER@ c++-bits-std_abs-h = @CXX_BITS_STD_ABS_H@ enable-werror = @enable_werror@ +enable-wimplicit-fallthrough = @enable_wimplicit_fallthrough@ have-z-execstack = @libc_cv_z_execstack@ have-protected-data = @libc_cv_protected_data@ diff --git a/configure b/configure index 1d543548cd..01a011d73f 100755 --- a/configure +++ b/configure @@ -643,6 +643,7 @@ have_selinux have_libcap have_libaudit LIBGD +enable_wimplicit_fallthrough libc_cv_cc_loop_to_function libc_cv_cc_submachine libc_cv_cc_nofma @@ -7465,6 +7466,17 @@ if test $libc_cv_cc_loop_to_function = yes; then fi +if ${CC-cc} --help=warnings 2>&1 | grep -q " -Wimplicit-fallthrough" \ + || ${CC-cc} -print-diagnostic-options 2>&1 | grep -q " -Wimplicit-fallthrough" +then + echo HOHOHO + enable_wimplicit_fallthrough=yes +else + echo BADBADBAD + enable_wimplicit_fallthrough=no +fi + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libgd" >&5 printf %s "checking for libgd... " >&6; } if test "$with_gd" != "no"; then diff --git a/configure.ac b/configure.ac index 9cbc0bf68f..c686ea4b97 100644 --- a/configure.ac +++ b/configure.ac @@ -1468,6 +1468,16 @@ if test $libc_cv_cc_loop_to_function = yes; then fi AC_SUBST(libc_cv_cc_loop_to_function) +dnl GCC uses --help=warnings, Clang uses -print-diagnostic-options. +if ${CC-cc} --help=warnings 2>&1 | grep -q " -Wimplicit-fallthrough" \ + || ${CC-cc} -print-diagnostic-options 2>&1 | grep -q " -Wimplicit-fallthrough" +then + enable_wimplicit_fallthrough=yes +else + enable_wimplicit_fallthrough=no +fi +AC_SUBST(enable_wimplicit_fallthrough) + dnl Check whether we have the gd library available. AC_MSG_CHECKING(for libgd) if test "$with_gd" != "no"; then