From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by sourceware.org (Postfix) with ESMTPS id 660D63858D1E; Sat, 4 Mar 2023 10:15:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 660D63858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-x42e.google.com with SMTP id r18so4468220wrx.1; Sat, 04 Mar 2023 02:15:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1677924912; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=zjxGEMTZNq1aDIP2ED4BApmScDwW+69BgjYi2u+PTfE=; b=XdNd5QBCztNyke/1z0uhwkmUNlEY+kFggJZDB37emhJz4jQPPFjpBdxvoGtg1yMNaY id1L7EetxB9B2lXT6jZ5mhoVxUoSjZM5RfnEKJxgVDD8SiRagCa9vzTTx5Nlc8ZXpcoz nUUcrkATJlRUQbFDQbvAtOIhdrF+0VKCuiuZOS6rNGjH0pZHuVnHRN2OMZH0zhqyJ6/j NfqvJK479cvpFqPIn2XhMNEWTu+BZAsPa1oF6bT+l8p1QNPhQ0luSO6XiaZaRyC2keQv KGY3+SsRk9pKS/i+ngFbpJ1MCjUZm6IBp8Us5iA5n9cWeME0G3D/jnf1X/I2Ff5XHawh uwdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677924912; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zjxGEMTZNq1aDIP2ED4BApmScDwW+69BgjYi2u+PTfE=; b=ap5OGAldfrQEN+DtWqfSuNx+J7QKUU19pOUZxc5QW/z1IpEH4A2QbSXHABzPbjsdP4 BpuD6CuXfAHKnVVpjOeqcourfZ/WgSw9bpS+/B/dXuCp4fhhuU99VCl+LDxwalKALxi6 Y6I4QcafzEsR0AJuEhdgpR+ocUpwV7GHs3WLMlgEf9rt7CnNbit80n9rWaRp4u+DG+8c RoL5KOY/46Txlzx4HJumE+6VP7cQdTyLKCN9t/u019YWfrWeDi/RR4fkbJboKBsgehSu 0LVeWu4LF+3kYIPXfiomebcyhj4RLgYdpY0RMhWYDPmK+O6IyQf+li/GKnU0ZKpq0R0c FMgA== X-Gm-Message-State: AO0yUKVa5KKfi5nRwtu0fUwT+nfrf5LZesC+3klkq3vemEm9lDdhwBaq +ar7WD1lXVqH3g9q12/4/DXTQmNbX/lzlgMsK24= X-Google-Smtp-Source: AK7set+28wZcoxKGUf+yWu8KaUJVAFqgbEKo6VGCKIHMp84NGWVX/Fu0L4bm5zNI8DerExEhu/gmcL3Hb4jH8rkjrao= X-Received: by 2002:adf:dc8b:0:b0:2c9:8b81:bcfc with SMTP id r11-20020adfdc8b000000b002c98b81bcfcmr897095wrj.10.1677924911788; Sat, 04 Mar 2023 02:15:11 -0800 (PST) MIME-Version: 1.0 References: <20230301222856.12300c64@nbbrfq> In-Reply-To: <20230301222856.12300c64@nbbrfq> From: Janne Blomqvist Date: Sat, 4 Mar 2023 12:15:00 +0200 Message-ID: Subject: Re: [PATCH][stage1] Remove conditionals around free() To: Bernhard Reutner-Fischer Cc: gcc-patches@gcc.gnu.org, ian@airs.com, charlet@adacore.com, fortran@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, Mar 1, 2023 at 11:31=E2=80=AFPM Bernhard Reutner-Fischer via Fortra= n wrote: > > Hi! > > Mere cosmetics. > > - if (foo !=3D 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. --=20 Janne Blomqvist