From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id DDDF43856B50 for ; Mon, 12 Dec 2022 11:00:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DDDF43856B50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1670842857; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=j+VI3Ngu8BgM7yUUIrnMvS4Hfr5VJzN5tQbTy/cKKZk=; b=bXe7NIRpAHp7Fll4ddqVFMDHFIjxmAyUGKaVCX2hjfnc1QVHnbPVvopxJpDtceOb8wt0oQ NpEcgol4rq/qPIkJjev54M+5cNxGy+CcD9UVN09yoBZ7u+bQEJcOEucIZd4yacD2/ck9Ws sq2Xh4WjwR/od6tOXFKrhOoxifQ9Eu8= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-396-JX2TCvxwMdGjSnUnfFVeQw-1; Mon, 12 Dec 2022 06:00:53 -0500 X-MC-Unique: JX2TCvxwMdGjSnUnfFVeQw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CEA543C14850; Mon, 12 Dec 2022 11:00:52 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.81]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C56D340C2004; Mon, 12 Dec 2022 11:00:51 +0000 (UTC) From: Florian Weimer To: Adhemerval Zanella via Libc-alpha Cc: Fangrui Song , Adhemerval Zanella Subject: Re: [PATCH 4/7] Move libc_freeres_ptrs and libc_subfreeres to weak functions References: <20221115193159.173838-1-adhemerval.zanella@linaro.org> <20221115193159.173838-5-adhemerval.zanella@linaro.org> Date: Mon, 12 Dec 2022 12:00:47 +0100 In-Reply-To: <20221115193159.173838-5-adhemerval.zanella@linaro.org> (Adhemerval Zanella via Libc-alpha's message of "Tue, 15 Nov 2022 16:31:56 -0300") Message-ID: <874ju0ubs0.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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: * Adhemerval Zanella via Libc-alpha: > diff --git a/grp/fgetgrent.c b/grp/fgetgrent.c > index fd2b4d32d6..df04530b04 100644 > --- a/grp/fgetgrent.c > +++ b/grp/fgetgrent.c > @@ -25,7 +25,7 @@ > /* We need to protect the dynamic buffer handling. */ > __libc_lock_define_initialized (static, lock); > > -libc_freeres_ptr (static char *buffer); > +static char *buffer; > > /* Read one entry from the given stream. */ > struct group * > @@ -82,3 +82,9 @@ fgetgrent (FILE *stream) > > return result; > } > + > +void > +__libc_fgetgrent_freemem (void) > +{ > + free (buffer); > +} > diff --git a/gshadow/fgetsgent.c b/gshadow/fgetsgent.c > index 02f9c7d643..4d9282e560 100644 > --- a/gshadow/fgetsgent.c > +++ b/gshadow/fgetsgent.c > @@ -28,7 +28,7 @@ > /* We need to protect the dynamic buffer handling. */ > __libc_lock_define_initialized (static, lock); > > -libc_freeres_ptr (static char *buffer); > +static char *buffer; > > /* Read one shadow entry from the given stream. */ > struct sgrp * Missing free function in the second patch. I think you should consider introducing a call_free_static_weak that does something like if (&ptr != NULL) free (ptr); in the static case, and calls free (ptr); unconditionally for the dynamic case. And then add attribute_hidden variable declarations to a suitable wrapper header under include/. This avoids writing all these little helper functions. Thanks, Florian