[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] build: correct cppcheck-misra make rule


  • To: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Fri, 9 Sep 2022 16:26:09 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/PNFK4QrGosaJFaEnRBcEOUvt/MRsw6suUnT2k/Hc7c=; b=ERFUGghBFZqa3gV/y4r8m0bcKp9FMfMe9gpTZh0YtdKFexiRifoKICttOjbvRnaDamwL5ciPyOf3UjymRLWbx3J6MvUGvzx5SfV3rRtrFdsPGZQU5f63HFeTE2n6XWeTRBQrZ+6crm5lGDY8S6+P54rZzWDZolS8pbpGf2RsEjLR3do4a9hacfJUCkNLTPqA3QZ4doJsC567weDqcBUF8DHW4a7o66qOkTyddtCrU1nF/nXWkGYdnGvqoWO5sbV8H89y3uRm2F1KMa+ZNYwUc8hw0hck7ryKPdF/MYQkp9jeEMb9hOu1TsTjSDt1C5GuVROojSxGNHp1S5dwS3kGbg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=STPZleN/Xh1fYruCPhIYxappdC4DM1iu4fgl/+ylP2IyycoLUsQNu0r5a0wGN8rwcf/2pDbMYEnYzkXpXaX6UWeJF0rYpweVxOj+PII2qKlYz5ydyr/j5OlxPYS7oWGvDs1PEHdSL7f9CzFrr9hVbRr6FeXLF+DW1m4TMQAgB6nzK5CkQF3Fs6qcbIsYyXfYSY1PMsbCnV3Sx3QtugKDNmekg8XqYL1uuy/18ZOK5SvNWABykBZDlRQx0pcaChNTvYI+iuI4xw5cqajnA60DKVrnGwKn0nckKsk8R96ezXpx7IGJthTBYjFCuSHJGpef80PBiKl0cX3hlLuT+ylFxQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>
  • Delivery-date: Fri, 09 Sep 2022 14:26:17 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 09.09.2022 15:50, Bertrand Marquis wrote:
>> On 9 Sep 2022, at 14:41, Jan Beulich <jbeulich@xxxxxxxx> wrote:
>>
>> It has been bothering me for a while that I made a bad suggestion during
> 
> This is not a sentence for a commit message.

How else should I express the motivation for the change?

>> review: Having cppcheck-misra.json depend on cppcheck-misra.txt does not
>> properly address the multiple targets problem. If cppcheck-misra.json
>> is deleted from the build tree but cppcheck-misra.txt is still there,
>> nothing will re-generate cppcheck-misra.json.
>>
>> With GNU make 4.3 or newer we could use the &: grouped target separator,
>> but since we support older make as well we need to use some other
>> mechanism. Convert the rule to a pattern one (with "cppcheck"
>> arbitrarily chosen as the stem), thus making known to make that both
>> files are created by a single command invocation. Since, as a result,
>> the JSON file is now "intermediate" from make's perspective, prevent it
>> being deleted again by making it a prereq of .PRECIOUS.
>>
>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
>> ---
>> I've not been able to spot where / how cppcheck-misra.txt is used. If
>> it's indeed unused, a perhaps better alternative would be to convert the
>> original rule to specify cppcheck-misra.json as (the only) target. One
>> might then even consider using "-o /dev/null" instead of producing an
>> unused *.txt file.
> 
> Txt file is used by cppcheck to give a text description of the rule.
> If you look inside the json content you will see it mentioned.

Oh, that's properly hidden then.

>> --- a/xen/Makefile
>> +++ b/xen/Makefile
>> @@ -746,11 +746,9 @@ cppcheck-version:
>> # documentation file. Also generate a json file with the right arguments for
>> # cppcheck in json format including the list of rules to ignore.
>> #
>> -cppcheck-misra.txt: $(XEN_ROOT)/docs/misra/rules.rst 
>> $(srctree)/tools/convert_misra_doc.py
>> -    $(Q)$(PYTHON) $(srctree)/tools/convert_misra_doc.py -i $< -o $@ -j 
>> $(@:.txt=.json)
>> -
>> -# convert_misra_doc is generating both files.
>> -cppcheck-misra.json: cppcheck-misra.txt
>> +.PRECIOUS: %-misra.json
>> +%-misra.txt %-misra.json: $(XEN_ROOT)/docs/misra/rules.rst 
>> $(srctree)/tools/convert_misra_doc.py
>> +    $(Q)$(PYTHON) $(srctree)/tools/convert_misra_doc.py -i $< -o 
>> $*-misra.txt -j $*-misra.json
> 
> As far as I know, this is not saying to make that both files are generated by 
> this rule,
> but that this rule can generate both files so nothing is telling make here 
> that calling
> it once is enough I think.

As said in the description - it specifically has this effect. We're
using this elsewhere already, see e.g. tools/libs/light/Makefile
generating three headers and a C file all in one go. Iirc this is
also explicitly described in make documentation (and contrasted to
the different behavior for non-pattern rules).

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.