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

Re: [RFC PATCH 1/4] xen/Makefile: add analysis-coverity and analysis-eclair


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Tue, 8 Nov 2022 14:00:35 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=2; 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=7c0pFD1+SOhmYB3zIrRf6nhJd/BNXs/pYswEKagG/OU=; b=JRA5+28kDAmmM+v2GXyKjkrZ1BEjgZl7A5FcihZ7JaOCQjN720N4K3Ham5epWlaK/RoV1UQGD+Nq3v5Od0JTX8QDfY58/x+xT1ECAAU0WRS4qwIY5ux90hxsyWSUVReKZ1eHghWl5CdMogFaamO8GrPSlrJXUezrJqffxApCRlsN9MVPqOBtCwaBR0DYp5n2inxpqwJtWz6xSW5hGEz0xpUMJzvKX4cUjLg5HS3VN4B6FPyjEmvtxzI3vUDUdL1e2pM5x+V4FbxyPzSDvOYTdvcIHbIQ6zKEktQeGB+iv4Q60mjmz7pwXWN1iVYZaU5KnpwQJw4E2ral2SJcxIMTcw==
  • 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=7c0pFD1+SOhmYB3zIrRf6nhJd/BNXs/pYswEKagG/OU=; b=XZtILcLCIk8COEN0LVvEle6gQuGBEIqiAhuNnLSPbzC1l5OuRNK6mpugdxFzUhE7ZXa4QOitpwlbTr+8++1P0sie2q/5QZaELosY2WOWXDpxXPbClsUpoQ+sA2I5omlOEM+FT4h2O8NgvNgll5Gr7G6So0HmOsN0jQhi3p1Fc0Dr2P1pvF/+YfvsLPYoOKBceSOTUtqZafeZ/1KYS91Ptb6jAiOV0V+8QcXHxZnHzcBd+6RJ84t7gb44Uv0ILqdV6VFJqO06aff53Hrvc6/YbuVFmf2R4kG7+8eVIB5DT5K7cAC2gZ3W/wBaRITdIoFHKmqZVHYVDnIWKjqg2MJ8Fg==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=S4RCHAXXpSwM5zDiUM1p77yj37k5+yfms9AeN0yBv6dF/NHbr/QT541gGiLd8+u35WsXUeWpgc9qWXCPo0WUlrbIRCjaIU03LApxfL8c9/aqn4WW3tWpuHWHqnQx3TssOY1lmSrXGNTxlv96nuOgdQSdyJMoBBg6JGKklEyGRTOY0etrgVmzs7E6J6sAz0Oq6Rt6B3xqfOqR5YkXaUftyr/uMovvyifUPOGC+w5eS7VAlbfppTc7i1mHXpHrERsxW/vMHpxEo9gkarCCj2DNvHR86waOIHY6QPvZm4dZPOuyP11um8pC2dwmVIhIke4Yr983sKMmxsX90Nnudzu54A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MxLIGTXkB/I6lBbDJkCx7Mo1KdO8saRBDc11ZQ9cpvdxjbl8o7W8b6ir4HCBpz5WtC7eygVhw70CodRKfUYlimuNiq9rUv1UlDlwKtpQfanDRfpbLsUk5Xc8Mgf1InQv+ziAxdSPb64/fYWLnLfmIm3Ne9e8pMTsXIHqr41MJcPiETp8cVPHnREkDgNlBpFa1QgNDruXIJeQubZkFj0XwtH0NZMcKU/IiwU12/GuI5o1xJ33tsl2/OhRPxog2no8ZhQqvS7SopzddV+37Ggf+DZGzCqAZFdVLPrq1+XxYdbn6cwfjCwCzOay2rnSCP3SgCI9vVVI3R/26Gad7sITjA==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Wei Chen <Wei.Chen@xxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 08 Nov 2022 14:00:56 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHY8pZ008DS0BACDkyhs+OWN8Oan64zqLWAgAE0WoCAAA3SgIAAJOMA
  • Thread-topic: [RFC PATCH 1/4] xen/Makefile: add analysis-coverity and analysis-eclair


