xref: /illumos-gate/usr/src/tools/smatch/src/validation/ptr-sub-blows.c (revision c85f09cc92abd00c84e58ec9f0f5d942906cb713)

ok(int * a,int * b)1 static int ok(int *a, int *b)
2 {
3 	return a - b;
4 }
5 
6 struct s {
7 	int a, b, c;
8 };
9 
ko(struct s * a,struct s * b)10 static int ko(struct s *a, struct s *b)
11 {
12 	return a - b;
13 }
14 
15 /*
16  * check-name: ptr-sub-blows
17  * check-command: sparse -Wptr-subtraction-blows $file
18  *
19  * check-error-start
20 ptr-sub-blows.c:12:18: warning: potentially expensive pointer subtraction
21 ptr-sub-blows.c:12:18:     'struct s' has a non-power-of-2 size: 12
22  * check-error-end
23  */
24