Skip to contentSkip to conversation

struct/union attributes placement

DISCUSSION Randy Dunlap 1 participant 1 message Nov 29, 2006 Sparse checker

lore
Share & tools
lore
#0 lore raw

In 2.6.19-rc6-mm2, kvm places struct attributes between "struct" and the struct name (in drivers/kvm/kvm_main.c):

void fx_init(struct kvm_vcpu *vcpu)

{
	struct __attribute__ ((__packed__)) fx_image_s {
		u16 control; //fcw
		u16 status; //fsw
		u16 tag; // ftw
		u16 opcode; //fop
		u64 ip; // fpu ip
		u64 operand;// fpu dp
		u32 mxcsr;
		u32 mxcsr_mask;

	} *fx_image;

This is legal gcc according to
http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Type-Attributes.html#Type-Attributes

but sparse complains about it (and following usage statements):

drivers/kvm/kvm_main.c:473:9: error: Trying to use reserved word '__attribute__' as identifier
drivers/kvm/kvm_main.c:473:38: error: Expected ; at end of declaration
drivers/kvm/kvm_main.c:473:38: error: got fx_image_s
drivers/kvm/kvm_main.c:485:14: error: Expected ) in function declarator
drivers/kvm/kvm_main.c:485:14: error: got ->
drivers/kvm/kvm_main.c:487:14: error: Expected ) in function declarator
drivers/kvm/kvm_main.c:487:14: error: got ->
drivers/kvm/kvm_main.c:488:17: error: Expected ) in function declarator
drivers/kvm/kvm_main.c:488:17: error: got ->
drivers/kvm/kvm_main.c:491:10: error: Expected ; at end of declaration
drivers/kvm/kvm_main.c:491:10: error: got ->
drivers/kvm/kvm_main.c:492:13: error: Expected ) in function declarator
drivers/kvm/kvm_main.c:492:13: error: got ->
drivers/kvm/kvm_main.c:494:1: error: Expected ; end of type declaration
drivers/kvm/kvm_main.c:494:1: error: got }
drivers/kvm/kvm_main.c:490:2: error: symbol 'fx_image' redeclared with different type (originally declared at drivers/kvm/kvm_main.c:483) - different base types drivers/kvm/kvm_main.c:491:2: error: symbol 'fx_image' redeclared with different type (originally declared at drivers/kvm/kvm_main.c:483) - different base types

---
~Randy