bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Collin Funk <collin.funk1@gmail.com>
To: Bruno Haible <bruno@clisp.org>, Paul Eggert <eggert@cs.ucla.edu>,
	bug-gnulib@gnu.org
Subject: Re: warnings in unit tests
Date: Mon, 29 Apr 2024 17:31:09 -0700	[thread overview]
Message-ID: <736e5958-018a-43ea-bd69-8da9fc7cb76f@gmail.com> (raw)
In-Reply-To: <7804088.cEBGB3zze1@nimes>

Hi Bruno,

On 4/29/24 3:12 PM, Bruno Haible wrote:
> Note that different warning policies may contradict each other. For example,
> some people want to see a warning for
> 
>     int *table = malloc (n * sizeof (int));
> 
> because it has an implicit conversion / "lacks a cast". While other people
> want to see a warning for
> 
>     int *table = (int *) malloc (n * sizeof (int));
> 
> because it has a cast and "casts are dubious". It is impossible to satisfy
> both of these policies at the same time.

Yes, I've seen both in gnulib. I'm pretty sure the cast is required
for C++ (though I think gcc has a warning to make it less strict).

Maybe a 5th category is code taken from another GNU program. Or 4.5th
category since there are only a few glibc files and mini-gmp IIRC.
In that case the original developer and their preferences would have
to be respected of course. :)

> Back to the four sets of code:
> 
> 1) This warning policy is the responsibility of that package's maintainer,
>    obviously.
> 
> 2) These header files are used in compilation units of the package, with
>    CFLAGS or AM_CFLAGS set by the package's maintainer for that package.
>    Therefore in these files we need to avoid even -Wundef, -Wvla, and
>    other kinds of warnings that we wouldn't enable in our code.
> 
> 3) The rest of the lib/ code is under our responsibility, not the
>    responsibility of a package's maintainer. We try to avoid warnings
>    from "reasonable" warning options. More details in the HACKING file.
> 
> 4) The unit tests are also in our responsibility, not the responsibility
>    of a package's maintainer. Here, the primary concern is that is must
>    be *easy* to contribute new unit tests. -Wmissing-variable-declarations
>    warnings _could_ — as Paul wrote — be avoided by adding an 'extern'
>    declaration for each global variable. But this is extra effort that
>    would hinder the addition of new unit tests.

That makes sense to me. Thanks for the explanation.

> Collin, if you want to find relevant findings in the unit tests, by
> using gcc or clang warning options, do *not* use a coreutils build
> for this purpose, but a gnulib testdir instead. (Because the latter
> is not biased by coding style preferences of any package maintainer.)
> 
> Or if you really want to use a coreutils build, first update the
> GL_CFLAG_GNULIB_WARNINGS definition in m4/gnulib-common.m4, so that
> it eliminates useless kinds of warnings.

Ah, thanks for the tip. That sounds quicker than modifying the
Makefiles by hand.

Collin


  reply	other threads:[~2024-04-30  0:31 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-28  6:52 Pacify -Wmissing-variable-declarations in unit tests Collin Funk
2024-04-28 10:11 ` Bruno Haible
2024-04-28 11:03   ` Collin Funk
2024-04-28 23:27     ` Paul Eggert
2024-04-29  0:58       ` Collin Funk
2024-04-29 22:12         ` warnings " Bruno Haible
2024-04-30  0:31           ` Collin Funk [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-05-16 17:01 new module 'sigsegv' Bruno Haible
2021-06-07 10:29 ` Dmitry V. Levin
2021-06-08  1:45   ` Jim Meyering
2021-06-08  2:40     ` warnings in unit tests Bruno Haible
2021-06-08  5:55       ` Jim Meyering
2021-06-08  8:56         ` Bruno Haible
2021-06-09  0:41           ` Dmitry V. Levin
2021-06-10 20:05             ` Bruno Haible
     [not found]         ` <CAH8yC8kHTq5J9onJj+2jwy_DwzXrwujqFs9TEBxGh5k_KCu=kg@mail.gmail.com>
2021-06-08 10:57           ` Bruno Haible
2021-06-08 16:42             ` Paul Eggert
2021-06-09 13:35               ` Dmitry V. Levin
2021-06-09 19:38               ` Bruno Haible
2021-06-10 19:39               ` Bruno Haible
2021-06-09  7:23             ` Bernhard Voelker
2021-06-09 14:17               ` Bruno Haible
2021-06-10  8:13                 ` Simon Josefsson via Gnulib discussion list
2021-06-10 19:51                   ` Bruno Haible
2021-06-10 21:49                     ` Simon Josefsson via Gnulib discussion list
2021-06-11 12:21                     ` Eric Blake
2021-06-11 13:57                       ` Bruno Haible

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

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=736e5958-018a-43ea-bd69-8da9fc7cb76f@gmail.com \
    --to=collin.funk1@gmail.com \
    --cc=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    --cc=eggert@cs.ucla.edu \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).