Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp981126rdb; Sun, 1 Oct 2023 14:09:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGhcd9IJHaDTUhCGVQEeiU7nZNrvrxg1eQNk8qpMTA2lTgdL8UGylsbhEaNxytVQ8/Oeysg X-Received: by 2002:a17:90b:3882:b0:274:7db1:f50f with SMTP id mu2-20020a17090b388200b002747db1f50fmr16265495pjb.15.1696194591676; Sun, 01 Oct 2023 14:09:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696194591; cv=none; d=google.com; s=arc-20160816; b=Voy0/LG5uUdjQgCQilnnlEXg0obY7UhixiK/GEIR5tmM8BdQZBODjfekiynX3Z+Il8 B6wIqpOi06iyqMkpcUiCPgvl3mEtyYA9QOUw5r6T+OqJ6955pG/h3wSXP9l9F9foH5+3 PfYt1Fcttn/ZsweQ8e/MCWXWp9g5rMnB7P2oozv42haO1tPiKNleNlPWRAyqTuIv+lJY esW7cc+SFabb5fUXh0v4MB+nOvs/VwnH50d+UgcNigAyr8vcBBffk+lWEIPYkhEUy0MO eMaYMjbfwnixIwXHLQCDXNumzxp7gKWOqPFK4IAxX4ptjO7JzRAiRqAVN0LAXBdL+rFZ 0ydQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=nDfEN3OGY++zYr0m+FztDUGBIwYYLCRO+2vFv32Qj4A=; fh=qxjCNiS5g98dkD8P3jr+zlMGWfB+2bZW2S3H6Hry9Ug=; b=lJKHJX96Mvp67rceJD+pb+HSBRII9fM/pTmlfOhWTmrSikVr5pi1zG05VAso4Qh/Lu uczq9iJQg5tB4CqGWbKA5z0kmUfrWhe3zkfz5p2R9rYDzJJVuilCARm7LjmyKOFC9Viy 5af6rsLHkkuIiZ/+7dSos0PcizGOj9f3KXbn5efUFi2k46M/PPQRyvJlheDik1Kmvs/v hnjV9DlzG/nNsrGlX73BU6r641cbq/lHUYUowtf+XOIAV8wZRTQF/UPgNUQeg5r+darx AuLp6N57XaCSwKrl0TEQ8bE78CEUpzPVEyh2lHxsaP5uacvYqmZiZZ9db8u4SmfX5469 GYxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=WR15PE4a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id h9-20020a17090aa88900b0027677087be2si5937548pjq.108.2023.10.01.14.09.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Oct 2023 14:09:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=WR15PE4a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id A634980B1212; Sun, 1 Oct 2023 12:14:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235330AbjJATOL (ORCPT + 99 others); Sun, 1 Oct 2023 15:14:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59768 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235278AbjJATOK (ORCPT ); Sun, 1 Oct 2023 15:14:10 -0400 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB14BBD; Sun, 1 Oct 2023 12:14:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=nDfEN3OGY++zYr0m+FztDUGBIwYYLCRO+2vFv32Qj4A=; b=WR15PE4aznQUPolQLX97e9073F76EfezyzsR999iqeKR+dDxwDypbB5k 8msTc4dDnJ55RIW/ej7QPfHaJ2OQB+ggMW+ylvAfol2jGe+zT2oNO03av 238dDqcORLxBTl8rX623VAgbls3ijYaUEf0H0+WnVLiMk/L5ZKja+xxYC w=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=julia.lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.03,191,1694728800"; d="scan'208";a="67453919" Received: from 231.85.89.92.rev.sfr.net (HELO hadrien) ([92.89.85.231]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Oct 2023 21:14:03 +0200 Date: Sun, 1 Oct 2023 21:14:02 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Kees Cook cc: Julia Lawall , Kees Cook , Christophe JAILLET , Ian Abbott , H Hartley Sweeten , "Gustavo A. R. Silva" , Nathan Chancellor , Nick Desaulniers , Tom Rix , 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 In-Reply-To: <90E2BBA5-8A2D-42DE-B36A-CD37BABBB433@kernel.org> Message-ID: References: <5c3b7459b820e22e2ac6ce892d4aadcc119cc919.1696065263.git.christophe.jaillet@wanadoo.fr> <202309301342.5B5BED40A1@keescook> <90E2BBA5-8A2D-42DE-B36A-CD37BABBB433@kernel.org> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 01 Oct 2023 12:14:38 -0700 (PDT) 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 *)