Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2485268pxb; Tue, 13 Apr 2021 03:09:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxci1V9h3ipBnvsipWH9JDwpADpVmD5GV7zr6OcGrpBx7igqsvR3615UUjU8noOIWa2EIPv X-Received: by 2002:a05:6402:4d1:: with SMTP id n17mr33276853edw.118.1618308550545; Tue, 13 Apr 2021 03:09:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618308550; cv=none; d=google.com; s=arc-20160816; b=k1cpMfRST7QH7oZx1ftLbDwCPI0uDlTwztFwBtBvvdN0poZ7FH9oMc2IxLwjXPqCkA +bMbzi8GVlSdbhv+P6qJc/CYG5hL5yZ9aWuIrWW13GZ+hcd13u0znN2mtmP71BQmidgI tRehkCbNOXU25WrHTtiP3feUt9xJqrFo6KyEJdSzQ2xnrpyR3+pc+I+y0BSXHS3W1BLs 8im3o+Af+YkK2g42fNbg6Sjr9Dk33+hZp7LIU1DZq84c6t49BQOxuT1gc/xRhRUxBjRD AoSPve5cLo+gv/qQimw0o5XnHnugwT72xsTREVTvy2GEQCCCB84zVzPHHHmW8yu4pvkf nclA== 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:ironport-hdrordr; bh=3PIP8SU9weAjC1DwRuvDMcBu/0+dESStcNrSANXxqsc=; b=BJxL++qZ0ycpMJsQfOoDBigJMRK6XJCI/SwzBUgGWKdWEElupeWHnQb801VIduQiad zy8twUOnU9MDfaHAJxIJZvwOqt9+BkQrTfx1jlQ9IwrdlTqJcCAybMzMkAgK95pqAx91 Ne1iCgXPPxjhieXz6zCtO7uEGYNjmpOLKAs+R0feq8VzAKJoSFlcIukyljZH5Y38JgpJ G/EoIPewkfvxG8znrJbLQikOVZoiwphBdMPsyPnVEjj50xJ3y5FpsvfElY4c73AT9xrU xkhdvQufCxWaZYVzUxh1KnT4Wpe0/BWcMwS809wWlKLkBAKYcEZe3nAJIqXgxiCKWxQN of8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v11si9531498eje.681.2021.04.13.03.08.45; Tue, 13 Apr 2021 03:09:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238683AbhDMJ4w (ORCPT + 99 others); Tue, 13 Apr 2021 05:56:52 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:2554 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231320AbhDMJ4l (ORCPT ); Tue, 13 Apr 2021 05:56:41 -0400 IronPort-HdrOrdr: =?us-ascii?q?A9a23=3AFqbHTaq7g8Ab45sZyXkxT8saV5t/L9V00zAX?= =?us-ascii?q?/kB9WHVpW+afkN2jm+le8BfyhioYVn1Io6H4BICrR3TA+ZlppbQAJLvKZniFhE?= =?us-ascii?q?KEJJxvhLGC/xTOACv7n9Q26Y5Bd7F5E8D5ClJ35PyKmDWQM9Fl+9Wf9bDtuOG2?= =?us-ascii?q?9RhQZCVLT40l0AtjEAacFSRNNWp7LL40DoCV6MYChxfIQxQqR/+2DHUEQOTPzu?= =?us-ascii?q?ej/K7OWhIICwUq7wODl1qThILSKBSA2wdbbjUn+9wf2FLYmA/07LjLiZ+G4yLc?= =?us-ascii?q?zGPa4tB3n9bs27J4daqxo/USQw+Ati+YIKBaf7WDuXQNu+Go81Y2gLD30nMdFv?= =?us-ascii?q?U2z3vQe22vyCGdvDXI4XIW8H/l0l+EkRLY0KnEeA4=3D?= X-IronPort-AV: E=Sophos;i="5.82,219,1613430000"; d="scan'208";a="502961834" Received: from 173.121.68.85.rev.sfr.net (HELO hadrien) ([85.68.121.173]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Apr 2021 11:56:21 +0200 Date: Tue, 13 Apr 2021 11:56:20 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Fabio Aiuto cc: gregkh@linuxfoundation.org, joe@perches.com, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: cocci script hints request In-Reply-To: <20210413090400.GA5477@agape.jhs> Message-ID: References: <20210413090400.GA5477@agape.jhs> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 13 Apr 2021, Fabio Aiuto wrote: > Hi, > > I would like to improve the following coccinelle script: > > @@ > expression a, fmt; > expression list var_args; > @@ > > - DBG_871X_LEVEL(a, fmt, var_args); > + printk(fmt, var_args); > > I would replace the DBG_871X_LEVEL macro with printk, but > I can't find a way to add KERN_* constant prefix to the fmt > argument in the + code line. If i try this > > @@ > expression a, fmt; > expression list var_args; > @@ > > - DBG_871X_LEVEL(a, fmt, var_args); > + printk(KERN_DEBUG fmt, var_args); > > plus: parse error: > File "../test.cocci", line 94, column 20, charpos = 1171 > around = 'fmt', > whole content = + printk(KERN_DEBUG fmt, var_args); > > how could I do this? Although I certainly agree with Greg, I'll answer the question from a technical point of view. I'm not sure that that kind of compound string is supported for a metavariable. It is possible to get around this problem using a python script. If you ever need to do this for a better reason, you can take a look at demos/pythontococci.cocci in the Coccinelle source code distribution. julia