All of lore.kernel.org
 help / color / mirror / Atom feed
From: Manivannan Sadhasivam <mani@kernel.org>
To: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: lpieralisi@kernel.org, kw@linux.com, robh@kernel.org,
	bhelgaas@google.com, jingoohan1@gmail.com,
	gustavo.pimentel@synopsys.com, linux-pci@vger.kernel.org,
	linux-renesas-soc@vger.kernel.org,
	Justin Stitt <justinstitt@google.com>,
	Nathan Chancellor <nathan@kernel.org>
Subject: Re: [PATCH v2 5/6] PCI: iproc: fix -Wvoid-pointer-to-enum-cast warning
Date: Fri, 17 Nov 2023 14:51:41 +0530	[thread overview]
Message-ID: <20231117092141.GG250770@thinkpad> (raw)
In-Reply-To: <20231114055456.2231990-6-yoshihiro.shimoda.uh@renesas.com>

On Tue, Nov 14, 2023 at 02:54:55PM +0900, Yoshihiro Shimoda wrote:
> From: Justin Stitt <justinstitt@google.com>
> 
> 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.
> 

As Geert noted, this statement is wrong as there is no possible data loss in
this driver. Please fix it in next version.

> Link: https://github.com/ClangBuiltLinux/linux/issues/1910
> Reported-by: Nathan Chancellor <nathan@kernel.org>
> Signed-off-by: Justin Stitt <justinstitt@google.com>
> Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>

Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>

- Mani

> ---
>  drivers/pci/controller/pcie-iproc-platform.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> 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, &reg);
>  	if (ret < 0) {
> -- 
> 2.34.1
> 

-- 
மணிவண்ணன் சதாசிவம்

  parent reply	other threads:[~2023-11-17  9:21 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-14  5:54 [PATCH v2 0/6] PCI: controllers: tidy code up Yoshihiro Shimoda
2023-11-14  5:54 ` [PATCH v2 1/6] PCI: dwc: Drop host prefix from struct dw_pcie_host_ops Yoshihiro Shimoda
2023-11-14 10:42   ` Serge Semin
2023-11-15 14:23   ` Jesper Nilsson
2023-11-16  0:15   ` nobuhiro1.iwamatsu
2023-11-17  9:10   ` Manivannan Sadhasivam
2023-11-21  1:15   ` Kunihiko Hayashi
2023-11-21  2:33   ` Heiko Stübner
2023-11-21  6:34   ` Lei Chuan Hua
2023-11-21  8:00   ` Thomas Petazzoni
2023-11-14  5:54 ` [PATCH v2 2/6] PCI: dwc: Rename to .init in struct dw_pcie_ep_ops Yoshihiro Shimoda
2023-11-14 10:44   ` Serge Semin
2023-11-15  9:09   ` Thokala, Srikanth
2023-11-15 14:23   ` Jesper Nilsson
2023-11-17  9:13   ` Manivannan Sadhasivam
2023-11-21  1:15   ` Kunihiko Hayashi
2023-11-14  5:54 ` [PATCH v2 3/6] PCI: dwc: Rename to .get_dbi_offset " Yoshihiro Shimoda
2023-11-17  9:14   ` Manivannan Sadhasivam
2023-11-14  5:54 ` [PATCH v2 4/6] PCI: dwc: Add dw_pcie_ep_{read,write}_dbi[2] helpers Yoshihiro Shimoda
2023-11-14 10:52   ` Serge Semin
2023-11-17  9:19     ` Manivannan Sadhasivam
2023-12-15  1:13       ` Yoshihiro Shimoda
2023-11-14  5:54 ` [PATCH v2 5/6] PCI: iproc: fix -Wvoid-pointer-to-enum-cast warning Yoshihiro Shimoda
2023-11-14  8:10   ` Geert Uytterhoeven
2023-11-17  9:21   ` Manivannan Sadhasivam [this message]
2023-12-15  1:20     ` Yoshihiro Shimoda
2023-11-14  5:54 ` [PATCH v2 6/6] PCI: rcar-gen4: " Yoshihiro Shimoda
2023-11-14  8:11   ` Geert Uytterhoeven
2023-11-17  9:28   ` Manivannan Sadhasivam
2023-12-14  2:35 ` [PATCH v2 0/6] PCI: controllers: tidy code up Yoshihiro Shimoda
2023-12-14  9:40   ` Serge Semin
2023-12-14 10:26     ` Manivannan Sadhasivam
2023-12-14 23:44       ` Yoshihiro Shimoda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231117092141.GG250770@thinkpad \
    --to=mani@kernel.org \
    --cc=bhelgaas@google.com \
    --cc=gustavo.pimentel@synopsys.com \
    --cc=jingoohan1@gmail.com \
    --cc=justinstitt@google.com \
    --cc=kw@linux.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=lpieralisi@kernel.org \
    --cc=nathan@kernel.org \
    --cc=robh@kernel.org \
    --cc=yoshihiro.shimoda.uh@renesas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.