17f904d7eSThomas Gleixner// SPDX-License-Identifier: GPL-2.0-only 22cbd0825SJulia Lawall/// sizeof when applied to a pointer typed expression gives the size of 32cbd0825SJulia Lawall/// the pointer 42cbd0825SJulia Lawall/// 52cbd0825SJulia Lawall// Confidence: High 67f904d7eSThomas Gleixner// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. 77f904d7eSThomas Gleixner// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. 8*f01701ceSJulia Lawall// URL: https://coccinelle.gitlabpages.inria.fr/website 92cbd0825SJulia Lawall// Comments: 1093f14468SNicolas Palix// Options: --no-includes --include-headers 112cbd0825SJulia Lawall 122cbd0825SJulia Lawallvirtual org 132cbd0825SJulia Lawallvirtual report 142cbd0825SJulia Lawallvirtual context 152cbd0825SJulia Lawallvirtual patch 162cbd0825SJulia Lawall 172cbd0825SJulia Lawall@depends on patch@ 182cbd0825SJulia Lawallexpression *x; 192cbd0825SJulia Lawallexpression f; 20bf56cc04SVaishali Thakkarexpression i; 212cbd0825SJulia Lawalltype T; 222cbd0825SJulia Lawall@@ 232cbd0825SJulia Lawall 242cbd0825SJulia Lawall( 252cbd0825SJulia Lawallx = <+... sizeof( 262cbd0825SJulia Lawall- x 272cbd0825SJulia Lawall+ *x 282cbd0825SJulia Lawall ) ...+> 292cbd0825SJulia Lawall| 302cbd0825SJulia Lawallf(...,(T)(x),...,sizeof( 312cbd0825SJulia Lawall- x 322cbd0825SJulia Lawall+ *x 332cbd0825SJulia Lawall ),...) 342cbd0825SJulia Lawall| 35bf56cc04SVaishali Thakkarf(...,sizeof( 36bf56cc04SVaishali Thakkar- x 37bf56cc04SVaishali Thakkar+ *x 38bf56cc04SVaishali Thakkar ),...,(T)(x),...) 39bf56cc04SVaishali Thakkar| 40bf56cc04SVaishali Thakkarf(...,(T)(x),...,i*sizeof( 412cbd0825SJulia Lawall- x 422cbd0825SJulia Lawall+ *x 432cbd0825SJulia Lawall ),...) 44bf56cc04SVaishali Thakkar| 45bf56cc04SVaishali Thakkarf(...,i*sizeof( 46bf56cc04SVaishali Thakkar- x 47bf56cc04SVaishali Thakkar+ *x 48bf56cc04SVaishali Thakkar ),...,(T)(x),...) 492cbd0825SJulia Lawall) 502cbd0825SJulia Lawall 512cbd0825SJulia Lawall@r depends on !patch@ 522cbd0825SJulia Lawallexpression *x; 532cbd0825SJulia Lawallexpression f; 54bf56cc04SVaishali Thakkarexpression i; 552cbd0825SJulia Lawallposition p; 562cbd0825SJulia Lawalltype T; 572cbd0825SJulia Lawall@@ 582cbd0825SJulia Lawall 592cbd0825SJulia Lawall( 602cbd0825SJulia Lawall*x = <+... sizeof@p(x) ...+> 612cbd0825SJulia Lawall| 622cbd0825SJulia Lawall*f(...,(T)(x),...,sizeof@p(x),...) 632cbd0825SJulia Lawall| 642cbd0825SJulia Lawall*f(...,sizeof@p(x),...,(T)(x),...) 65bf56cc04SVaishali Thakkar| 66bf56cc04SVaishali Thakkar*f(...,(T)(x),...,i*sizeof@p(x),...) 67bf56cc04SVaishali Thakkar| 68bf56cc04SVaishali Thakkar*f(...,i*sizeof@p(x),...,(T)(x),...) 692cbd0825SJulia Lawall) 702cbd0825SJulia Lawall 712cbd0825SJulia Lawall@script:python depends on org@ 722cbd0825SJulia Lawallp << r.p; 732cbd0825SJulia Lawall@@ 742cbd0825SJulia Lawall 752cbd0825SJulia Lawallcocci.print_main("application of sizeof to pointer",p) 762cbd0825SJulia Lawall 772cbd0825SJulia Lawall@script:python depends on report@ 782cbd0825SJulia Lawallp << r.p; 792cbd0825SJulia Lawall@@ 802cbd0825SJulia Lawall 812cbd0825SJulia Lawallmsg = "ERROR: application of sizeof to pointer" 822cbd0825SJulia Lawallcoccilib.report.print_report(p[0],msg) 83