2019-06-04 10:11:38 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2012-04-21 20:23:48 +02:00
|
|
|
/// sizeof when applied to a pointer typed expression gives the size of
|
|
|
|
/// the pointer
|
|
|
|
///
|
|
|
|
// Confidence: High
|
2019-06-04 10:11:38 +02:00
|
|
|
// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6.
|
|
|
|
// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.
|
2012-04-21 20:23:48 +02:00
|
|
|
// URL: http://coccinelle.lip6.fr/
|
|
|
|
// Comments:
|
2013-06-20 13:10:56 +02:00
|
|
|
// Options: --no-includes --include-headers
|
2012-04-21 20:23:48 +02:00
|
|
|
|
|
|
|
virtual org
|
|
|
|
virtual report
|
|
|
|
virtual context
|
|
|
|
virtual patch
|
|
|
|
|
|
|
|
@depends on patch@
|
|
|
|
expression *x;
|
|
|
|
expression f;
|
2016-05-24 06:19:17 +02:00
|
|
|
expression i;
|
2012-04-21 20:23:48 +02:00
|
|
|
type T;
|
|
|
|
@@
|
|
|
|
|
|
|
|
(
|
|
|
|
x = <+... sizeof(
|
|
|
|
- x
|
|
|
|
+ *x
|
|
|
|
) ...+>
|
|
|
|
|
|
|
|
|
f(...,(T)(x),...,sizeof(
|
|
|
|
- x
|
|
|
|
+ *x
|
|
|
|
),...)
|
|
|
|
|
|
2016-05-24 06:19:17 +02:00
|
|
|
f(...,sizeof(
|
|
|
|
- x
|
|
|
|
+ *x
|
|
|
|
),...,(T)(x),...)
|
|
|
|
|
|
|
|
|
f(...,(T)(x),...,i*sizeof(
|
2012-04-21 20:23:48 +02:00
|
|
|
- x
|
|
|
|
+ *x
|
|
|
|
),...)
|
2016-05-24 06:19:17 +02:00
|
|
|
|
|
|
|
|
f(...,i*sizeof(
|
|
|
|
- x
|
|
|
|
+ *x
|
|
|
|
),...,(T)(x),...)
|
2012-04-21 20:23:48 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@r depends on !patch@
|
|
|
|
expression *x;
|
|
|
|
expression f;
|
2016-05-24 06:19:17 +02:00
|
|
|
expression i;
|
2012-04-21 20:23:48 +02:00
|
|
|
position p;
|
|
|
|
type T;
|
|
|
|
@@
|
|
|
|
|
|
|
|
(
|
|
|
|
*x = <+... sizeof@p(x) ...+>
|
|
|
|
|
|
|
|
|
*f(...,(T)(x),...,sizeof@p(x),...)
|
|
|
|
|
|
|
|
|
*f(...,sizeof@p(x),...,(T)(x),...)
|
2016-05-24 06:19:17 +02:00
|
|
|
|
|
|
|
|
*f(...,(T)(x),...,i*sizeof@p(x),...)
|
|
|
|
|
|
|
|
|
*f(...,i*sizeof@p(x),...,(T)(x),...)
|
2012-04-21 20:23:48 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
@script:python depends on org@
|
|
|
|
p << r.p;
|
|
|
|
@@
|
|
|
|
|
|
|
|
cocci.print_main("application of sizeof to pointer",p)
|
|
|
|
|
|
|
|
@script:python depends on report@
|
|
|
|
p << r.p;
|
|
|
|
@@
|
|
|
|
|
|
|
|
msg = "ERROR: application of sizeof to pointer"
|
|
|
|
coccilib.report.print_report(p[0],msg)
|