From: Dongliang Mu <mudongliangabcd@gmail.com> To: Marcelo Schmitt <marcelo.schmitt1@gmail.com> Cc: Jonathan Corbet <corbet@lwn.net>, Mauro Carvalho Chehab <mchehab+huawei@kernel.org>, dlatypov@google.com, davidgow@google.com, linux-doc@vger.kernel.org, linux-sparse@vger.kernel.org, cocci@inria.fr, smatch@vger.kernel.org, linux-kernel <linux-kernel@vger.kernel.org>, skhan@linuxfoundation.org, Dan Carpenter <dan.carpenter@oracle.com>, julia.lawall@inria.fr Subject: Re: [PATCH v3 1/2] Documentation: dev-tools: Add a section for static analysis tools Date: Thu, 31 Mar 2022 12:14:19 +0800 [thread overview] Message-ID: <CAD-N9QVvgCqbwiebjVX2_81pH_YhK+j4hhJPG3fbWbAtzFVJTQ@mail.gmail.com> (raw) In-Reply-To: <7d793c1b9f87d9cb8ac0e858e561e108c2bf0176.1648674305.git.marcelo.schmitt1@gmail.com> On Thu, Mar 31, 2022 at 12:07 PM Marcelo Schmitt <marcelo.schmitt1@gmail.com> wrote: > > Complement the Kernel Testing Guide documentation page by adding a > section about static analysis tools. > > Signed-off-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com> > Acked-by: Daniel Latypov <dlatypov@google.com> > Acked-by: Dan Carpenter <dan.carpenter@oracle.com> > Acked-by: Julia Lawall <julia.lawall@inria.fr> > Reviewed-by: David Gow <davidgow@google.com> > Reviewed-by: Shuah Khan <skhan@linuxfoundation.org> > --- > Change log v2 -> v3: > - Added Julia's acknowledgment tag > > Change log v1 -> v2: > - Brought generic tool characteristics to the intro paragraph > - Made explicit that these tools run at compile time > - Added a note of caution about false positives > - Updated Coccinelle info to make it sound better and be more skimmable > > Documentation/dev-tools/testing-overview.rst | 31 ++++++++++++++++++++ > 1 file changed, 31 insertions(+) > > diff --git a/Documentation/dev-tools/testing-overview.rst b/Documentation/dev-tools/testing-overview.rst > index 65feb81edb14..b5e02dd3fd94 100644 > --- a/Documentation/dev-tools/testing-overview.rst > +++ b/Documentation/dev-tools/testing-overview.rst > @@ -115,3 +115,34 @@ that none of these errors are occurring during the test. > Some of these tools integrate with KUnit or kselftest and will > automatically fail tests if an issue is detected. > > +Static Analysis Tools > +===================== > + > +In addition to testing a running kernel, one can also analyze kernel source code > +directly (**at compile time**) using **static analysis** tools. The tools > +commonly used in the kernel allow one to inspect the whole source tree or just > +specific files within it. They make it easier to detect and fix problems during > +the development process. > + > +Sparse can help test the kernel by performing type-checking, lock checking, > +value range checking, in addition to reporting various errors and warnings while > +examining the code. See the Documentation/dev-tools/sparse.rst documentation > +page for details on how to use it. > + > +Smatch extends Sparse and provides additional checks for programming logic > +mistakes such as missing breaks in switch statements, unused return values on > +error checking, forgetting to set an error code in the return of an error path, > +etc. Smatch also has tests against more serious issues such as integer > +overflows, null pointer dereferences, and memory leaks. See the project page at > +http://smatch.sourceforge.net/. > + > +Coccinelle is another static analyzer at our disposal. Coccinelle is often used > +to aid refactoring and collateral evolution of source code, but it can also help > +to avoid certain bugs that occur in common code patterns. The types of tests > +available include API tests, tests for correct usage of kernel iterators, checks > +for the soundness of free operations, analysis of locking behavior, and further > +tests known to help keep consistent kernel usage. See the > +Documentation/dev-tools/coccinelle.rst documentation page for details. > + > +Beware, though, that static analysis tools suffer from **false positives**. > +Errors and warns need to be evaluated carefully before attempting to fix them. Hi Marcelo, Should we include static analysis tools based on LLVM? For example, Clang static analysis. > -- > 2.35.1 >
WARNING: multiple messages have this Message-ID (diff)
From: Dongliang Mu <mudongliangabcd@gmail.com> To: Marcelo Schmitt <marcelo.schmitt1@gmail.com> Cc: Jonathan Corbet <corbet@lwn.net>, Mauro Carvalho Chehab <mchehab+huawei@kernel.org>, dlatypov@google.com, davidgow@google.com, linux-doc@vger.kernel.org, linux-sparse@vger.kernel.org, cocci@inria.fr, smatch@vger.kernel.org, linux-kernel <linux-kernel@vger.kernel.org>, skhan@linuxfoundation.org, Dan Carpenter <dan.carpenter@oracle.com>, julia.lawall@inria.fr Subject: Re: [cocci] [PATCH v3 1/2] Documentation: dev-tools: Add a section for static analysis tools Date: Thu, 31 Mar 2022 12:14:19 +0800 [thread overview] Message-ID: <CAD-N9QVvgCqbwiebjVX2_81pH_YhK+j4hhJPG3fbWbAtzFVJTQ@mail.gmail.com> (raw) In-Reply-To: <7d793c1b9f87d9cb8ac0e858e561e108c2bf0176.1648674305.git.marcelo.schmitt1@gmail.com> On Thu, Mar 31, 2022 at 12:07 PM Marcelo Schmitt <marcelo.schmitt1@gmail.com> wrote: > > Complement the Kernel Testing Guide documentation page by adding a > section about static analysis tools. > > Signed-off-by: Marcelo Schmitt <marcelo.schmitt1@gmail.com> > Acked-by: Daniel Latypov <dlatypov@google.com> > Acked-by: Dan Carpenter <dan.carpenter@oracle.com> > Acked-by: Julia Lawall <julia.lawall@inria.fr> > Reviewed-by: David Gow <davidgow@google.com> > Reviewed-by: Shuah Khan <skhan@linuxfoundation.org> > --- > Change log v2 -> v3: > - Added Julia's acknowledgment tag > > Change log v1 -> v2: > - Brought generic tool characteristics to the intro paragraph > - Made explicit that these tools run at compile time > - Added a note of caution about false positives > - Updated Coccinelle info to make it sound better and be more skimmable > > Documentation/dev-tools/testing-overview.rst | 31 ++++++++++++++++++++ > 1 file changed, 31 insertions(+) > > diff --git a/Documentation/dev-tools/testing-overview.rst b/Documentation/dev-tools/testing-overview.rst > index 65feb81edb14..b5e02dd3fd94 100644 > --- a/Documentation/dev-tools/testing-overview.rst > +++ b/Documentation/dev-tools/testing-overview.rst > @@ -115,3 +115,34 @@ that none of these errors are occurring during the test. > Some of these tools integrate with KUnit or kselftest and will > automatically fail tests if an issue is detected. > > +Static Analysis Tools > +===================== > + > +In addition to testing a running kernel, one can also analyze kernel source code > +directly (**at compile time**) using **static analysis** tools. The tools > +commonly used in the kernel allow one to inspect the whole source tree or just > +specific files within it. They make it easier to detect and fix problems during > +the development process. > + > +Sparse can help test the kernel by performing type-checking, lock checking, > +value range checking, in addition to reporting various errors and warnings while > +examining the code. See the Documentation/dev-tools/sparse.rst documentation > +page for details on how to use it. > + > +Smatch extends Sparse and provides additional checks for programming logic > +mistakes such as missing breaks in switch statements, unused return values on > +error checking, forgetting to set an error code in the return of an error path, > +etc. Smatch also has tests against more serious issues such as integer > +overflows, null pointer dereferences, and memory leaks. See the project page at > +http://smatch.sourceforge.net/. > + > +Coccinelle is another static analyzer at our disposal. Coccinelle is often used > +to aid refactoring and collateral evolution of source code, but it can also help > +to avoid certain bugs that occur in common code patterns. The types of tests > +available include API tests, tests for correct usage of kernel iterators, checks > +for the soundness of free operations, analysis of locking behavior, and further > +tests known to help keep consistent kernel usage. See the > +Documentation/dev-tools/coccinelle.rst documentation page for details. > + > +Beware, though, that static analysis tools suffer from **false positives**. > +Errors and warns need to be evaluated carefully before attempting to fix them. Hi Marcelo, Should we include static analysis tools based on LLVM? For example, Clang static analysis. > -- > 2.35.1 >
next prev parent reply other threads:[~2022-03-31 4:23 UTC|newest] Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-03-30 21:49 [PATCH v3 0/2] Add a section for static analysis tools Marcelo Schmitt 2022-03-30 21:49 ` [cocci] " Marcelo Schmitt 2022-03-30 21:49 ` [PATCH v3 1/2] Documentation: dev-tools: " Marcelo Schmitt 2022-03-30 21:49 ` [cocci] " Marcelo Schmitt 2022-03-31 4:14 ` Dongliang Mu [this message] 2022-03-31 4:14 ` Dongliang Mu 2022-03-31 12:10 ` Marcelo Schmitt 2022-03-31 12:10 ` [cocci] " Marcelo Schmitt 2022-04-05 15:50 ` Jonathan Corbet 2022-04-05 15:50 ` Jonathan Corbet 2022-03-30 21:49 ` [PATCH v3 2/2] Documentation: dev-tools: Enhance static analysis section with discussion Marcelo Schmitt 2022-03-30 21:49 ` [cocci] " Marcelo Schmitt 2022-04-01 0:22 ` David Gow 2022-04-01 0:22 ` [cocci] " David Gow 2022-03-31 2:09 ` [PATCH v3 0/2] Add a section for static analysis tools David Gow 2022-03-31 2:09 ` [cocci] " David Gow
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=CAD-N9QVvgCqbwiebjVX2_81pH_YhK+j4hhJPG3fbWbAtzFVJTQ@mail.gmail.com \ --to=mudongliangabcd@gmail.com \ --cc=cocci@inria.fr \ --cc=corbet@lwn.net \ --cc=dan.carpenter@oracle.com \ --cc=davidgow@google.com \ --cc=dlatypov@google.com \ --cc=julia.lawall@inria.fr \ --cc=linux-doc@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-sparse@vger.kernel.org \ --cc=marcelo.schmitt1@gmail.com \ --cc=mchehab+huawei@kernel.org \ --cc=skhan@linuxfoundation.org \ --cc=smatch@vger.kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.