1*c85f09ccSJohn Levon 2*c85f09ccSJohn Levon #define __kernel __attribute__((address_space(0))) 3*c85f09ccSJohn Levon #define __user __attribute__((address_space(__user))) 4*c85f09ccSJohn Levon #define __iomem __attribute__((address_space(__iomem))) 5*c85f09ccSJohn Levon #define __percpu __attribute__((address_space(__percpu))) 6*c85f09ccSJohn Levon #define __rcu __attribute__((address_space(__rcu))) 7*c85f09ccSJohn Levon 8*c85f09ccSJohn Levon 9*c85f09ccSJohn Levon typedef struct s obj_t; 10*c85f09ccSJohn Levon expl(obj_t __kernel * k,obj_t __iomem * o,obj_t __user * p,obj_t __percpu * pc,obj_t __rcu * r)11*c85f09ccSJohn Levonstatic void expl(obj_t __kernel *k, obj_t __iomem *o, 12*c85f09ccSJohn Levon obj_t __user *p, obj_t __percpu *pc, 13*c85f09ccSJohn Levon obj_t __rcu *r) 14*c85f09ccSJohn Levon { 15*c85f09ccSJohn Levon (__UINTPTR_TYPE__)(k); // OK 16*c85f09ccSJohn Levon (unsigned long)(k); // OK 17*c85f09ccSJohn Levon (void *)(k); // OK 18*c85f09ccSJohn Levon (obj_t*)(k); // OK 19*c85f09ccSJohn Levon (obj_t __kernel*)(k); // OK 20*c85f09ccSJohn Levon 21*c85f09ccSJohn Levon (__UINTPTR_TYPE__)(o); // OK 22*c85f09ccSJohn Levon (unsigned long)(o); // OK 23*c85f09ccSJohn Levon (void *)(o); 24*c85f09ccSJohn Levon (obj_t*)(o); 25*c85f09ccSJohn Levon (obj_t __iomem*)(o); // OK 26*c85f09ccSJohn Levon 27*c85f09ccSJohn Levon (__UINTPTR_TYPE__)(p); // OK 28*c85f09ccSJohn Levon (unsigned long)(p); // OK 29*c85f09ccSJohn Levon (void *)(p); 30*c85f09ccSJohn Levon (obj_t*)(p); 31*c85f09ccSJohn Levon (obj_t __user*)(p); // OK 32*c85f09ccSJohn Levon 33*c85f09ccSJohn Levon (__UINTPTR_TYPE__)(pc); // OK 34*c85f09ccSJohn Levon (unsigned long)(pc); // OK 35*c85f09ccSJohn Levon (void *)(pc); 36*c85f09ccSJohn Levon (obj_t*)(pc); 37*c85f09ccSJohn Levon (obj_t __percpu*)(pc); // OK 38*c85f09ccSJohn Levon 39*c85f09ccSJohn Levon (__UINTPTR_TYPE__)(r); // OK 40*c85f09ccSJohn Levon (unsigned long)(r); // OK 41*c85f09ccSJohn Levon (void *)(r); 42*c85f09ccSJohn Levon (obj_t*)(r); 43*c85f09ccSJohn Levon (obj_t __rcu*)(r); // OK 44*c85f09ccSJohn Levon } 45*c85f09ccSJohn Levon 46*c85f09ccSJohn Levon /* 47*c85f09ccSJohn Levon * check-name: Waddress-space-from 48*c85f09ccSJohn Levon * check-command: sparse -Wno-cast-from-as $file 49*c85f09ccSJohn Levon * check-description: Test the removal of AS from a pointer but only 50*c85f09ccSJohn Levon * in the non-strict variant where casts to ulong (or uintptr_t) 51*c85f09ccSJohn Levon * are allowed. 52*c85f09ccSJohn Levon * 53*c85f09ccSJohn Levon * check-error-start 54*c85f09ccSJohn Levon Waddress-space-from.c:23:10: warning: cast removes address space '__iomem' of expression 55*c85f09ccSJohn Levon Waddress-space-from.c:24:10: warning: cast removes address space '__iomem' of expression 56*c85f09ccSJohn Levon Waddress-space-from.c:29:10: warning: cast removes address space '__user' of expression 57*c85f09ccSJohn Levon Waddress-space-from.c:30:10: warning: cast removes address space '__user' of expression 58*c85f09ccSJohn Levon Waddress-space-from.c:35:10: warning: cast removes address space '__percpu' of expression 59*c85f09ccSJohn Levon Waddress-space-from.c:36:10: warning: cast removes address space '__percpu' of expression 60*c85f09ccSJohn Levon Waddress-space-from.c:41:10: warning: cast removes address space '__rcu' of expression 61*c85f09ccSJohn Levon Waddress-space-from.c:42:10: warning: cast removes address space '__rcu' of expression 62*c85f09ccSJohn Levon * check-error-end 63*c85f09ccSJohn Levon */ 64