Re: Can't get rid of sparse warning

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

 



Greg KH wrote:
On Sat, Nov 18, 2006 at 07:03:52PM -0600, Jay Cliburn wrote:
I'm getting the following warning from sparse on the line marked /* L523 */ down below. This is from an x86_64 installation of 2.6.19.rc6. I've included the relevant structs for reference.

I'd like to get the code fixed so sparse runs warning-free, but I'm having trouble understanding just what the warning tells me. (This is my first time using sparse.) Can you help by explaining it? Thanks.

Here's the sparse error:

drivers/net/atl1/atl1_main.c:523:25: warning: incorrect type in assignment (different base types) drivers/net/atl1/atl1_main.c:523:25: expected unsigned long long [unsigned] [usertype] buffer_addr drivers/net/atl1/atl1_main.c:523:25: got restricted unsigned long long [usertype] [force] <noident>
***********************************************

Here's the source code:
/* .h snippet */
typedef struct rx_free_desc {
	u64 buffer_addr;
	u16 buf_len;
	u16 coalese;
} _AT_ATTRIB_PACK_ rx_free_desc_t;

struct at_buffer {
	struct sk_buff *skb;
	u16 length;
	u16 alloced;
	dma_addr_t dma;  /*dma_addr_t is u64 on my system*/
};

/* .c snippet */
	struct at_buffer *buffer_info;
	rx_free_desc_t *rfd_desc;

And this is the line that generates the sparse warning:
/* L523 */ rfd_desc->buffer_addr = cpu_to_le64(buffer_info->dma);

buffer_addr is not marked as __le64, which it should be if you are going
to be putting a little endian 64 bit number in it.

Change that and you should get rid of the sparse warning.

Oh, and  you know that typedefs aren't recommended to be used in the
kernel, right?  See the file, Documentation/CodingStyle for more
details.

Thanks Greg.  I'll try the le annotations.

And thanks for the tip re typedefs. I'm working on a reference ethernet driver supplied by Attansic for inclusion in the mainline kernel. I don't work for Attansic, but they gave me permission to hack their GPL'd driver and submit it to lkml. It's been a lot more work than I thought, but I'm learning a good bit. Anyway, I'd change the typedefs, but I'm thrown off by the ATTRIB_PACK business. Can you suggest how to handle it?

#define _AT_ATTRIB_PACK_ __attribute__ ((packed))

typedef struct foo {
...
} _AT_ATTRIB_PACKED_ foo_t

What would this look like "un"typedef'd?

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux