Philippe Mathieu-Daudé <phi...@redhat.com> writes: > Add a job to run common coccinelle checks.
This makes sense only for coccinelle scripts that come up clean and have a reasonably high confidence. Come up clean: we get no reports for master. Otherwise new reports will drown in the old reports, and soon enough nobody will bother to look. Reasonably high confidence: when the scripts complain, the complaint is valid often enough, and when they propose a change, the change is good enough often enough. How do the scripts proposed in this patch score? > We use spatch tool from Fedora 32 (Docker image) because > more recent versions are failing. > > Signed-off-by: Philippe Mathieu-Daudé <phi...@redhat.com> > --- > Based-on: <20210311192700.1441263-1-phi...@redhat.com> > --- > .gitlab-ci.d/containers.yml | 5 ++++ > .gitlab-ci.yml | 26 +++++++++++++++++++ > .../dockerfiles/fedora-coccinelle.docker | 16 ++++++++++++ > 3 files changed, 47 insertions(+) > create mode 100644 tests/docker/dockerfiles/fedora-coccinelle.docker > > diff --git a/.gitlab-ci.d/containers.yml b/.gitlab-ci.d/containers.yml > index 33e4046e233..8f14afdccab 100644 > --- a/.gitlab-ci.d/containers.yml > +++ b/.gitlab-ci.d/containers.yml > @@ -249,3 +249,8 @@ amd64-opensuse-leap-container: > <<: *container_job_definition > variables: > NAME: opensuse-leap > + > +cocci-fedora-container: > + <<: *container_job_definition > + variables: > + NAME: fedora-coccinelle > diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml > index 07202f6ffb2..615a0b98fe2 100644 > --- a/.gitlab-ci.yml > +++ b/.gitlab-ci.yml > @@ -746,6 +746,32 @@ build-libvhost-user: > - meson > - ninja > > +check-cocci: > + stage: build > + needs: ['cocci-fedora-container'] > + image: $CI_REGISTRY_IMAGE/qemu/fedora-coccinelle:latest > + script: > + - for script in > + scripts/coccinelle/errp-guard.cocci I doubt the tree's state permits this one. Its output should not be applied blindly. > + scripts/coccinelle/exec_rw_const.cocci > + scripts/coccinelle/inplace-byteswaps.cocci > + scripts/coccinelle/overflow_muldiv64.cocci > + scripts/coccinelle/qom-parent-type.cocci > + scripts/coccinelle/qom-parent-type.cocci > + scripts/coccinelle/remove_local_err.cocci > + scripts/coccinelle/remove_muldiv64.cocci > + scripts/coccinelle/return_directly.cocci > + scripts/coccinelle/typecast.cocci > + scripts/coccinelle/use-after-abort-fatal-errp.cocci > + ; do > + spatch --macro-file scripts/cocci-macro-file.h > + --sp-file $script > + --timeout 137 > + --jobs 2 > + --use-gitgrep > + --dir . > + ; done > + > # Prepare for GitLab pages deployment. Anything copied into the > # "public" directory will be deployed to $USER.gitlab.io/$PROJECT > pages: > diff --git a/tests/docker/dockerfiles/fedora-coccinelle.docker > b/tests/docker/dockerfiles/fedora-coccinelle.docker > new file mode 100644 > index 00000000000..5392c73fcb2 > --- /dev/null > +++ b/tests/docker/dockerfiles/fedora-coccinelle.docker > @@ -0,0 +1,16 @@ > +# > +# Docker image to run Coccinelle spatch > +# (program matching and transformation engine) > +# > +# Copyright (C) 2021 Red Hat, Inc. > +# > +# SPDX-License-Identifier: GPL-2.0-or-later > + > +FROM fedora:32 > + > +# Please keep this list sorted alphabetically > +RUN dnf install -y \ > + coccinelle \ > + diffutils \ > + findutils \ > + git-core