public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Janne Blomqvist <blomqvist.janne@gmail.com>
To: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Cc: gcc-patches@gcc.gnu.org, ian@airs.com, charlet@adacore.com,
	 fortran@gcc.gnu.org
Subject: Re: [PATCH][stage1] Remove conditionals around free()
Date: Sat, 4 Mar 2023 12:15:00 +0200	[thread overview]
Message-ID: <CAO9iq9G11qWGOHMbb=sPn1zDk3CHN8ZguO7jcK=HrsVwnD1gCA@mail.gmail.com> (raw)
In-Reply-To: <20230301222856.12300c64@nbbrfq>

On Wed, Mar 1, 2023 at 11:31 PM Bernhard Reutner-Fischer via Fortran
<fortran@gcc.gnu.org> wrote:
>
> Hi!
>
> Mere cosmetics.
>
> - if (foo != NULL)
>     free (foo);
>
> With the caveat that coccinelle ruins replacement whitespace or i'm
> uneducated enough to be unable to _not_ run the diff through
>  sed -e 's/^+\([[:space:]]*\)free(/+\1free (/'
> at least. If anybody knows how to improve replacement whitespace,
> i'd be interrested but didn't look nor ask. ISTM that leading
> whitespace is somewhat ruined, too, so beware (8 spaces versus tab as
> far as i have spot-checked).
>
> Would touch
>  gcc/ada/rtinit.c             |    3 +--
>  intl/bindtextdom.c           |    3 +--
>  intl/loadmsgcat.c            |    6 ++----
>  intl/localcharset.c          |    3 +--
>  libbacktrace/xztest.c        |    9 +++------
>  libbacktrace/zstdtest.c      |    9 +++------
>  libbacktrace/ztest.c         |    9 +++------
>  libgfortran/caf/single.c     |    6 ++----
>  libgfortran/io/async.c       |    6 ++----
>  libgfortran/io/format.c      |    3 +--
>  libgfortran/io/transfer.c    |    6 ++----
>  libgfortran/io/unix.c        |    3 +--
>  libgo/runtime/go-setenv.c    |    6 ++----
>  libgo/runtime/go-unsetenv.c  |    3 +--
>  libgomp/target.c             |    3 +--
>  libiberty/concat.c           |    3 +--
>  zlib/contrib/minizip/unzip.c |    2 +-
>  zlib/contrib/minizip/zip.c   |    2 +-
>  zlib/examples/enough.c       |    6 ++----
>  zlib/examples/gun.c          |    2 +-
>  zlib/examples/gzjoin.c       |    3 +--
>  zlib/examples/gzlog.c        |    6 ++----
>
> coccinelle script and invocation inline.
> Would need to be split for the respective maintainers and run through
> mklog with subject changelog and should of course be compiled and
> tested before that.
>
> Remarks:
> 1) We should do this in if-conversion (?) on our own.
>    I suppose. Independently of -fdelete-null-pointer-checks
> 2) Maybe not silently, but raise language awareness nowadays.
>    By now it's been a long time since this was first mandated.
> 3) fallout from looking at something completely different
> 4) i most likely will not remember to split it apart and send proper
>    patches, tested patches, in stage 1 to maintainers proper, so if
>    anyone feels like pursuing this, be my guest. I thought i'd just
>    mention it.
>
> cheers,

Back in 2011 Jim Meyering applied a patch doing this, see
https://gcc.gnu.org/legacy-ml/gcc-patches/2011-03/msg00403.html , and
the gcc/README.Portability snippet added then which is still there.

Per analysis done then, it seems SunOS 4 was the last system where
free() of a NULL pointer didn't behave per the spec.

Also in Jim's patch intl/ and zlib/ directories were not touched as
those are imported from other upstreams.

-- 
Janne Blomqvist

  parent reply	other threads:[~2023-03-04 10:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-01 21:28 Bernhard Reutner-Fischer
2023-03-01 21:58 ` Bernhard Reutner-Fischer
2023-03-01 22:54   ` Bernhard Reutner-Fischer
2023-03-01 22:59 ` Andrew Pinski
2023-03-01 23:52   ` Bernhard Reutner-Fischer
2023-03-02  0:39     ` Andrew Pinski
2023-03-02  0:07 ` Steve Kargl
2023-03-02  1:23   ` Jerry D
2023-03-03 23:11     ` Bernhard Reutner-Fischer
2023-03-03 23:32       ` Iain Sandoe
2023-03-04  3:14         ` Jerry D
2023-03-24  6:30           ` NightStrike
2023-05-08  6:01   ` Bernhard Reutner-Fischer
2023-03-02  3:23 ` Ian Lance Taylor
2023-03-04 10:15 ` Janne Blomqvist [this message]
2023-03-22  7:21   ` Eric Gallager
2023-03-08 21:56 ` Thomas Schwinge

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='CAO9iq9G11qWGOHMbb=sPn1zDk3CHN8ZguO7jcK=HrsVwnD1gCA@mail.gmail.com' \
    --to=blomqvist.janne@gmail.com \
    --cc=charlet@adacore.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ian@airs.com \
    --cc=rep.dot.nop@gmail.com \
    /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).