From patchwork Wed Nov 29 18:12:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jani Nikula X-Patchwork-Id: 13473316 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C7F24C4167B for ; Wed, 29 Nov 2023 18:12:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2D20D10E21D; Wed, 29 Nov 2023 18:12:32 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by gabe.freedesktop.org (Postfix) with ESMTPS id A430A10E21D; Wed, 29 Nov 2023 18:12:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701281550; x=1732817550; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=R1Lr9uHQfHuA4q4I0DrIgWlieF9N1RNDCZSQwaAUZ4c=; b=OBZF52MDu1CEWSa9S6/wQr+UTbM6fxu/DEusgrDwA2S3P2Wyvud7KC3m jesgbsHYWF9lP9KZikbMYNZmOMPTuDVOVcZxtg/bhDYdWWDyr5S2Qu/DH OEiUVvsfl7tkEYWk3Li91j5pATKTqCfLTJPRQlB+iKHeDpfQtRHruoz8r 2p32RMYJUzjMcWrtq/dCgwZUdCtf8vccFWZKh4fpRC9n3TvkWKNoPO8yB 94VJcgWzQg7Hh/Ku+613pUbzMlUlYE9QO/+3DfKxvcuAHImD+gfiUXrkK 5BS/G1/w9YAZQHXy64AvVOGnRUWaFtyxuCZZUQYm1dGWUdsAV+ydP7ezO g==; X-IronPort-AV: E=McAfee;i="6600,9927,10909"; a="14762416" X-IronPort-AV: E=Sophos;i="6.04,237,1695711600"; d="scan'208";a="14762416" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2023 10:12:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10909"; a="745345455" X-IronPort-AV: E=Sophos;i="6.04,237,1695711600"; d="scan'208";a="745345455" Received: from dstavrak-mobl.ger.corp.intel.com (HELO localhost) ([10.252.60.61]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Nov 2023 10:12:23 -0800 From: Jani Nikula To: dri-devel@lists.freedesktop.org Subject: [RFC] drm: enable W=1 warnings by default across the subsystem Date: Wed, 29 Nov 2023 20:12:19 +0200 Message-Id: <20231129181219.1237887-1-jani.nikula@intel.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Zimmermann , Karol Herbst , Jani Nikula , Sean Paul , intel-gfx@lists.freedesktop.org, Xinhui , Abhinav Kumar , Maxime Ripard , Dmitry Baryshkov , Danilo Krummrich , Alex Deucher , Marijn Suijten , =?utf-8?q?Christian_K=C3=B6?= =?utf-8?q?nig?= , Pan@freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" At least the i915 and amd drivers enable a bunch more compiler warnings than the kernel defaults. Extend the W=1 warnings to the entire drm subsystem by default. Use the copy-pasted warnings from scripts/Makefile.extrawarn with s/KBUILD_CFLAGS/subdir-ccflags-y/ to make it easier to compare and keep up with them in the future. This is similar to the approach currently used in i915. Some of the -Wextra warnings do need to be disabled, just like in Makefile.extrawarn, but take care to not disable them for W=2 or W=3 builds, depending on the warning. Cc: David Airlie Cc: Daniel Vetter Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Thomas Zimmermann Cc: Alex Deucher Cc: Christian König Cc: Pan, Xinhui Cc: Karol Herbst Cc: Lyude Paul Cc: Danilo Krummrich Cc: Rob Clark Cc: Abhinav Kumar Cc: Dmitry Baryshkov Cc: Sean Paul Cc: Marijn Suijten Signed-off-by: Jani Nikula Acked-by: Thomas Zimmermann Acked-by: Javier Martinez Canillas Acked-by: Sui Jingfeng --- With my admittedly limited and very much x86 focused kernel config, I get some -Wunused-but-set-variable and -Wformat-truncation= warnings, but nothing we can't handle. We could fix them up front, or disable the extra warnings on a per driver basis with a FIXME comment in their respective Makefiles. With the experience from i915, I think this would significantly reduce the constant loop of warnings added by people not using W=1 and subsequently fixed by people using W=1. Note: I've Cc'd the maintainers of drm, drm misc and some of the biggest drivers. --- drivers/gpu/drm/Makefile | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index b4cb0835620a..6939e4ea13d5 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -5,6 +5,33 @@ CFLAGS-$(CONFIG_DRM_USE_DYNAMIC_DEBUG) += -DDYNAMIC_DEBUG_MODULE +# Unconditionally enable W=1 warnings locally +# --- begin copy-paste W=1 warnings from scripts/Makefile.extrawarn +subdir-ccflags-y += -Wextra -Wunused -Wno-unused-parameter +subdir-ccflags-y += -Wmissing-declarations +subdir-ccflags-y += $(call cc-option, -Wrestrict) +subdir-ccflags-y += -Wmissing-format-attribute +subdir-ccflags-y += -Wmissing-prototypes +subdir-ccflags-y += -Wold-style-definition +subdir-ccflags-y += -Wmissing-include-dirs +subdir-ccflags-y += $(call cc-option, -Wunused-but-set-variable) +subdir-ccflags-y += $(call cc-option, -Wunused-const-variable) +subdir-ccflags-y += $(call cc-option, -Wpacked-not-aligned) +subdir-ccflags-y += $(call cc-option, -Wformat-overflow) +subdir-ccflags-y += $(call cc-option, -Wformat-truncation) +subdir-ccflags-y += $(call cc-option, -Wstringop-overflow) +subdir-ccflags-y += $(call cc-option, -Wstringop-truncation) +# The following turn off the warnings enabled by -Wextra +ifeq ($(findstring 2, $(KBUILD_EXTRA_WARN)),) +subdir-ccflags-y += -Wno-missing-field-initializers +subdir-ccflags-y += -Wno-type-limits +subdir-ccflags-y += -Wno-shift-negative-value +endif +ifeq ($(findstring 3, $(KBUILD_EXTRA_WARN)),) +subdir-ccflags-y += -Wno-sign-compare +endif +# --- end copy-paste + drm-y := \ drm_aperture.o \ drm_atomic.o \