From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3215 2.6.0.0/16 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by dcvr.yhbt.net (Postfix) with ESMTP id 7EF8A1F54E for ; Tue, 30 Aug 2022 21:32:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229875AbiH3Vc2 (ORCPT ); Tue, 30 Aug 2022 17:32:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229640AbiH3Vc0 (ORCPT ); Tue, 30 Aug 2022 17:32:26 -0400 Received: from cloud.peff.net (cloud.peff.net [104.130.231.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C26EC89900 for ; Tue, 30 Aug 2022 14:32:25 -0700 (PDT) Received: (qmail 7917 invoked by uid 109); 30 Aug 2022 21:32:25 -0000 Received: from Unknown (HELO peff.net) (10.0.1.2) by cloud.peff.net (qpsmtpd/0.94) with ESMTP; Tue, 30 Aug 2022 21:32:25 +0000 Authentication-Results: cloud.peff.net; auth=none Received: (qmail 30159 invoked by uid 111); 30 Aug 2022 21:32:25 -0000 Received: from coredump.intra.peff.net (HELO sigill.intra.peff.net) (10.0.0.2) by peff.net (qpsmtpd/0.94) with (TLS_AES_256_GCM_SHA384 encrypted) ESMTPS; Tue, 30 Aug 2022 17:32:25 -0400 Authentication-Results: peff.net; auth=none Date: Tue, 30 Aug 2022 17:32:24 -0400 From: Jeff King To: Johannes Schindelin Cc: phillip.wood@dunelm.org.uk, Johannes Schindelin via GitGitGadget , git@vger.kernel.org Subject: Re: validating signed/unsigned comparisons with Coccinelle, was Re: [PATCH 0/3] A couple of CI fixes regarding the built-in add --patch Message-ID: References: <73spp934-1q41-1123-41no-q2337954op92@tzk.qr> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <73spp934-1q41-1123-41no-q2337954op92@tzk.qr> Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Tue, Aug 30, 2022 at 11:12:24PM +0200, Johannes Schindelin wrote: > On Tue, 30 Aug 2022, Phillip Wood wrote: > > > I wonder if they would be interested in fixing the parsing bug we found > > with Peff's UNUSED() series. > > Could you point me to the relevant mail? I am sure that I can come up with > an MCVE that will help them pinpoint the bug and fix it as quickly as they > did with this here bug. It's the sub-thread starting here: https://lore.kernel.org/git/220825.86ilmg4mil.gmgdl@evledraar.gmail.com/ I tried to put together a minimal example, which would be something like: $ cat foo.c void old_function(int); void new_function(int); #if defined(__GNUC__) #define UNUSED(var) UNUSED_##var __attribute__((unused)) #else #define UNUSED(var) UNUSED_##var #endif void foo(int UNUSED(bar), int x) { old_function(x); } $ cat foo.cocci @@ expression E; @@ -old_function(E) +new_function(E) but to my frustration, it actually works! If you add --verbose-parsing to the spatch command, you can see it complaining about some of the parsing. And it produces wrong outputs in the real-world with our actual unused.cocci file. I suspect the example semantic patch might just need to be a little more complicated. -Peff