Waddress-space-strict.c 988 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #define __user __attribute__((address_space(1)))
  2. typedef unsigned long ulong;
  3. typedef struct s obj_t;
  4. static void expl(ulong u, void *v, obj_t *o, obj_t __user *p)
  5. {
  6. (obj_t*)(u);
  7. (obj_t __user*)(u);
  8. (obj_t*)(v);
  9. (obj_t __user*)(v);
  10. (ulong)(o);
  11. (void *)(o);
  12. (obj_t*)(o);
  13. (obj_t __user*)(o);
  14. (ulong)(p); // w!
  15. (void *)(p); // w
  16. (obj_t*)(p); // w
  17. (obj_t __user*)(p); // ok
  18. }
  19. /*
  20. * check-name: Waddress-space-strict
  21. * check-command: sparse -Wcast-from-as -Wcast-to-as $file
  22. *
  23. * check-error-start
  24. Waddress-space-strict.c:12:10: warning: cast adds address space '<asn:1>' to expression
  25. Waddress-space-strict.c:17:10: warning: cast adds address space '<asn:1>' to expression
  26. Waddress-space-strict.c:19:10: warning: cast removes address space '<asn:1>' of expression
  27. Waddress-space-strict.c:20:10: warning: cast removes address space '<asn:1>' of expression
  28. Waddress-space-strict.c:21:10: warning: cast removes address space '<asn:1>' of expression
  29. * check-error-end
  30. */