From patchwork Mon Aug 14 22:29:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Stitt X-Patchwork-Id: 13353379 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 42C57C001DB for ; Mon, 14 Aug 2023 22:29:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: Mime-Version:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=iFqcqlrkZJOpqt2M5xzoqh41sGFVdmc6KYL7KnHoDbU=; b=aH/ xSvxCG1FYu+r1dBtZ5BZXd2txoQRI7bhOBFJRdwNwzEkJJ0xjtSBAr2lIoQ0KuMe85LSg3aawNQ0X 5AvZT6npCaotmOZImtjJQfOvfhHD+NZ2IZupCJdjgv7kidWKufIzVk+vgROkWFcSJNRDfqUHi1T7G 8jrrDb7PVwWD1ido+HKwrZbaNlOp0qFfWQ1Scu1k7yYNcNdV081YUmh4vcFiNd451Kuexw4ercfYY sMcYnl9Av3qslqgk9bEhE88G68ZbLANCbvxYAGJtbce6uYmOVZKgjG8F6tauN3VqN6rzgMMAOLagH pJelllJ9gQ51E3ldUc1jwUgM/NX/C7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qVg42-000SQZ-0e; Mon, 14 Aug 2023 22:29:30 +0000 Received: from mail-yb1-xb4a.google.com ([2607:f8b0:4864:20::b4a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qVg3y-000SQ9-1L for linux-arm-kernel@lists.infradead.org; Mon, 14 Aug 2023 22:29:27 +0000 Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d1c693a29a0so5891199276.1 for ; Mon, 14 Aug 2023 15:29:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1692052163; x=1692656963; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=RcDIHEJOfIIWu/ve0ihwsZwkiAHO9c4r9RpAYPgPp0Q=; b=nijWK+10BpOOGjaNzFF/ySkAzQyd1bpPMAfTFZ15CB3RONAkpICnZD9HkZuF0WDOdr GmWZDXkttlQgwIrweQ06htMhP1y5c4dLLYcFiXhr2DYygC4CPaLl+lXkCBPRFGdQyA3Y s0zI+dAdAYnKv6EAMUSqioCW8e6SUoVkxKzh/BalivDSLxU2tVRr4qXnh5FjJ1xE2yPt a40o8fKsSE0Y9fz5Eo6vn5qAG36WTiaG55mlMnja0ivOXsUFnoJ6U8R5a08Thl6oiixp tuICWzWVtM21YVHhiB6Q48LsBlDn/7IG53hgwDBPDI0W6fINqvXu2McNcBRTy83aW9hk 5vcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692052163; x=1692656963; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=RcDIHEJOfIIWu/ve0ihwsZwkiAHO9c4r9RpAYPgPp0Q=; b=SJQBPwXP+8FeKxHbLctYxrHomzlN6mVM+bgiExORw598iIuvVCGLhXOeewG87WZf+G zqpaWwm4pgNTG2/gZVglKaVPddfnII1azAft2deNgNlxDiUfkdAgh1CmGglVE0E3jxto TK81wmtFCsw0M3spAIxpsOyupJLelfKtJfj+2KViCWktCbn8fMGA1hJ2J9Y0DGvtgUkB GeRGZHkpSBEY+6iGLdi2ADLwiwbY+KB0F2l5idflXWb0exy4cpCTJqPnoUOvHayzXWWh JfeExoiY16EsPUCmpZ5+XhaXGg0sDUfauD8EUY1Qbr/UgZws7E8YD5SBBPP+2+Xh6QEH Woww== X-Gm-Message-State: AOJu0YwNNSLWYo9/hDtbi3yy5NutlJQLWbnncoYxHaglAHCJJh4YyvNG sLMX6uu6vRVjFOxywyUuAbrmmEUfVc8/X5dO2w== X-Google-Smtp-Source: AGHT+IFOorN5wnUKQMgqROu8nIpxAopwbZ9DVt7NA03X2ZwvhZWl7WSRhbOBwhQ2hjOiEXxNdv8EMmqvUlMFUGlkFQ== X-Received: from jstitt-linux1.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:23b5]) (user=justinstitt job=sendgmr) by 2002:a05:6902:4c7:b0:d5d:511b:16da with SMTP id v7-20020a05690204c700b00d5d511b16damr152077ybs.2.1692052163298; Mon, 14 Aug 2023 15:29:23 -0700 (PDT) Date: Mon, 14 Aug 2023 22:29:22 +0000 Mime-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAMGq2mQC/x3N0QrCMAyF4VcZuTawzYnOV5FdhDTTQG1KOoow9 u5WLz/4OWeHIq5S4N7t4FK1qKWG4dQBvyg9BTU0w9iP5/42TFhNAwbXKl4wsyJb2txiFP+x9dm NMUfaVvM3UqCJeKaZrhdoq9ll1c//8bEcxxf6NaK4gQAAAA== X-Developer-Key: i=justinstitt@google.com; a=ed25519; pk=tC3hNkJQTpNX/gLKxTNQKDmiQl6QjBNCGKJINqAdJsE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1692052162; l=1795; i=justinstitt@google.com; s=20230717; h=from:subject:message-id; bh=toFi8SLwCRTpw1/0M43OmJYYHtAj7TdhUp1prlUqvx0=; b=U3QTlDMvdylVxAWgbG3pK732X8XyFTgIFb66Bd2VJBtoqOoT1q9iVC/u9LcAgyIsk9+LM9r9F EJcOv89AN5mAXhCnqYlgISVYhs9mDM/pbsSB1w8FWz7dQcfdDIwtpq1 X-Mailer: b4 0.12.3 Message-ID: <20230814-void-drivers-pci-controller-pcie-iproc-platform-v1-1-81a121607851@google.com> Subject: [PATCH] PCI: iproc: fix -Wvoid-pointer-to-enum-cast warning From: Justin Stitt To: Lorenzo Pieralisi , " =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= " , Rob Herring , Bjorn Helgaas , Ray Jui , Scott Branden , Broadcom internal kernel review list , Nathan Chancellor , Nick Desaulniers , Tom Rix Cc: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, Justin Stitt X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230814_152926_476119_09F17196 X-CRM114-Status: GOOD ( 13.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When building with clang 18 I see the following warning: | drivers/pci/controller/pcie-iproc-platform.c:55:15: warning: cast to smaller | integer type 'enum iproc_pcie_type' from 'const void *' [-Wvoid-pointer-to-enum-cast] | 55 | pcie->type = (enum iproc_pcie_type) of_device_get_match_data(dev); This is due to the fact that `of_device_get_match_data` returns a void* while `enum iproc_pcie_type` has the size of an int. This leads to truncation and possible data loss. Link: https://github.com/ClangBuiltLinux/linux/issues/1910 Reported-by: Nathan Chancellor Signed-off-by: Justin Stitt --- Note: There is likely no data loss occurring here since `enum iproc_pcie_type` has only a few fields enumerated from 0. Definitely not enough to cause data loss from pointer-width to int-width. --- drivers/pci/controller/pcie-iproc-platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- base-commit: 2ccdd1b13c591d306f0401d98dedc4bdcd02b421 change-id: 20230814-void-drivers-pci-controller-pcie-iproc-platform-ada4ac9a9a75 Best regards, -- Justin Stitt diff --git a/drivers/pci/controller/pcie-iproc-platform.c b/drivers/pci/controller/pcie-iproc-platform.c index acdc583d2980..83cbc95f4384 100644 --- a/drivers/pci/controller/pcie-iproc-platform.c +++ b/drivers/pci/controller/pcie-iproc-platform.c @@ -52,7 +52,7 @@ static int iproc_pltfm_pcie_probe(struct platform_device *pdev) pcie = pci_host_bridge_priv(bridge); pcie->dev = dev; - pcie->type = (enum iproc_pcie_type) of_device_get_match_data(dev); + pcie->type = (uintptr_t) of_device_get_match_data(dev); ret = of_address_to_resource(np, 0, ®); if (ret < 0) {