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

Re: [PATCH] Add more rules to docs/misra/rules.rst


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Stefano Stabellini <stefano.stabellini@xxxxxxx>
  • Date: Thu, 26 Jan 2023 07:59:08 -0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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=khjpEyDzuKs0srj1SOymkxfPi+62LoBUiSGbPAT6KQI=; b=lW2OlqXCJ7EArNoEcsRx8D0chrvDTPODK6+A6JFK/Qb2C598yr9FolJ51kKvZg2wJivZKfdeVV31M22boyXFI7fzfpwm8jrIc4KiS6su+rGTXXD2suZ0yezEnkMDe7N98ojbVN9k7G4lsrtGwTPZjXaNwB0qCm6XdfuinCeqnolPI4zs6CaZtOxTikrEvh8zqrFC5zoLF5AJtb9GwVt+1WALcP6HOHRxVGHIpAW5YWzxKfN7m9x1xdPqnJ5/li/Ro3IuOmkou9KtwHYfadDFxExWyomvGcrZTTf619d5JaAwDpHurGoihFXP/jM9MbXvIfg0sS9D4KnRbiX61eajCA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lJAy8u549xO7FSbiHmtv6cGSNfE40BzoVH8yZb3gqVHO/ZKyocfQEr7iXYeJjt4h/HUJmZwYuCvz/l51qjRqpgk3/MZD3EG/zcPTOAXr7wd3b6sXsIPbZyz/DNvN0fG2nemBfYNogMwkPvgVS7/XXMFzIBVzMX0yTiIKm57gXj17R/qu9QX36KPCs7Ikm2fPumM/Dnhk//cjqh9XsfyHEfpakO7J46BOXsmBQSlEq6EVGmsDDPFxTxNpirMzJ381Mt/9kQoMxH/lPV3n5V/qQjQ376uKXQjwl8K2TnEZ7bsst3C9I5pUtkL0yPKpNtB4s9Py1gWELJh/j8RL+IDYLg==
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, <george.dunlap@xxxxxxxxxx>, <andrew.cooper3@xxxxxxxxxx>, <roger.pau@xxxxxxxxxx>, <Bertrand.Marquis@xxxxxxx>, <julien@xxxxxxx>, Stefano Stabellini <stefano.stabellini@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 26 Jan 2023 15:59:48 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, 26 Jan 2023, Jan Beulich wrote:
> On 25.01.2023 21:57, Stefano Stabellini wrote:
> > From: Stefano Stabellini <stefano.stabellini@xxxxxxx>
> > 
> > As agreed during the last MISRA C discussion, I am adding the following
> > MISRA C rules: 7.1, 7.3, 18.3.
> > 
> > I am also adding 13.1 and 18.2 that were "agreed pending an analysis on
> > the amount of violations".
> > 
> > In the case of 13.1 there are zero violations reported by cppcheck.
> > 
> > In the case of 18.2, there are zero violations reported by cppcheck
> > after deviating the linker symbols, as discussed.
> 
> I find this suspicious.

Hi Jan, you are right to be suspicious about 18.2 :-)  cppcheck is
clearly not doing a great job at finding violations. Here is the full
picture:

- cppcheck finds 3 violations, obviously related to linker symbols
specifically common/version.c:xen_build_init and
xen/lib/ctors.c:init_constructors

- Coverity finds 9 violations, not sure which ones

- Eclair finds 56 total on x86. Eclair is always the strictest of the
  three tools and is flagging:
  - the usage of the guest_mode macro in x86/traps.c and other places
  - the usage of the NEED_OP/NEED_IP macros in common/lzo.c
  the remaining violations should be less than 10


> See e.g. ((pg) - frame_table) expressions both Arm
> and x86 have. frame_table is neither a linker generated symbol, nor does
> it represent something that the compiler (or static analysis tools) would
> recognized as an "object". Still, the entire frame table of course
> effectively is an object (array), yet there's no way for any tool to
> actually recognize the array dimension.

I used cppcheck in my original email because it is the only tool today
where I can add a deviation as an in-code comment, re-run the scan,
and what happens (see the number of violations go down.)

However also considering that Coverity reports less than 10, and Eclair
reports more but due to only 2-3 macros, I think 18.2 should be
manageable.



 


Rackspace

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