From patchwork Thu Jul 20 10:31:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Simon Ser X-Patchwork-Id: 13320292 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 F2576EB64DC for ; Thu, 20 Jul 2023 10:31:25 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 515D010E5A1; Thu, 20 Jul 2023 10:31:25 +0000 (UTC) Received: from mail-4317.proton.ch (mail-4317.proton.ch [185.70.43.17]) by gabe.freedesktop.org (Postfix) with ESMTPS id AB0D910E5A1 for ; Thu, 20 Jul 2023 10:31:23 +0000 (UTC) Date: Thu, 20 Jul 2023 10:31:14 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=emersion.fr; s=protonmail2; t=1689849081; x=1690108281; bh=RIzsxjFJVzu7QLMreVFel/I2enVI2aly68q3YeP4hq0=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=InfTrSUQ0uZ/cMgSXlQK6VSWlXVFSQUq4KnMDYSwVWz+Dhb5SWy/GZ7imgs+dsspT Zg1SHsw7CgvUoajZWTrNYH4aleja1q9XsJMbF7h4/aNGzf8s9G34J3t3ej+iCtIjK5 ntrtIdfWf7pqkWxec5CBohfGorFTZEcJgJvcjBPqirvsnMygrkkFXu+MSbpLpMlXsW 3SXmXK1H5sE+H4HUGniyVDpKJfhXWc4UZoBh6F9v0LELbm4jwUj8Ux174PVOFGNxZD ZBe7CxGXqYfpBOXNRy17utA7Cd1S4ZZf59Lp1q1wrWj+gAGhyKUQ/KEJ+e8Lj36PUD jC7Fe8X7VZL4Q== To: dri-devel@lists.freedesktop.org From: Simon Ser Subject: [PATCH] drm/ioctl: turn on -Woverride-init for IOCTL table Message-ID: <20230720103107.817084-1-contact@emersion.fr> Feedback-ID: 1358184:user:proton MIME-Version: 1.0 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: Erik Kurzinger , Thomas Zimmermann , =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Recently two patches [1] [2] have hit a case of mistakenly picking an IOCTL number which was already in-use. This is hard to debug because the last definition wins and there is no indication that there is a conflict. Fix this by enabling -Werror=override-init for the IOCTL table. When there is a duplicate entry, the compiler now errors out: CC [M] drivers/gpu/drm/drm_ioctl.o drivers/gpu/drm/drm_ioctl.c:555:33: error: initialized field overwritten [-Werror=override-init] 555 | [DRM_IOCTL_NR(ioctl)] = { \ | ^ drivers/gpu/drm/drm_ioctl.c:708:9: note: in expansion of macro ‘DRM_IOCTL_DEF’ 708 | DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_EVENTFD, drm_syncobj_reset_ioctl, | ^~~~~~~~~~~~~ drivers/gpu/drm/drm_ioctl.c:555:33: note: (near initialization for ‘drm_ioctls[207]’) 555 | [DRM_IOCTL_NR(ioctl)] = { \ | ^ drivers/gpu/drm/drm_ioctl.c:708:9: note: in expansion of macro ‘DRM_IOCTL_DEF’ 708 | DRM_IOCTL_DEF(DRM_IOCTL_SYNCOBJ_EVENTFD, drm_syncobj_reset_ioctl, | ^~~~~~~~~~~~~ cc1: some warnings being treated as errors [1]: https://lore.kernel.org/dri-devel/20230714111257.11940-1-contact@emersion.fr/ [2]: https://lore.kernel.org/dri-devel/vVFDBgHpdcB0vOwnl02QPOFmAZPEbIV56E_wQ8B012K2GZ-fAGyG0JMbSrMu3-IcKYVf0JpJyrf71e6KFHfeMoSPJlYRACxlxy91eW9c6Fc=@emersion.fr/ Signed-off-by: Simon Ser Cc: Erik Kurzinger Cc: Daniel Vetter Cc: Thomas Zimmermann Cc: Christian König --- drivers/gpu/drm/drm_ioctl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index f03ffbacfe9b..cd485eb54d2a 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -566,6 +566,8 @@ static int drm_ioctl_permit(u32 flags, struct drm_file *file_priv) #endif /* Ioctl table */ +#pragma GCC diagnostic push +#pragma GCC diagnostic error "-Woverride-init" static const struct drm_ioctl_desc drm_ioctls[] = { DRM_IOCTL_DEF(DRM_IOCTL_VERSION, drm_version, DRM_RENDER_ALLOW), DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, 0), @@ -718,6 +720,7 @@ static const struct drm_ioctl_desc drm_ioctls[] = { DRM_IOCTL_DEF(DRM_IOCTL_MODE_GET_LEASE, drm_mode_get_lease_ioctl, DRM_MASTER), DRM_IOCTL_DEF(DRM_IOCTL_MODE_REVOKE_LEASE, drm_mode_revoke_lease_ioctl, DRM_MASTER), }; +#pragma GCC diagnostic pop #define DRM_CORE_IOCTL_COUNT ARRAY_SIZE(drm_ioctls)