xref: /illumos-gate/usr/src/tools/smatch/src/validation/ptr-sub-blows.c (revision 2a8bcb4efb45d99ac41c94a75c396b362c414f7f)
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 
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