Re: [PATCH][stage1] Remove conditionals around free()

2023-03-04 Thread Janne Blomqvist via Gcc-patches
On Wed, Mar 1, 2023 at 11:31 PM Bernhard Reutner-Fischer via Fortran
 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


Re: [PATCH 3/5] Fortran: Narrow return types [PR78798]

2022-11-13 Thread Janne Blomqvist via Gcc-patches
On Sun, Nov 13, 2022 at 1:47 AM Bernhard Reutner-Fischer via Fortran
 wrote:
> --- a/gcc/fortran/arith.cc
> +++ b/gcc/fortran/arith.cc
> @@ -1135,7 +1135,7 @@ compare_complex (gfc_expr *op1, gfc_expr *op2)
> strings.  We return -1 for a < b, 0 for a == b and 1 for a > b.
> We use the processor's default collating sequence.  */
>
> -int
> +signed char
>  gfc_compare_string (gfc_expr *a, gfc_expr *b)
>  {
>size_t len, alen, blen, i;
> @@ -1162,7 +1162,7 @@ gfc_compare_string (gfc_expr *a, gfc_expr *b)
>  }

Hmm, really? PR 78798 mentions changing int to bool, where
appropriate, which I think is uncontroversial, but this?


-- 
Janne Blomqvist


Re: [PATCH] Don't assume __secure_getenv is available

2017-05-08 Thread Janne Blomqvist via gcc-patches
PING

On Thu, Apr 27, 2017 at 9:55 PM, Janne Blomqvist
 wrote:
> On Thu, Apr 27, 2017 at 9:50 PM, Janne Blomqvist
>  wrote:
> [snip]
>
> And on top of that patch this simple typo fix:
>
> diff --git a/libgfortran/runtime/environ.c b/libgfortran/runtime/environ.c
> index 969dcdf..f488e87 100644
> --- a/libgfortran/runtime/environ.c
> +++ b/libgfortran/runtime/environ.c
> @@ -46,7 +46,7 @@ static char* weak_secure_getenv (const char*)
>  char *
>  secure_getenv (const char *name)
>  {
> -#if SUPPORTS_WEAKREF && defined(HAVE__SECURE_GETENV)
> +#if SUPPORTS_WEAKREF && defined(HAVE___SECURE_GETENV)
>if (weak_secure_getenv)
>  return weak_secure_getenv (name);
>  #endif
>
>
>
> --
> Janne Blomqvist



-- 
Janne Blomqvist