summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-09-09 23:20:31 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2018-09-10 00:54:38 +0200
commit16517102991cab96722a90859ec9be50852747a1 (patch)
tree18a08b153202f82ec58a1e6a8e93b882be97a221
parent20042e2851a6ff07232f1a5ac3da4413499bc4d3 (diff)
downloadsparse-16517102991cab96722a90859ec9be50852747a1.tar.gz
test: make test Waddress-space-strict succeed on 32-bit
The test Waddress-space-strict made assumptions about the relative size of integers & pointers. Since this test was crafted on a 64-bit machine, the test was running fine for LP64 but failed on a 32-bit machine (or anything using IP32, like using the -m32 option). However, since the test is about conversion of address-spaces, using integers of different size adds no value, and indeed brings problems. Fix this by limiting the conversions to a single integer type, the one with the same size as pointers on ILP32 & LP64: long. Reported-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r--validation/Waddress-space-strict.c33
1 files changed, 7 insertions, 26 deletions
diff --git a/validation/Waddress-space-strict.c b/validation/Waddress-space-strict.c
index 5071aab2..871da282 100644
--- a/validation/Waddress-space-strict.c
+++ b/validation/Waddress-space-strict.c
@@ -1,33 +1,22 @@
#define __user __attribute__((address_space(1)))
typedef unsigned long ulong;
-typedef long long llong;
typedef struct s obj_t;
-static void expl(int i, ulong u, llong l, void *v, obj_t *o, obj_t __user *p)
+static void expl(ulong u, void *v, obj_t *o, obj_t __user *p)
{
- (obj_t*)(i);
- (obj_t __user*)(i);
-
(obj_t*)(u);
(obj_t __user*)(u);
- (obj_t*)(l);
- (obj_t __user*)(l);
-
(obj_t*)(v);
(obj_t __user*)(v);
- (int)(o);
(ulong)(o);
- (llong)(o);
(void *)(o);
(obj_t*)(o);
(obj_t __user*)(o);
- (int)(p); // w
(ulong)(p); // w!
- (llong)(p); // w
(void *)(p); // w
(obj_t*)(p); // w
(obj_t __user*)(p); // ok
@@ -38,19 +27,11 @@ static void expl(int i, ulong u, llong l, void *v, obj_t *o, obj_t __user *p)
* check-command: sparse -Wcast-from-as -Wcast-to-as $file
*
* check-error-start
-Waddress-space-strict.c:10:10: warning: cast adds address space to expression (<asn:1>)
-Waddress-space-strict.c:13:10: warning: cast adds address space to expression (<asn:1>)
-Waddress-space-strict.c:16:10: warning: cast adds address space to expression (<asn:1>)
-Waddress-space-strict.c:19:10: warning: cast adds address space to expression (<asn:1>)
-Waddress-space-strict.c:26:10: warning: cast adds address space to expression (<asn:1>)
-Waddress-space-strict.c:28:10: warning: cast removes address space of expression
-Waddress-space-strict.c:29:10: warning: cast removes address space of expression
-Waddress-space-strict.c:30:10: warning: cast removes address space of expression
-Waddress-space-strict.c:31:10: warning: cast removes address space of expression
-Waddress-space-strict.c:32:10: warning: cast removes address space of expression
-Waddress-space-strict.c:9:18: warning: non size-preserving integer to pointer cast
-Waddress-space-strict.c:10:25: warning: non size-preserving integer to pointer cast
-Waddress-space-strict.c:21:15: warning: non size-preserving pointer to integer cast
-Waddress-space-strict.c:28:15: warning: non size-preserving pointer to integer cast
+Waddress-space-strict.c:9:10: warning: cast adds address space to expression (<asn:1>)
+Waddress-space-strict.c:12:10: warning: cast adds address space to expression (<asn:1>)
+Waddress-space-strict.c:17:10: warning: cast adds address space to expression (<asn:1>)
+Waddress-space-strict.c:19:10: warning: cast removes address space of expression
+Waddress-space-strict.c:20:10: warning: cast removes address space of expression
+Waddress-space-strict.c:21:10: warning: cast removes address space of expression
* check-error-end
*/