> On 8 Nov 2022, at 11:48, Jan Beulich <jbeulich@xxxxxxxx> wrote:
> 
> On 08.11.2022 11:59, Luca Fancellu wrote:
>>> On 07.11.2022 11:47, Luca Fancellu wrote:
>>>> +Here is an example to add a new justification in 
>>>> false-positive-<tool>.json::
>>> 
>>> With <tool> already present in the name, ...
>>> 
>>>> +|{
>>>> +|    "version": "1.0",
>>>> +|    "content": [
>>>> +|        {
>>>> +|            "id": "SAF-0-false-positive-<tool>",
>>>> +|            "analyser": {
>>>> +|                "<tool>": "<proprietary-id>"
>>> 
>>> ... can we avoid the redundancy here? Perhaps ...
>>> 
>>>> +|            },
>>>> +|            "tool-version": "<version>",
>>> 
>>> ... it could be
>>> 
>>>           "analyser": {
>>>               "<version>": "<proprietary-id>"
>>>           },
>> 
>> Yes it’s a bit redundant but it helps re-using the same tool we use for 
>> safe.json
> 
> I guess the tool could also be made cope without much effort.

I can modify the script to take an additional parameter to distinguish between 
safe.json
and false-positive-*.json, then call twice the script and append the result to 
the .sed file.

> 
>>>> @@ -757,6 +758,51 @@ cppcheck-version:
>>>> $(objtree)/include/generated/compiler-def.h:
>>>>    $(Q)$(CC) -dM -E -o $@ - < /dev/null
>>>> 
>>>> +JUSTIFICATION_FILES := $(XEN_ROOT)/docs/misra/safe.json \
>>>> +                       $(XEN_ROOT)/docs/misra/false-positive-$$*.json
>>>> +
>>>> +# The following command is using grep to find all files that contains a 
>>>> comment
>>>> +# containing "SAF-<anything>" on a single line.
>>>> +# %.safparse will be the original files saved from the build system, 
>>>> these files
>>>> +# will be restored at the end of the analysis step
>>>> +PARSE_FILE_LIST := $(addsuffix .safparse,$(filter-out %.safparse,\
>>>> +$(shell grep -ERl '^[[:blank:]]*\/\*[[:space:]]+SAF-.*\*\/$$' 
>>>> $(srctree))))
>>> 
>>> Please indent such line continuations. And then isn't this going to risk
>>> matching non-source files as well? Perhaps you want to restrict this to
>>> *.c and *.h?
>> 
>> Yes, how about this, it will filter out *.safparse files while keeping in 
>> only .h and .c:
>> 
>> PARSE_FILE_LIST := $(addsuffix .safparse,$(filter %.c %.h,\
>>    $(shell grep -ERl '^[[:blank:]]*\/\*[[:space:]]+SAF-.*\*\/$$' 
>> $(srctree))))
> 
> That's better, but still means touching all files by grep despite now
> only a subset really looked for. If I was to use the new goals on a
> more or less regular basis, I'd expect that this enumeration of files
> doesn't read _much_ more stuff from disk than is actually necessary.

Ok would it be ok?

PARSE_FILE_LIST := $(addsuffix .safparse,$(shell grep -ERl --include=\*.h \
    --include=\*.c '^[[:blank:]]*\/\*[[:space:]]+SAF-.*\*\/$$' $(srctree)))

> 
>>> To limit work done, could this me "mv" instead of "cp -p", and then ...
>>> 
>>>> +analysis-parse-tags-%: $(PARSE_FILE_LIST) $(objtree)/%.sed
>>>> +  $(Q)for file in $(patsubst %.safparse,%,$(PARSE_FILE_LIST)); do \
>>>> +          sed -i -f "$(objtree)/$*.sed" "$${file}"; \
>>> 
>>> ... with then using
>>> 
>>>             sed -f "$(objtree)/$*.sed" "$${file}.safparse" >"$${file}"
>>> 
>>> here? This would then also have source consistent between prereqs and
>>> rule.
>> 
>> We saw that mv is not preserving the timestamp of the file, instead we would 
>> like to preserve
>> it, for this reason we used cp -p
> 
> Buggy mv? It certainly doesn't alter timestamps here, and I don't think
> the spec allows for it doing so (at least when it doesn't need to resort
> to copying to deal with cross-volume moves, but those can't happen here).

Yes you are right, my assumption was wrong, I will change the code as you 
suggested.

> 
>>>> +  done
>>>> +
>>>> +analysis-build-%: analysis-parse-tags-%
>>>> +  $(MAKE) O=$(abs_objtree) -f $(srctree)/Makefile build
>>> 
>>> This rule doesn't use the stem, so I'm struggling to understand what
>>> this is about.
>> 
>> Yes, here my aim was to catch analysis-build-{eclair,coverity}, here I see 
>> that if the user has a typo
>> the rule will run anyway, but it will be stopped by the dependency chain 
>> because at the end we have:
>> 
>> JUSTIFICATION_FILES := $(XEN_ROOT)/docs/misra/safe.json \
>>                       $(XEN_ROOT)/docs/misra/false-positive-$$*.json
>> 
>> That will give an error because 
>> $(XEN_ROOT)/docs/misra/false-positive-<typo>.json does not exists.
>> 
>> If you think it is not enough, what if I reduce the scope of the rule like 
>> this?
>> 
>> _analysis-coverity _analysis-eclair: _analysis-%: analysis-build-%
> 
> But then, without using the stem, how does it know whether to do an
> Eclair or a Coverity run?

Sorry I think I’m a bit lost here, the makefile is working on both 
analysis-coverity and analysis-eclair
because the % is solving in coverity or eclair depending on which the makefile 
has in input, it is not complaining
so I guess it works.
Do you see something not working? If so, are you able to provide a piece of 
code for that to make me understand?

> 
>> Or, if you are still worried about “analysis-build-%: 
>> analysis-parse-tags-%”, then I can do something
>> like this: 
>> 
>> analysis-supported-coverity analysis-supported-eclair:
>>    @echo > /dev/null
>> 
>> analysis-supported-%:
>>    @error Unsupported analysis tool @*
>> 
>> analysis-build-%: analysis-parse-tags-% | analysis-supported-%
>>    $(MAKE) O=$(abs_objtree) -f $(srctree)/Makefile build
> 
> If I'm not mistaken support for | doesn't exist in make 3.80 (the
> minimum version we require to be used).

IDK, we use order-only prerequisite already in the Makefile.

> 
>>>> +analysis-clean:
>>>> +# Reverts the original file (-p preserves also timestamp)
>>>> +  $(Q)find $(srctree) -type f -name "*.safparse" -print | \
>>>> +  while IFS= read file; do \
>>>> +          cp -p "$${file}" "$${file%.safparse}"; \
>>>> +          rm -f "$${file}"; \
>>> 
>>> Why not "mv"?
>>> 
>>>> +  done
>>>> +
>>>> +_analysis-%: analysis-build-%
>>>> +  $(Q)$(MAKE) O=$(abs_objtree) -f $(srctree)/Makefile analysis-clean
>>> 
>>> Again no use of the stem, plus here I wonder if this may not lead to
>>> people invoking "analysis-clean" without having said anything about
>>> cleaning on their command line.
>> 
>> In any case, the cleaning process is very safe and does not clean anything 
>> that was not dirty before,
>> so in case of typos, it’s just like a nop.
> 
> People may put transient files in their trees. Of course they need to be
> aware that when they specify a "clean" target their files may be deleted.
> But without any "clean" target specified nothing should be removed.

*.safparse files are not supposed to be used freely by user in their tree, those
files will be removed only if the user calls the “analysis-clean” target or if 
the
analysis-coverity or analysis-eclair reaches the end (a process that creates 
*.safparse).

There is no other way to trigger the “analysis-clean” unintentionally, so I’m 
not sure about
the modification you would like to see there.

> 
> Jan


 


Rackspace

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