From: Han-Wen Nienhuys <hanwen@google.com>
To: git <git@vger.kernel.org>
Subject: Fwd: coverity problems in reftable code
Date: Tue, 7 Dec 2021 12:34:15 +0100 [thread overview]
Message-ID: <CAFQ2z_OrN+RkwnMyrJHdh5xN6ueOP8KKBVQ7-U4kEkA3ApcuNg@mail.gmail.com> (raw)
In-Reply-To: <CAFQ2z_OK5949p1WfovJ00Katk5hTv_oeLo-ZRCi1XqrtzQqL2g@mail.gmail.com>
On Sat, Dec 4, 2021 at 3:13 AM Jeff King <peff@peff.net> wrote:
> We're not doing project-wide analysis with Coverity right now, but I've
> been doing builds of my personal repo, which I usually build off of
> next. And since hn/reftable just hit next, it got included in my latest
> build.
>
> It came up with several complaints. Some of them are dumb and can be
> ignored (e.g., using rand() in a test harness, oh no!) but I poked at a
> few and they look like real issues:
I fixed most of the obvious ones.
> - A lot of your structs have vtables. Initializing them to NULL, as in
> reftable_reader_refs_for_indexed(), leaves the risk that we'll try
> to call a NULL function pointer, even if it's for something simple
I have the impression that coverity doesn't understand enough of the
control flow. Some of the things it complains of are code paths that
only get executed if err==0, in which case, the struct members at hand
should not be null.
> I similarly wondered if these polymorphic types could be using a union
> within reftable_record, rather than pointing to a separate stack
> variable. Then you could initialize the whole thing without worrying
> about intermediate NULLs (and also there's less pointer chasing and it's
> a little bit more type safe than a void pointer). But again, I don't
> know the code well enough to know if that would cover all of your cases.
This is a great idea. I've made a change that does this, which I will
post shortly.
> The summary of issues is below. You can get more details on their site.
> I _think_ I've configured it so that anybody can look at:
>
> https://scan.coverity.com/projects/peff-git/view_defects
Alas, it says I have no access, even after I logged in.
--
Han-Wen Nienhuys - Google Munich
I work 80%. Don't expect answers from me on Fridays.
--
Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
next prev parent reply other threads:[~2021-12-07 11:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-04 2:13 coverity problems in reftable code Jeff King
[not found] ` <CAFQ2z_OK5949p1WfovJ00Katk5hTv_oeLo-ZRCi1XqrtzQqL2g@mail.gmail.com>
2021-12-07 11:34 ` Han-Wen Nienhuys [this message]
2021-12-07 17:46 ` Fwd: " Ævar Arnfjörð Bjarmason
2021-12-08 1:46 ` Jeff King
2021-12-08 3:26 ` Jeff King
2021-12-08 10:50 ` Han-Wen Nienhuys
2021-12-08 19:12 ` Jeff King
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=CAFQ2z_OrN+RkwnMyrJHdh5xN6ueOP8KKBVQ7-U4kEkA3ApcuNg@mail.gmail.com \
--to=hanwen@google.com \
--cc=git@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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).