lkml.org 
[lkml]   [2023]   [Oct]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] comedi: Annotate struct comedi_lrange with __counted_by
Kees,

You can try the following.

julia

#spatch --all-includes

@r@
identifier i,j;
type T;
@@

struct i {
...
T j[];
}

@s@
identifier r.i;
constant ini;
identifier j;
initializer list [n] is2;
position p;
identifier x;
@@

struct i@p x =
{ ...,
.j = ini,
...,
{ is2 } }
;

@script:ocaml@
ini << s.ini;
i << r.i;
j << s.j;
n << s.n;
p << s.p;
@@

try
let ini = int_of_string ini in
if n = ini
then Printf.printf "%s:%d: struct %s: field %s is the counter for the flex array\n" (List.hd p).file (List.hd p).line i j
with _-> () (* not an explicit integer *)

@s2@
identifier r.i;
constant ini;
initializer list [n] is;
initializer list [n2] is2;
position p;
identifier x;
@@

struct i@p x =
{ is,
ini,
...,
{ is2 } };

@script:ocaml@
ini << s2.ini;
i << r.i;
n << s2.n;
n2 << s2.n2;
p << s2.p;
@@

try
let ini = int_of_string ini in
if n2 = ini
then Printf.printf "%s:%d: struct %s: field at offset %d is the counter for the flex array\n" (List.hd p).file (List.hd p).line i n
with _-> () (* not an explicit integer *)

\
 
 \ /
  Last update: 2023-10-01 21:15    [W:0.307 / U:0.440 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site