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

Re: [XEN PATCH] xen: Add SAF deviations for MISRA C:2012 Rule 7.1



Hi Stefano,

On 11/10/2023 00:39, Stefano Stabellini wrote:
On Tue, 10 Oct 2023, Julien Grall wrote:
Hi Stefano,

On 09/10/2023 23:19, Stefano Stabellini wrote:

I am not sure this is better. This is a long line to read. But this is a
personal opinion.

On the technical side, can we easily teach a tool to format this kind of
exception? If not, then this should not be an exception we should
implement.

I am not sure I understand what you mean by "can we easily teach a tool
to format this kind of exception". Do you mean whether we can teach a
tool to interpret a multiline statement as a single statement?

Sorry for the wording was not clear. I was referring to tools formatting the
code (e.g. clang-format). Hopefully, at some point, we will finally have a way
to automatically format the code. So we need a coding style that can be easily
be checked.

It is not clear to me whether your proposed exception would work. We may have
to allow longer lines (and this has drawback).

Yes, that's a good point. It will probably be an issue with clang-format.


/* cppcheck tag */
line1
/* cppcheck tag */
line2
/* cppcheck tag */
line3

and that would end up changing the line numbers in the source files so
the cppcheck report wouldn't match with the original line numbers any
longer

Would cppcheck accepts tag at the end of the line? If so, the following would
not modify the line count:

/* cppcheck tag */
line1 /* added cppcheck tag */
line2 /* added cppcheck tag */
line3 /* added cppcheck tag */

Luca answered to a similar, more generic, question a few days ago about
Coverity: https://marc.info/?l=xen-devel&m=169657904027210

Interesting.


So even if we get cppcheck to work like that, we would lose Coverity
support.

I think my suggestion was probably misunderstood. So let me clarify it. To cover multi-line, we could write the following in Xen:

/* cppcheck tag next-3-lines */
line 1
line 2
line 3

AFAIU Eclair supports multi-line, so the tag would be transformed to there internal solution. For CPPCheck, this could be transformed to:

/* cppcheck tag next-3 lines */
line 1 /* generated cppcheck tag */
line 2 /* generated cppcheck tag */
line 3 /* generated cppcheck tag */

Now, I understand that coverity doesn't support any of the two format. So the only solution would be to add the comment before each line which would impact the line numbers. This is not great, but I think this is acceptable as the context would likely help to find where this is coming from.

Cheers,

--
Julien Grall



 


Rackspace

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