All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@inria.fr>
To: Kees Cook <kees@kernel.org>
Cc: Julia Lawall <julia.lawall@inria.fr>,
	Kees Cook <keescook@chromium.org>,
	Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	Ian Abbott <abbotti@mev.co.uk>,
	H Hartley Sweeten <hsweeten@visionengravers.com>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Tom Rix <trix@redhat.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-hardening@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH] comedi: Annotate struct comedi_lrange with __counted_by
Date: Sun, 1 Oct 2023 21:14:02 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2310012112560.3166@hadrien> (raw)
In-Reply-To: <90E2BBA5-8A2D-42DE-B36A-CD37BABBB433@kernel.org>

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 *)

  reply	other threads:[~2023-10-01 19:14 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-30  9:14 [PATCH] comedi: Annotate struct comedi_lrange with __counted_by Christophe JAILLET
2023-09-30 20:57 ` Kees Cook
2023-10-01  7:25   ` Julia Lawall
2023-10-01  7:50     ` Christophe JAILLET
2023-10-01  7:45   ` Julia Lawall
2023-10-01 15:26     ` Kees Cook
2023-10-01 19:14       ` Julia Lawall [this message]
2023-10-01 21:05         ` Kees Cook
2023-10-01 21:22           ` Kees Cook
2023-10-01 22:21             ` Kees Cook
2023-10-02  5:38               ` Julia Lawall
2023-10-02  7:36                 ` Kees Cook
2023-11-05 21:27             ` Christophe JAILLET
2023-10-01  6:43 ` Gustavo A. R. Silva

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.22.394.2310012112560.3166@hadrien \
    --to=julia.lawall@inria.fr \
    --cc=abbotti@mev.co.uk \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=gustavoars@kernel.org \
    --cc=hsweeten@visionengravers.com \
    --cc=kees@kernel.org \
    --cc=keescook@chromium.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=trix@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.