[RFC] drm: enable W=1 warnings by default across the subsystem

Nathan Chancellor nathan at kernel.org
Fri Dec 1 17:59:39 UTC 2023


On Thu, Nov 30, 2023 at 10:52:17AM +0200, Jani Nikula wrote:
> On Wed, 29 Nov 2023, Hamza Mahfooz <hamza.mahfooz at amd.com> wrote:
> > Cc: Nathan Chancellor <nathan at kernel.org>
> >
> > On 11/29/23 13:12, Jani Nikula wrote:
> >> 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.
> >
> > I think this should go in after drm-misc-next has a clean build (for
> > COMPILE_TEST builds) with this patch applied. Otherwise, it will break a
> > lot of build configs.
> 
> Oh, I'm absolutely not suggesting this should be merged before known
> warnings have been addressed one way or another. Either by fixing them
> or by disabling said warning in driver local Makefiles, depending on the
> case.
> 
> While I'm suggesting this, I obviously (I hope) can't take on fixing all
> the warnings this exposes. One way to scale would be for folks to apply
> this locally, see what it uncovers in their drivers, and fix some.
> 
> As an intermediate step we might also apply this to a topic branch in
> drm-tip, so you'd see the warnings when building drm-tip, but not in
> indidual branches or in anything that's merged upstream.

For what it's worth, I ran this through my personal build matrix with
LLVM/clang and it only found a few instances of
-Wunused-but-set-variable:

drivers/gpu/drm/mediatek/mtk_disp_gamma.c:121:6: warning: variable 'cfg_val' set but not used [-Wunused-but-set-variable]
drivers/gpu/drm/nouveau/nouveau_svm.c:115:24: warning: variable 'priority' set but not used [-Wunused-but-set-variable]
drivers/gpu/drm/nouveau/nouveau_svm.c:929:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
drivers/gpu/drm/nouveau/nvkm/subdev/acr/lsfw.c:221:7: warning: variable 'loc' set but not used [-Wunused-but-set-variable]
drivers/gpu/drm/qxl/qxl_cmd.c:424:6: warning: variable 'count' set but not used [-Wunused-but-set-variable]
drivers/gpu/drm/qxl/qxl_ioctl.c:148:14: warning: variable 'num_relocs' set but not used [-Wunused-but-set-variable]

I know that clang does not support all the warnings that are being
enabled here but I suspect there won't be too many instances of the
other warnings. -Wformat-overflow and -Wformat-truncation might be the
big ones. I know -Wstringop-overflow is being turned on globally
in -next so that is one that you shouldn't have to worry much about.

Cheers,
Nathan


More information about the dri-devel mailing list