Re: possible incorrect warning in arch/arm/mm/dma-mapping.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 08, 2019 at 09:04:59AM +0100, Ben Dooks wrote:
> We see the following when building arm kernel:
> 
> arch/arm/mm/dma-mapping.c:738:52: warning: Using plain integer as NULL
> pointer
> 
> The function starts with:
> 
> static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t
> *handle,
> 			 gfp_t gfp, pgprot_t prot, bool is_coherent,
> 			 unsigned long attrs, const void *caller)
> {
> 	u64 mask = get_coherent_dma_mask(dev);
> 	struct page *page = NULL;
> 	void *addr;
> 	bool allowblock, cma;
> 
> 
> The line at 738 is:
> 
> 	cma = allowblock ? dev_get_cma_area(dev) : false;
> 
> 
> Which looks fine, dev_get_cma_area() takes a "struct device *" so not
> sure where sparse can be finding an integer, as cma and allowblock are
> both "bool" types.

Since the first side of the conditional (dev_get_cma_area()) returns
a pointer, the second side is also expected to be a pointer.
But here it's 'false' that is given, an integer of value 0, hence
the warning.

I agree, the message is very unclear and it would be better, to have
a message like: "mixing pointer & integer in conditional expression".

Best regards,
-- Luc



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux